Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / August 2003

Tip: Looking for answers? Try searching our database.

Scaled BufferedImage turns black - interpolation mode mystery!

Thread view: 
Ken DeLong - 29 Aug 2003 05:42 GMT
I'm constructing a BufferedImage out of a byte array.  Each pixel in
the array is 3 bytes long, ostensibly RGB but it's actually a
monochrome image so the three channels are always the same.  My BI
construction is:

DataBuffer db = new DataBufferByte(buffer, buffer.length);
WritableRaster raster = Raster.createInterleavedRaster(db, width,
height, width*3, 3, new int[]{0}, null);
bi = new BufferedImage(indexedColorModel, raster, false, null);       

and I draw with
g2.drawImage(bi, 0, 0, getWidth(), getHeight(), null);

Now here's the funny behavior: with the interpolation mode set to
nearest-neighbor, the image only displays when the panel size matches
the image size.  If I resize the frame, the image surface goes black
(black is the zero color in my indexed color model).  If I set the
interpolation mode to nearest-neighbor, it works just fine.

Any idea what in the world is going on here???
Ana - 29 Aug 2003 19:37 GMT
Ken, try to construct the BufferedImage directly. I found that much easier
to deal with. There are BufferedImage constructors for indexColorModel
support.

Ana

> I'm constructing a BufferedImage out of a byte array.  Each pixel in
> the array is 3 bytes long, ostensibly RGB but it's actually a
[quoted text clipped - 16 lines]
>
> Any idea what in the world is going on here???
Ken DeLong - 30 Aug 2003 21:51 GMT
Well, the problem is that I don't have control over the format of the
data source.  So I need to wrap the incoming array of bytes in a
DataBuffer, and I need access to the Raster factory methods to specify
which bytes are relevant.

> Ken, try to construct the BufferedImage directly. I found that much easier
> to deal with. There are BufferedImage constructors for indexColorModel
[quoted text clipped - 22 lines]
> >
> > Any idea what in the world is going on here???


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.