🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #579

Read pixels from a file and display it on the screen

#579
From: Hakan
Date: Thu, 24 Feb 2005 10:41
20 lines
1502 bytes
Hello all

In my program I decode a file format and display it on a JPanel.
Each pixel in the file is tored as 10 bits so I do some conversion and store each pixel value in an integer (only lower 
16 bits contain information) I use BufferedImage(I am not sure 
if this is the most suitable one) and dipslay the image on 
Jpanel as Black&White (the code is below). But colors don't look 
correct. 

Any ideas on how I can correct this?
Thank you.

Hakan

       bi = new BufferedImage(width, height,    
BufferedImage.TYPE_USHORT_GRAY);
       WritableRaster wr = bi.getRaster();
       wr.setPixels(0, 0, width, height, valsdisplay);
       repaint();
Technical Details
Message-ID: <421daf5e$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 111d45,e4e44d651d8a47ff,start
X-Google-Attributes: gid111d45,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Hakan" <hkocak@meteor.gov.tr>
Sender: "Hakan" <hkocak@meteor.gov.tr>
Reply-To: "Hakan" <hkocak@meteor.gov.tr>
Subject: Read pixels from a file and display it on the screen
Newsgroups: borland.public.jbuilder.java.swing
X-User-Info: 163.165.203.190     
NNTP-Posting-Host: 207.105.83.66
Message-ID: <421daf5e$1@newsgroups.borland.com>
Date: 24 Feb 2005 02:41:34 -0800
X-Trace: newsgroups.borland.com 1109241694 207.105.83.66 (24 Feb 2005 02:41:34 -0800)
Lines: 22
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail