/// <summary> /// The runnable method for this class. This will produce an image using /// the current RenderableImage and RenderContext and send it to all the /// ImageConsumer currently registered with this class. /// </summary> public virtual void Run() { // First get the rendered image RenderedImage rdrdImage; if (Rc != null) { rdrdImage = RdblImage.CreateRendering(Rc); } else { rdrdImage = RdblImage.CreateDefaultRendering(); } // And its ColorModel ColorModel colorModel = rdrdImage.ColorModel; Raster raster = rdrdImage.Data; SampleModel sampleModel = raster.SampleModel; DataBuffer dataBuffer = raster.DataBuffer; if (colorModel == null) { colorModel = ColorModel.RGBdefault; } int minX = raster.MinX; int minY = raster.MinY; int width = raster.Width; int height = raster.Height; System.Collections.IEnumerator icList; ImageConsumer ic; // Set up the ImageConsumers icList = Ics.elements(); while (icList.hasMoreElements()) { ic = (ImageConsumer)icList.nextElement(); ic.SetDimensions(width, height); ic.Hints = java.awt.image.ImageConsumer_Fields.TOPDOWNLEFTRIGHT | java.awt.image.ImageConsumer_Fields.COMPLETESCANLINES | java.awt.image.ImageConsumer_Fields.SINGLEPASS | java.awt.image.ImageConsumer_Fields.SINGLEFRAME; } // Get RGB pixels from the raster scanline by scanline and // send to consumers. int[] pix = new int[width]; int i, j; int numBands = sampleModel.NumBands; int[] tmpPixel = new int[numBands]; for (j = 0; j < height; j++) { for (i = 0; i < width; i++) { sampleModel.GetPixel(i, j, tmpPixel, dataBuffer); pix[i] = colorModel.GetDataElement(tmpPixel, 0); } // Now send the scanline to the Consumers icList = Ics.elements(); while (icList.hasMoreElements()) { ic = (ImageConsumer)icList.nextElement(); ic.SetPixels(0, j, width, 1, colorModel, pix, 0, width); } } // Now tell the consumers we're done. icList = Ics.elements(); while (icList.hasMoreElements()) { ic = (ImageConsumer)icList.nextElement(); ic.ImageComplete(java.awt.image.ImageConsumer_Fields.STATICIMAGEDONE); } }