| Summary: | Exception while saving image data | ||
|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Ivan Furnadjiev <ivan> |
| Component: | SWT | Assignee: | Platform-SWT-Inbox <platform-swt-inbox> |
| Status: | RESOLVED WORKSFORME | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | eclipse.felipe, rsternberg |
| Version: | 3.6 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | |||
| Bug Depends on: | |||
| Bug Blocks: | 324440 | ||
That is wrong, you can't use indirect palette with 24 bit depth. Create the palette using masks (direct palette), that should work. |
Using the test case below: public void testCase() { Display display = new Display(); Color white = display.getSystemColor( SWT.COLOR_WHITE ); PaletteData palette = new PaletteData( new RGB[] { white.getRGB() } ); ImageData imageData = new ImageData( 10, 10, 24, palette ); ImageLoader imageLoader = new ImageLoader(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); imageLoader.data = new ImageData[] { imageData }; imageLoader.save( outputStream, SWT.IMAGE_PNG ); assertTrue( outputStream.toByteArray().length > 0 ); } we got the following exception: org.eclipse.swt.SWTException: Unsupported color depth at org.eclipse.swt.SWT.error(SWT.java:4209) at org.eclipse.swt.SWT.error(SWT.java:4124) at org.eclipse.swt.SWT.error(SWT.java:4095) at org.eclipse.swt.graphics.ImageData.getPixels(ImageData.java:850) at org.eclipse.swt.internal.image.PngEncoder.writeImageData(PngEncoder.java:247) at org.eclipse.swt.internal.image.PngEncoder.encode(PngEncoder.java:349) at org.eclipse.swt.internal.image.PNGFileFormat.unloadIntoByteStream(PNGFileFormat.java:146) at org.eclipse.swt.internal.image.FileFormat.unloadIntoStream(FileFormat.java:122) at org.eclipse.swt.internal.image.FileFormat.save(FileFormat.java:110) at org.eclipse.swt.graphics.ImageLoader.save(ImageLoader.java:202) at Image_Test.testCase(Image_Test.java:55) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at junit.framework.TestCase.runTest(TestCase.java:164) at junit.framework.TestCase.runBare(TestCase.java:130) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:120) at junit.framework.TestSuite.runTest(TestSuite.java:230) at junit.framework.TestSuite.run(TestSuite.java:225) at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Is using of "indexed palette" with a color depth of 24 valid?