Hello, Ted,

 > I would have expected that at least one of the following that I have
 > overriden would get called:
 >
 > getDataElement
 > getDataElements
 > getSample
 > getSamples
 > getPixel
 > getPixels

  taking into consideration the operation you're performing
  (drawImage) these methods are not supposed to be called
  because of their inefficiency.
  They might be called if there is no other way to copy pixels
  from source surface to destination but that's a rare case as
  we have loops for all frequently used surface types.

  The efficiency (and speed) of drawImage operation depends on
  the types of surfaces involved as well as the operation
  performed (xor or alpha compositing, for example).

  drawImage often could be boiled down to just a loop of
  memcpy's or (on win32) a direct draw blit operation.

  Thank you,
    Dmitri

On Wed, Aug 16, 2000 at 03:28:0p -0500, Ted Hill wrote:
 > Hello,
 >
 > I want to use BufferedImage to displays 2D 'slices' of a 3D data set.
 >
 > Several slices will be displayed simultaneously.
 >
 > I do not want to copy data from the 3D data set to the WritableRaster of
 > each BufferedImage instance. (The 3D data set is just a large array of
 > shorts (TYPE_USHORT).)
 >
 > Instead I want each BufferedImage to draw its data directly from the single
 > 3D data set.  I assume that this is possible by having each BufferedImage
 > instance have its own SampleModel that knows how to pull a 2D plane of
 > pixels from the 3D data set.
 >
 > So far what I have done is this:
 >
 > ///////////////********************
 >
 > final int transferType = DataBuffer.TYPE_USHORT;
 >
 > // 0. Read the data file for all slices into a one dimensional short array
 >             short [ ] allSliceDataArray = get3DDataArray( );
 >
 > // 1. Create a DataBufferUShort( ) from existing short[ ]
 >             DataBuffer allSliceDataBuffer = new
 > DataBufferUShort(allSliceDataArray, allSliceDataArray.length);
 >
 > // 2. Create a compatible SampleModel
 >             SampleModel sm = new MyPixelInterleavedSampleModel(transferType,
 > 512, 512, 1, 512, new int[ ] {0});
 >
 > // 3. Use the DataBuffer from 1. above to create a Raster
 >             WritableRaster allSliceRaster = Raster.createWritableRaster(sm,
 > allSliceDataBuffer, new Point(0, 0));
 >
 > // 4. Create a compatible ColorModel
 >             ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
 >             ColorModel cm = new ComponentColorModel(cs, new int[ ] {16},
 > false, false, Transparency.OPAQUE, transferType);
 >
 > // 5. Finally create the BufferedImage using the Raster from 3. above.
 >             BufferedImage bi = new BufferedImage(cm, allSliceRaster, false,
 > null);
 >
 > /////////////////***************
 >
 > Using the BufferedImage created in step 5, I am able to display the 'first'
 > 2D slice in a JPanel as follows:
 >
 >     public void paint(Graphics g)
 >     {
 >         Graphics2D g2 = (Graphics2D) g;
 >         g2.drawImage(bufferedImage, 0, 0, this);
 >     }
 >
 > To display other 2D slices of the 3D data, I was planning to override
 > methods of PixelInterleavedSampleModel. So in my class,
 > MyPixelInterleavedSampleModel, I have overridden several methods of
 > PixelInterleavedSampleModel, ComponentSampleModel, and SampleModel itself.
 >
 > The big puzzler is that none of my overriden methods get called!
 >
 > All of my overrides in MyPixelInterleavedSampleModel are similar to these:
 >
 >     public Object getDataElements(int x, int y, Object obj, DataBuffer data)
 >     {
 >         System.out.println("getDataElements 1");
 >         return super.getDataElements(x,y,obj,data);
 >     }
 >
 >     public Object getDataElements(int x, int y, int w, int h, Object obj,
 > DataBuffer data)
 >     {
 >         System.out.println("getDataElements 2");
 >         return super.getDataElements(x,y,w,h,obj,data);
 >     }
 >
 > where I simply print out a trace statement and then return super's output.
 >
 > Everything compiles and runs fine, but I can't find any methods that get
 > called in MyPixelInterleavedSampleModel. The only trace statement that gets
 > printed out is the one in my constructor. There are a few final methods in
 > the super classess that are final and thus cannot be overriden, but they
 > seem like helper methods, e.g. ComponentModel.getScanlineStride( )
 >
 > I would have expected that at least one of the following that I have
 > overriden would get called:
 >
 > getDataElement
 > getDataElements
 > getSample
 > getSamples
 > getPixel
 > getPixels
 >
 >
 > Any ideas?
 >
 > Thanks,
 >
 > Ted Hill
 >
 > ===========================================================================
 > To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
 > of the message "signoff JAVA2D-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 JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to