当前位置: 首页>>代码示例>>Java>>正文


Java DataBufferFloat类代码示例

本文整理汇总了Java中java.awt.image.DataBufferFloat的典型用法代码示例。如果您正苦于以下问题:Java DataBufferFloat类的具体用法?Java DataBufferFloat怎么用?Java DataBufferFloat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DataBufferFloat类属于java.awt.image包,在下文中一共展示了DataBufferFloat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createBuffer

import java.awt.image.DataBufferFloat; //导入依赖的package包/类
/**
  * Create a data buffer of a particular type.
  *
  * @param dataType the desired data type of the buffer.
  * @param size the size of the data buffer bank
  * @param numBanks the number of banks the buffer should have
  */
 public static DataBuffer createBuffer(int dataType, int size, int numBanks)
 {
   switch (dataType)
     {
     case DataBuffer.TYPE_BYTE:
return new DataBufferByte(size, numBanks);
     case DataBuffer.TYPE_SHORT:
return new DataBufferShort(size, numBanks);
     case DataBuffer.TYPE_USHORT:
return new DataBufferUShort(size, numBanks);
     case DataBuffer.TYPE_INT:
return new DataBufferInt(size, numBanks);
     case DataBuffer.TYPE_FLOAT:
return new DataBufferFloat(size, numBanks);
     case DataBuffer.TYPE_DOUBLE:
return new DataBufferDouble(size, numBanks);
     default:
throw new UnsupportedOperationException();
     }
 }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:28,代码来源:Buffers.java

示例2: createBufferFromData

import java.awt.image.DataBufferFloat; //导入依赖的package包/类
/**
  * Create a data buffer of a particular type.
  *
  * @param dataType the desired data type of the buffer
  * @param data an array containing the data
  * @param size the size of the data buffer bank
  */
 public static DataBuffer createBufferFromData(int dataType, Object data,
					int size)
 {
   switch (dataType)
     {
     case DataBuffer.TYPE_BYTE:
return new DataBufferByte((byte[]) data, size);
     case DataBuffer.TYPE_SHORT:
return new DataBufferShort((short[]) data, size);
     case DataBuffer.TYPE_USHORT:
return new DataBufferUShort((short[]) data, size);
     case DataBuffer.TYPE_INT:
return new DataBufferInt((int[]) data, size);
     case DataBuffer.TYPE_FLOAT:
return new DataBufferFloat((float[]) data, size);
     case DataBuffer.TYPE_DOUBLE:
return new DataBufferDouble((double[]) data, size);
     default:
throw new UnsupportedOperationException();
     }
 }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:29,代码来源:Buffers.java

示例3: createFloatBufferedImage

import java.awt.image.DataBufferFloat; //导入依赖的package包/类
BufferedImage createFloatBufferedImage(int w, int h, int bands) {
    // Define dimensions and layout of the image
    //int bands = 4; // 4 bands for ARGB, 3 for RGB etc
    int[] bandOffsets = {0, 1, 2, 3}; // length == bands, 0 == R, 1 == G, 2 == B and 3 == A

    // Create a TYPE_FLOAT sample model (specifying how the pixels are stored)
    SampleModel sampleModel = new PixelInterleavedSampleModel(DataBuffer.TYPE_FLOAT, w, h, bands, w  * bands, bandOffsets);
    // ...and data buffer (where the pixels are stored)
    DataBuffer buffer = new DataBufferFloat(w * h * bands);

    // Wrap it in a writable raster
    WritableRaster raster = Raster.createWritableRaster(sampleModel, buffer, null);

    // Create a color model compatible with this sample model/raster (TYPE_FLOAT)
    // Note that the number of bands must equal the number of color components in the 
    // color space (3 for RGB) + 1 extra band if the color model contains alpha 
    ColorSpace colorSpace = ColorSpace.getInstance(ColorSpace.CS_sRGB);
    ColorModel colorModel = new ComponentColorModel(colorSpace, true, false, Transparency.TRANSLUCENT, DataBuffer.TYPE_FLOAT);

    // And finally create an image with this raster
    return new BufferedImage(colorModel, raster, colorModel.isAlphaPremultiplied(), null);
}
 
开发者ID:iapafoto,项目名称:DicomViewer,代码行数:23,代码来源:OpenCLWithJOCL.java

示例4: createBuffer

import java.awt.image.DataBufferFloat; //导入依赖的package包/类
/**
 * Create a data buffer of a particular type.
 *
 * @param dataType the desired data type of the buffer.
 * @param size the size of the data buffer bank
 * @param numBanks the number of banks the buffer should have
 */
public static DataBuffer createBuffer(int dataType, int size, int numBanks)
{
  switch (dataType)
    {
    case DataBuffer.TYPE_BYTE:
      return new DataBufferByte(size, numBanks);
    case DataBuffer.TYPE_SHORT:
      return new DataBufferShort(size, numBanks);
    case DataBuffer.TYPE_USHORT:
      return new DataBufferUShort(size, numBanks);
    case DataBuffer.TYPE_INT:
      return new DataBufferInt(size, numBanks);
    case DataBuffer.TYPE_FLOAT:
      return new DataBufferFloat(size, numBanks);
    case DataBuffer.TYPE_DOUBLE:
      return new DataBufferDouble(size, numBanks);
    default:
      throw new UnsupportedOperationException();
    }
}
 
开发者ID:vilie,项目名称:javify,代码行数:28,代码来源:Buffers.java

示例5: createBufferFromData

import java.awt.image.DataBufferFloat; //导入依赖的package包/类
/**
 * Create a data buffer of a particular type.
 *
 * @param dataType the desired data type of the buffer
 * @param data an array containing the data
 * @param size the size of the data buffer bank
 */
public static DataBuffer createBufferFromData(int dataType, Object data,
                                              int size)
{
  switch (dataType)
    {
    case DataBuffer.TYPE_BYTE:
      return new DataBufferByte((byte[]) data, size);
    case DataBuffer.TYPE_SHORT:
      return new DataBufferShort((short[]) data, size);
    case DataBuffer.TYPE_USHORT:
      return new DataBufferUShort((short[]) data, size);
    case DataBuffer.TYPE_INT:
      return new DataBufferInt((int[]) data, size);
    case DataBuffer.TYPE_FLOAT:
      return new DataBufferFloat((float[]) data, size);
    case DataBuffer.TYPE_DOUBLE:
      return new DataBufferDouble((double[]) data, size);
    default:
      throw new UnsupportedOperationException();
    }
}
 
开发者ID:vilie,项目名称:javify,代码行数:29,代码来源:Buffers.java

示例6: createFloatPlanarImage

import java.awt.image.DataBufferFloat; //导入依赖的package包/类
public static PlanarImage createFloatPlanarImage(float[] src, int width, int height){
    int[] bandOffsets = {0};

    SampleModel sampleModel = new PixelInterleavedSampleModel(TYPE_FLOAT, width, height, 1, width, bandOffsets);
    ColorSpace colorSpace = ColorSpace.getInstance(ColorSpace.CS_GRAY);
    ColorModel colorModel = new ComponentColorModel(colorSpace, false, false, Transparency.TRANSLUCENT, TYPE_FLOAT);
    PlanarImage opImage;
    DataBuffer buffer = new DataBufferFloat(width * height);

    // Wrap it in a writable raster
    WritableRaster raster = Raster.createWritableRaster(sampleModel, buffer, null);
    raster.setPixels(0, 0, width, height, src);

    // Create an image with this raster
    BufferedImage image = new BufferedImage(colorModel, raster, colorModel.isAlphaPremultiplied(), null);
    opImage = PlanarImage.wrapRenderedImage(image);
    return opImage;
}
 
开发者ID:senbox-org,项目名称:s2tbx,代码行数:19,代码来源:S2ResamplerUtils.java

示例7: getData

import java.awt.image.DataBufferFloat; //导入依赖的package包/类
public static Object getData(final DataBuffer db) {
	if (db instanceof DataBufferByte) {
		return ((DataBufferByte) db).getData();
	} else if (db instanceof DataBufferUShort) {
		return ((DataBufferUShort) db).getData();
	} else if (db instanceof DataBufferShort) {
		return ((DataBufferShort) db).getData();
	} else if (db instanceof DataBufferInt) {
		return ((DataBufferInt) db).getData();
	} else if (db instanceof DataBufferFloat) {
		return ((DataBufferFloat) db).getData();
	} else if (db instanceof DataBufferDouble) {
		return ((DataBufferDouble) db).getData();
	} else {
		throw new RuntimeException("Not found DataBuffer class !");
	}
}
 
开发者ID:cping,项目名称:RipplePower,代码行数:18,代码来源:GraphicsUtils.java

示例8: getData

import java.awt.image.DataBufferFloat; //导入依赖的package包/类
@Override
public Object getData(DataBuffer db) {
    if (db instanceof DataBufferByte){
        return ((DataBufferByte)db).getData();
    } else if (db instanceof DataBufferUShort){
        return ((DataBufferUShort)db).getData();
    } else if (db instanceof DataBufferShort){
        return ((DataBufferShort)db).getData();
    } else if (db instanceof DataBufferInt){
        return ((DataBufferInt)db).getData();
    } else if (db instanceof DataBufferFloat){
        return ((DataBufferFloat)db).getData();
    } else if (db instanceof DataBufferDouble){
        return ((DataBufferDouble)db).getData();
    } else {
        // awt.235=Wrong Data Buffer type : {0}
        throw new IllegalArgumentException(Messages.getString("awt.235", //$NON-NLS-1$
                db.getClass()));
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:21,代码来源:AwtImageBackdoorAccessorImpl.java

示例9: setUp

import java.awt.image.DataBufferFloat; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp();
    float dataArrays[][] = new float[numBanks][];
    for(int i = 0; i < numBanks; i++){
        dataArrays[i] = new float[arraySize];
    }

    float dataArray[] = new float[arraySize];
    int offsets[] = new int[numBanks];
    for(int i = 0; i < numBanks; i++){
        offsets[i] = i;
    }

    db1 = new DataBufferFloat(dataArrays, size);
    db2 = new DataBufferFloat(dataArrays, size, offsets);
    db3 = new DataBufferFloat(dataArray, size);
    db4 = new DataBufferFloat(dataArray, size, numBanks);
    db5 = new DataBufferFloat(size);
    db6 = new DataBufferFloat(size, numBanks);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:22,代码来源:DataBufferFloatTest.java

示例10: test_from_BuffImg_to_FloatDataBuffer

import java.awt.image.DataBufferFloat; //导入依赖的package包/类
public final void test_from_BuffImg_to_FloatDataBuffer(){
    src = createImage(BufferedImage.TYPE_INT_RGB);

    DataBufferFloat dbf = new DataBufferFloat(w * h * 3);
    int offsets[] = new int[]{0,1,2};
    ComponentSampleModel csm = new ComponentSampleModel(DataBuffer.TYPE_FLOAT,
            w, h, 3, 3 * w, offsets);
    WritableRaster wr = new OrdinaryWritableRaster(csm, dbf, new Point(0, 0));
    ColorModel cm = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB), false, false, Transparency.OPAQUE, DataBuffer.TYPE_FLOAT);
    BufferedImage dst = new BufferedImage(cm, wr, cm.isAlphaPremultiplied(), null);
    Graphics2D g2d = dst.createGraphics();
    g2d.drawImage(src, 0, 0, null);

    for(int y = 0; y < h; y++){
        for(int x = 0; x < w; x++){
            assertEquals(src.getRGB(x, y), dst.getRGB(x, y));
        }
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:20,代码来源:JavaBlitterTest.java

示例11: getFloats

import java.awt.image.DataBufferFloat; //导入依赖的package包/类
/** Extracts pixel data as arrays of floats, one per channel. */
public static float[][] getFloats(final WritableRaster r, final int x,
	final int y, final int w, final int h)
{
	if (canUseBankDataDirectly(r, DataBuffer.TYPE_FLOAT, DataBufferFloat.class) &&
		x == 0 && y == 0 && w == r.getWidth() && h == r.getHeight())
	{
		return ((DataBufferFloat) r.getDataBuffer()).getBankData();
	}
	// NB: an order of magnitude faster than the naive makeType solution
	final int c = r.getNumBands();
	final float[][] samples = new float[c][w * h];
	for (int i = 0; i < c; i++)
		r.getSamples(x, y, w, h, i, samples[i]);
	return samples;
}
 
开发者ID:scifio,项目名称:scifio,代码行数:17,代码来源:AWTImageTools.java

示例12: getBufferedImage

import java.awt.image.DataBufferFloat; //导入依赖的package包/类
@Override
public BufferedImage getBufferedImage(final ByteSource byteSource, final Map<String, Object> params)
        throws ImageReadException, IOException {
    try (RgbeInfo info = new RgbeInfo(byteSource)) {
        // It is necessary to create our own BufferedImage here as the
        // org.apache.commons.imaging.common.IBufferedImageFactory interface does
        // not expose this complexity
        final DataBuffer buffer = new DataBufferFloat(info.getPixelData(),
                info.getWidth() * info.getHeight());

        final BufferedImage ret = new BufferedImage(new ComponentColorModel(
                ColorSpace.getInstance(ColorSpace.CS_sRGB), false, false,
                Transparency.OPAQUE, buffer.getDataType()),
                Raster.createWritableRaster(
                        new BandedSampleModel(buffer.getDataType(),
                                info.getWidth(), info.getHeight(), 3),
                        buffer,
                        new Point()), false, null);
        return ret;
    }
}
 
开发者ID:apache,项目名称:commons-imaging,代码行数:22,代码来源:RgbeImageParser.java

示例13: clone

import java.awt.image.DataBufferFloat; //导入依赖的package包/类
public static DataBuffer clone(DataBuffer dataBuffer) {
    if (dataBuffer instanceof DataBufferByte) {
        return clone((DataBufferByte) dataBuffer);
    } else if (dataBuffer instanceof DataBufferDouble) {
        return clone((DataBufferDouble) dataBuffer);
    } else if (dataBuffer instanceof DataBufferFloat) {
        return clone((DataBufferFloat) dataBuffer);
    } else if (dataBuffer instanceof DataBufferInt) {
        return clone((DataBufferInt) dataBuffer);
    } else if (dataBuffer instanceof DataBufferShort) {
        return clone((DataBufferShort) dataBuffer);
    } else if (dataBuffer instanceof DataBufferUShort) {
        return clone((DataBufferUShort) dataBuffer);
    } else {
        throw new UnsupportedOperationException("Don't know how to clone " + dataBuffer.getClass().getName());
    }
}
 
开发者ID:Captain-Chaos,项目名称:WorldPainter,代码行数:18,代码来源:ObjectUtils.java

示例14: getDataFloat

import java.awt.image.DataBufferFloat; //导入依赖的package包/类
@Override
public float[] getDataFloat(DataBuffer db) {
    if (db instanceof DataBufferFloat){
        return ((DataBufferFloat)db).getData();
    }
    return null;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:8,代码来源:AwtImageBackdoorAccessorImpl.java

示例15: setupLazyCustomConversion

import java.awt.image.DataBufferFloat; //导入依赖的package包/类
private void setupLazyCustomConversion(final BufferedImage image) {
    imageForLazyCustomConversion = image;
    final boolean hasAlpha = image.getColorModel().hasAlpha();
    int pixelFormat = pixelAttributes.format;
    int pixelType = pixelAttributes.type;
    if (pixelFormat == 0) {
        pixelFormat = hasAlpha ? GL.GL_RGBA : GL.GL_RGB;
    }
    alignment = 1; // FIXME: do we need better?
    rowLength = width; // FIXME: correct in all cases?

    // Allow previously-selected pixelType (if any) to override that
    // we can infer from the DataBuffer
    final DataBuffer data = image.getRaster().getDataBuffer();
    if (data instanceof DataBufferByte || isPackedInt(image)) {
        // Don't use GL_UNSIGNED_INT for BufferedImage packed int images
        if (pixelType == 0) pixelType = GL.GL_UNSIGNED_BYTE;
    } else if (data instanceof DataBufferDouble) {
        throw new RuntimeException("DataBufferDouble rasters not supported by OpenGL");
    } else if (data instanceof DataBufferFloat) {
        if (pixelType == 0) pixelType = GL.GL_FLOAT;
    } else if (data instanceof DataBufferInt) {
        // FIXME: should we support signed ints?
        if (pixelType == 0) pixelType = GL.GL_UNSIGNED_INT;
    } else if (data instanceof DataBufferShort) {
        if (pixelType == 0) pixelType = GL.GL_SHORT;
    } else if (data instanceof DataBufferUShort) {
        if (pixelType == 0) pixelType = GL.GL_UNSIGNED_SHORT;
    } else {
        throw new RuntimeException("Unexpected DataBuffer type?");
    }
    pixelAttributes = new GLPixelAttributes(pixelFormat, pixelType);
}
 
开发者ID:jedwards1211,项目名称:breakout,代码行数:34,代码来源:AWTTextureData.java


注:本文中的java.awt.image.DataBufferFloat类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。