Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] 'Unsupported color depth' error on Linux


Thanks Udaya and Chris for providing alternatives. Actually, before sending out email I had tried SWT.IMAGE_JPEG and that worked. However, I am still interested in why the SWT.IMAGE_GIF case is failing.

Getting to Randy's question, here is some more detail as to what I am doing:


// We use Eclipse's ImageDescriptor/ImageRegistry mechanism to initially create all the

// images and then we get the particular image we want

Image image = ....

ImageData = image.getImageData();

// at this point color depth is 32

// We then create 8 bit version of this image

// Step1:create 8 bit palette

PaletteData paletteData = ...

// Step2:Create new image data with color depth 8 and using palette above but

// dimensions of original image

ImageData newImageData = new ImageData (imageData.width, imageData.height, 8, paletteData);

// Step3:create image

Image newImage = new Image (display, newImageData);

// Step4:Paint original image into new image using GCs

GC gc = new GC (newImage);

gc.drawImage (image, 0, 0);

gc.dispose();

// Step5: Retrieve the image data for the new image

newImageData = newImage.getImageData ();

// at this point the depth is 24 and consequently the save call throws SWT.Error


Rajeev


Randy Hudson/Raleigh/IBM@IBMUS
Sent by: platform-swt-dev-admin@xxxxxxxxxxx

07/29/2004 04:00 PM
Please respond to platform-swt-dev

       
        To:        platform-swt-dev@xxxxxxxxxxx
        cc:        
        Subject:        Re: [platform-swt-dev] 'Unsupported color depth' error on Linux




Rajeev,


You left out an important piece of information.  How are you constructing the Image?  If it is simply a new Image(display, width, height), the color depth is the same as the Display's color depth.  So this will vary even just on windows.  We should continue this discussion on the newsgroup if necessary.


-Randy



"Udaya Tejwani" <udayatejwani@xxxxxxxxxxx>
Sent by: platform-swt-dev-admin@xxxxxxxxxxx

07/29/2004 06:26 PM
Please respond to platform-swt-dev

       
       To:        platform-swt-dev@xxxxxxxxxxx

       cc:        

       Subject:        Re: [platform-swt-dev] 'Unsupported color depth' error on Linux




What Chris simply means is replace the following code

>imageLoader.save(..., SWT.IMAGE_GIF);

with

>imageLoader.save(..., SWT.IMAGE_BMP);

Hope this helps.

Udaya Tejwani

>From: Rajeev Sikka <sikkar@xxxxxxxxxx>
>Reply-To: platform-swt-dev@xxxxxxxxxxx
>
>Hi Chris,
>
>I could not follow your answer. Could you elaborate.
>
>Thanks,
>Rajeev
>
>
>
>
>Christophe Cornu <Christophe_Cornu@xxxxxxxxxx>
>Sent by: platform-swt-dev-admin@xxxxxxxxxxx
>07/29/2004 12:28 PM
>Please respond to platform-swt-dev
>
>         To:     platform-swt-dev@xxxxxxxxxxx
>         cc:
>         Subject:        Re: [platform-swt-dev] 'Unsupported color depth'
>error on Linux
>
>
>
>Hi Rajeev,
>
>Unlike GIF, the BMP encoder should support all the bit depths.
>
>Chris
>
>
>
>
>Rajeev Sikka <sikkar@xxxxxxxxxx>
>Sent by: platform-swt-dev-admin@xxxxxxxxxxx
>07/29/2004 01:42 PM
>
>Please respond to
>platform-swt-dev
>
>
>To
>platform-swt-dev@xxxxxxxxxxx
>cc
>
>Subject
>[platform-swt-dev] 'Unsupported color depth' error on Linux
>
>
>Hi,
>
>I have the following code sequence:
>
>...
>Image image = ...
>...
>ImageData imageData = image.getImageData();
>...
>ImageLoader imageLoader = new ImageLoader();
>imageLoader.save(..., SWT.IMAGE_GIF);
>...
>
>This runs fine on windows but gives 'Unsupported color depth' error on
>Linux. The reason is that the code for Image::getImageData() is different
>for Windows and Linux. On Linux the returned ImageData object has color
>depth 24 (on windows its 8). Here is the code snippet from Image.java on
>Linux:
>
>ImageData data = "" ImageData(width, height, 24, palette);
>
>Subsequently, the function ImageLoader::save which indirectly calls
>unloadIntoByteStream(ImageData ) in file GIFFileFormat.java throws a
>SWT.error, since valid color depths are only 1, 4, and 8.
>
>Is there any workaround/alternative way to get around this?
>
>Thanks,
>Rajeev


Discover the best of the best at MSN Luxury Living.
_______________________________________________ platform-swt-dev mailing list platform-swt-dev@xxxxxxxxxxx http://dev.eclipse.org/mailman/listinfo/platform-swt-dev


Back to the top