Thanks. My images are of TYPE_BYTE_INDEX. To which type should I convert in order to get correct colors in Java3D?
Regards, Fredrik -----Ursprungligt meddelande----- Fr�n: Discussion list for Java 3D API [mailto:[EMAIL PROTECTED]]F�r Dipasqua, Aldo Skickat: den 14 januari 2002 14:29 Till: [EMAIL PROTECTED] �mne: Re: [JAVA3D] TextureLoading with JAI You might want to use an image converter as shown below. Aldo /** * Convert any buffered image to another type of buffered image * @param oldImage the image to be converted * @param type the image type (e.g. BufferedImage.TYPE_3BYTE_BGR, etc.) * @return the new image of type specified and the of the same dimension */ public static BufferedImage convertBufferedImageType( BufferedImage oldImage, int type ) { BufferedImage newImage = null; if( oldImage != null ) { // No conversion for the same type if( oldImage.getType() == type ) { newImage = oldImage; } else { // Make a buffered image of type newImage = new BufferedImage( oldImage.getWidth(), oldImage.getHeight(), type ); // Draw the input image to the new image Graphics2D graphics = newImage.createGraphics(); graphics.drawImage( oldImage, null, null ); graphics.dispose(); } } return newImage; } -----Original Message----- From: Dipl. Ing. Paul Szawlowski [mailto:[EMAIL PROTECTED]] Sent: Monday, January 14, 2002 7:47 AM To: [EMAIL PROTECTED] Subject: Re: [JAVA3D] TextureLoading with JAI I'm ot quite sure about that but there are BufferedImage formats like BGR and RGB. So I suppose that the order of the color bands is reversed. Check the BufferedImage typae after reading. To Correct this you will have to go deeper into the java.awt.image package. Probably it can be solved by creating a new BufferedImage with a SampleModel which defines a new order how the banks are mapped to bands. If this is possible you don't have to make a copy of the image data. regards Paul Fredrik Lyd�n schrieb: > Hi! > > I have some problems loading textures with JAI; > > PlanarImage planarImage = JAI.create("fileload", fileName); > Texture texture = new TextureLoader(planarImage.getAsBufferedImage()); > > results in incorrect colors (i.e. yellow gets turquoise). > > Without using JAI the colors are correct, but the loading is very slow > (15 seconds compared to 4 with JAI). > > Thankful for any tips! > > Regards, > Fredrik > > ====================================================================== ===== > To unsubscribe, send email to [EMAIL PROTECTED] and include in the body > of the message "signoff JAVA3D-INTEREST". For general help, send email to > [EMAIL PROTECTED] and include in the body of the message "help". ====================================================================== ====To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA3D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help". ====================================================================== ====To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA3D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help". =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA3D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
