当前位置: 首页>>代码示例>>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;未经允许,请勿转载。