當前位置: 首頁>>代碼示例>>Java>>正文


Java DataBufferInt.getData方法代碼示例

本文整理匯總了Java中java.awt.image.DataBufferInt.getData方法的典型用法代碼示例。如果您正苦於以下問題:Java DataBufferInt.getData方法的具體用法?Java DataBufferInt.getData怎麽用?Java DataBufferInt.getData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.image.DataBufferInt的用法示例。


在下文中一共展示了DataBufferInt.getData方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: write

import java.awt.image.DataBufferInt; //導入方法依賴的package包/類
/**
 * Write a tile image to a stream.
 *
 * @param tile the image
 * @param out the stream
 *
 * @throws ImageIOException if the write fails
 */
public static void write(BufferedImage tile, OutputStream out)
                                                         throws IOException {
  ByteBuffer bb;

  // write the header
  bb = ByteBuffer.allocate(18);

  bb.put("VASSAL".getBytes())
    .putInt(tile.getWidth())
    .putInt(tile.getHeight())
    .putInt(tile.getType());

  out.write(bb.array());

  // write the tile data
  final DataBufferInt db = (DataBufferInt) tile.getRaster().getDataBuffer();
  final int[] data = db.getData();

  bb = ByteBuffer.allocate(4*data.length);
  bb.asIntBuffer().put(data);

  final GZIPOutputStream zout = new GZIPOutputStream(out);
  zout.write(bb.array());
  zout.finish();
}
 
開發者ID:ajmath,項目名稱:VASSAL-src,代碼行數:34,代碼來源:TileUtils.java

示例2: initImageMem

import java.awt.image.DataBufferInt; //導入方法依賴的package包/類
private cl_mem initImageMem(BufferedImage img) {
    cl_image_format imageFormat = new cl_image_format();
    imageFormat.image_channel_order = CL_RGBA;
    imageFormat.image_channel_data_type = CL_UNSIGNED_INT8;
    
    // Create the memory object for the input image
    DataBufferInt dataBufferSrc = (DataBufferInt)img.getRaster().getDataBuffer();
    int dataSrc[] = dataBufferSrc.getData();

    cl_mem inputImageMem = CL.clCreateImage2D(
        context, CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR,
        new cl_image_format[]{imageFormat}, img.getWidth(), img.getHeight(),
        img.getWidth() * Sizeof.cl_uint, Pointer.to(dataSrc), null);
    
    return  inputImageMem;
}
 
開發者ID:iapafoto,項目名稱:DicomViewer,代碼行數:17,代碼來源:OpenCLWithJOCL.java

示例3: fix_tRNS

import java.awt.image.DataBufferInt; //導入方法依賴的package包/類
protected BufferedImage fix_tRNS(Reference<BufferedImage> ref,
                                 int tRNS, int type) throws ImageIOException {
  BufferedImage img = ref.obj;

  // Ensure that we are working with integer ARGB data. Whether it's
  // premultiplied doesn't matter, since fully transparent black pixels
  // are the same in both.
  if (img.getType() != BufferedImage.TYPE_INT_ARGB &&
      img.getType() != BufferedImage.TYPE_INT_ARGB_PRE) {

    // If the requested type is not an ARGB one, then we convert to ARGB
    // for applying this fix.
    if (type != BufferedImage.TYPE_INT_ARGB &&
        type != BufferedImage.TYPE_INT_ARGB_PRE) {
      type = BufferedImage.TYPE_INT_ARGB;
    }

    img = null;
    img = tconv.convert(ref, type);
  }

  // NB: This unmanages the image.
  final DataBufferInt db = (DataBufferInt) img.getRaster().getDataBuffer();
  final int[] data = db.getData();

  // Set all pixels of the transparent color to have alpha 0.
  for (int i = 0; i < data.length; ++i) {
    if (data[i] == tRNS) data[i] = 0x00000000;
  }

  return img;
}
 
開發者ID:ajmath,項目名稱:VASSAL-src,代碼行數:33,代碼來源:ImageIOImageLoader.java

示例4: fix_YCbCr

import java.awt.image.DataBufferInt; //導入方法依賴的package包/類
protected BufferedImage fix_YCbCr(Reference<BufferedImage> ref, int type)
                                                    throws ImageIOException {
  BufferedImage img = ref.obj;

  // Ensure that we are working with RGB or ARGB data.
  if (img.getType() != BufferedImage.TYPE_INT_RGB &&
      img.getType() != BufferedImage.TYPE_INT_ARGB) {

    if (type != BufferedImage.TYPE_INT_RGB &&
        type != BufferedImage.TYPE_INT_ARGB) {
      type = BufferedImage.TYPE_INT_ARGB;
    }

    img = null;
    img = tconv.convert(ref, type);
  }

  // NB: This unmanages the image.
  final DataBufferInt db = (DataBufferInt) img.getRaster().getDataBuffer();
  final int[] data = db.getData();

  for (int i = 0; i < data.length; ++i) {
    final int y  =  (data[i] >> 16) & 0xFF;
    final int pb = ((data[i] >>  8) & 0xFF) - 128;
    final int pr = ( data[i]        & 0xFF) - 128;

    final int a  = (data[i] >> 24) & 0xFF;
    final int r = (int) Math.round(y + 1.402*pr);
    final int g = (int) Math.round(y - 0.34414*pb - 0.71414*pr);
    final int b = (int) Math.round(y + 1.772*pb);

    data[i] = (a << 24) |
              ((r < 0 ? 0 : (r > 0xFF ? 0xFF : r)) << 16) |
              ((g < 0 ? 0 : (g > 0xFF ? 0xFF : g)) <<  8) |
               (b < 0 ? 0 : (b > 0xFF ? 0xFF : b));
  }

  return img;
}
 
開發者ID:ajmath,項目名稱:VASSAL-src,代碼行數:40,代碼來源:ImageIOImageLoader.java

示例5: getRaster

import java.awt.image.DataBufferInt; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
public final Raster getRaster(int x, int y, int w, int h) {
    // If working raster is big enough, reuse it. Otherwise,
    // build a large enough new one.
    Raster raster = saved;
    if (raster == null ||
        raster.getWidth() < w || raster.getHeight() < h)
    {
        raster = getCachedRaster(model, w, h);
        saved = raster;
    }

    // Access raster internal int array. Because we use a DirectColorModel,
    // we know the DataBuffer is of type DataBufferInt and the SampleModel
    // is SinglePixelPackedSampleModel.
    // Adjust for initial offset in DataBuffer and also for the scanline
    // stride.
    // These calls make the DataBuffer non-acceleratable, but the
    // Raster is never Stable long enough to accelerate anyway...
    DataBufferInt rasterDB = (DataBufferInt)raster.getDataBuffer();
    int[] pixels = rasterDB.getData(0);
    int off = rasterDB.getOffset();
    int scanlineStride = ((SinglePixelPackedSampleModel)
                          raster.getSampleModel()).getScanlineStride();
    int adjust = scanlineStride - w;

    fillRaster(pixels, off, adjust, x, y, w, h); // delegate to subclass

    return raster;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:33,代碼來源:MultipleGradientPaintContext.java

示例6: regenerate

import java.awt.image.DataBufferInt; //導入方法依賴的package包/類
public void regenerate(final boolean antialiasing, final BufferedImage imgout, final CLEditor editor) {
  //   try {
         if (isKernelOk()) {

             final int w = imageOutWidth,
                       h = imageOutHeight;

             long t0 = System.nanoTime();
             
             CL.clFinish(commandQueue);
             editor.updateKernelArgsRenderingMode(antialiasing);
             
             cl_event events[] = new cl_event[1];
             events[0] = new cl_event();
             CL.clEnqueueNDRangeKernel(commandQueue, kernel, 2, null, new long[]{w, h}, null, 0, null, events[0]);

             CL.clWaitForEvents(1, events);
             
             // Read the pixel data into the output image
             DataBufferInt dataBufferDst = (DataBufferInt)imgout.getRaster().getDataBuffer();
             int dataDst[] = dataBufferDst.getData();

             CL.clEnqueueReadImage(
                 commandQueue, imageOut, true, new long[3], new long[]{w,h,1},
                 w * Sizeof.cl_uint, 0, Pointer.to(dataDst), 0, null, null);

             long dt = System.nanoTime() - t0;
             System.out.println("Image (" + w + "x" + h + ") generated in " + (dt / 1000000) + "ms");
         }
//     } catch (CLException e) {
 //        int ff = 0;
 //    }
 }
 
開發者ID:iapafoto,項目名稱:DicomViewer,代碼行數:34,代碼來源:OpenCLWithJOCL.java

示例7: doGetDataFrom

import java.awt.image.DataBufferInt; //導入方法依賴的package包/類
private static int[] doGetDataFrom(final BufferedImage bufferedImage) {
	final WritableRaster writableRaster = bufferedImage.getRaster();
	
	final DataBuffer dataBuffer = writableRaster.getDataBuffer();
	
	final DataBufferInt dataBufferInt = DataBufferInt.class.cast(dataBuffer);
	
	final int[] data = dataBufferInt.getData();
	
	return data;
}
 
開發者ID:macroing,項目名稱:Dayflower-Path-Tracer,代碼行數:12,代碼來源:ImageTexture.java


注:本文中的java.awt.image.DataBufferInt.getData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。