Warning: Can't synchronize with repository "(default)" (/home/git/ome.git does not appear to be a Git repository.). Look in the Trac log for more information.

Ticket #729: NoClassDefFoundErrorTest.java

File NoClassDefFoundErrorTest.java, 2.1 KB (added by callan, 17 years ago)

Test case

Line 
1import java.awt.*;
2import java.awt.image.*;
3import sun.awt.image.IntegerInterleavedRaster;
4
5
6class NoClassDefFoundErrorTest
7{
8    private static final int SIZE_X = 10;
9    private static final int SIZE_Y = 10;
10   
11    public BufferedImage createBufferedImage(int[] buf, int sizeX, int sizeY)
12    {
13        System.out.println("DataBufferInt and DataBuffer");
14        // First wrap the packed integer array with a Java2D buffer
15        DataBuffer j2DBuf = new DataBufferInt(buf, sizeX * sizeY, 0);
16
17        System.out.println("SinglePixelPackedSampleModel");
18        // Create a sample model which supplies the bit masks for each colour
19        // component.
20        SinglePixelPackedSampleModel sampleModel =
21            new SinglePixelPackedSampleModel(
22                DataBuffer.TYPE_INT, sizeX, sizeY, sizeX, new int[] {
23                        0x00ff0000, // Red
24                        0x0000ff00, // Green
25                        0x000000ff, // Blue
26                        // 0xff000000 // Alpha
27            });
28
29        System.out.println("WritableRaster, IntegerInterleavedRaster and Point");
30        // Now create a compatible raster which wraps the Java2D buffer and is
31        // told how to get to the pixel data by the sample model.
32        WritableRaster raster = new IntegerInterleavedRaster(sampleModel,
33                j2DBuf, new Point(0, 0));
34
35        System.out.println("ColorModel, DirectColorModel and BufferedImage");
36        // Finally create a screen accessible colour model and wrap the raster
37        // in a buffered image.
38        ColorModel colorModel = new DirectColorModel(24, 0x00ff0000, // Red
39                0x0000ff00, // Green
40                0x000000ff // Blue
41        // 0xff000000 // Alpha
42        );
43        BufferedImage image = new BufferedImage(colorModel, raster, false, null);
44
45        System.out.println("Returning buffered image...");
46        return image;
47    }
48   
49    public static void main(String[] argv)
50    {
51        NoClassDefFoundErrorTest t = new NoClassDefFoundErrorTest();
52
53        int[] buffer = new int[SIZE_X * SIZE_Y];
54        t.createBufferedImage(buffer, SIZE_X, SIZE_Y);
55        System.out.println("Exiting...");
56    }
57}

1.3.13-PRO © 2008-2011 Agilo Software all rights reserved (this page was served in: 0.29399 sec.)

We're Hiring!