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


Java DataBufferUShort类代码示例

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


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

示例1: readTileXY

import java.awt.image.DataBufferUShort; //导入依赖的package包/类
/**
* 
* @param x
* @param y
* @param width
* @param height
* @param band
* @return
*/
 public int readTileXY(int x, int y, int band) {
     Rectangle rect = new Rectangle(x, y, 1, 1);
     int val=0;

     	if (y < 0||y>this.getHeight()||x<0||x>this.getWidth()) {
           val= 0;
     	}else{
        TIFF tiff=(TIFF)getImage(band);
        try {
        	BufferedImage bi=null;
       		bi=tiff.read(0, rect);
       		DataBufferUShort raster=(DataBufferUShort)bi.getRaster().getDataBuffer();
       		short[] b=raster.getData();
        	//short[] data=(short[])raster.getDataElements(0, 0, width,height, null);
        	val=b[0];
        } catch (Exception ex) {
            logger.error(ex.getMessage(),ex);
        }
     	}  
     
     return val;
 }
 
开发者ID:ec-europa,项目名称:sumo,代码行数:32,代码来源:Sentinel1GRD.java

示例2: read

import java.awt.image.DataBufferUShort; //导入依赖的package包/类
/**
*
* @param x
* @param y
* @param width
* @param height
* @param band
* @return
*/
public int[] read(int x, int y,int w,int h, int band) {
 TIFF tiff=(TIFF)getImage(band);
    Rectangle rect = new Rectangle(x, y, w, h);
    rect = rect.intersection(tiff.getBounds());
    int data[]=null;

     try {
      	BufferedImage bi=null;
  		bi=tiff.read(0, rect);
  		DataBufferUShort raster=(DataBufferUShort)bi.getRaster().getDataBuffer();
  		short[] b=raster.getData();
  		data=new int[b.length];
      	for(int i=0;i<b.length;i++)
      		data[i]=b[i];

     } catch (Exception ex) {
         logger.warn(ex.getMessage());
     }

    return data;
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:31,代码来源:Alos.java

示例3: read

import java.awt.image.DataBufferUShort; //导入依赖的package包/类
/**
*
* @param x
* @param y
* @param width
* @param height
* @param band
* @return
*/
public int[] read(int x, int y,int w,int h, int band) {
    Rectangle rect = new Rectangle(x, y, w, h);
    rect = rect.intersection(getImage(band).getBounds());
    int data[]=null;

     TIFF tiff=getImage(band);
     try {
     	BufferedImage bi=null;
 		bi=tiff.read(0, rect);
 		DataBufferUShort raster=(DataBufferUShort)bi.getRaster().getDataBuffer();
 		short[] b=raster.getData();
 		data=new int[b.length];
     	for(int i=0;i<b.length;i++)
     		data[i]=b[i];

     } catch (Exception ex) {
         logger.warn(ex.getMessage());
     }finally{
     }

    return data;
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:32,代码来源:AlosGeoTiff.java

示例4: createBuffer

import java.awt.image.DataBufferUShort; //导入依赖的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

示例5: createBufferFromData

import java.awt.image.DataBufferUShort; //导入依赖的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

示例6: createBuffer

import java.awt.image.DataBufferUShort; //导入依赖的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

示例7: createBufferFromData

import java.awt.image.DataBufferUShort; //导入依赖的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

示例8: getData

import java.awt.image.DataBufferUShort; //导入依赖的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

示例9: getData

import java.awt.image.DataBufferUShort; //导入依赖的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

示例10: setUp

import java.awt.image.DataBufferUShort; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp();
    dbb1 = new DataBufferByte(w * h);
    dbb2 = new DataBufferByte(scanlineStride * (h - 1) + w);
    dbu1 = new DataBufferUShort(w * h);
    dbu2 = new DataBufferUShort(scanlineStride * (h - 1) + w);
    dbi1 = new DataBufferInt(w * h);
    dbi2 = new DataBufferInt(scanlineStride * (h - 1) + w);
    sppsmb1 = new SinglePixelPackedSampleModel(DataBuffer.TYPE_BYTE, w, h, bitMaskB);
    sppsmb2 = new SinglePixelPackedSampleModel(DataBuffer.TYPE_BYTE, w, h, scanlineStride, bitMaskB);
    sppsmu1 = new SinglePixelPackedSampleModel(DataBuffer.TYPE_USHORT, w, h, bitMaskUS);
    sppsmu2 = new SinglePixelPackedSampleModel(DataBuffer.TYPE_USHORT, w, h, scanlineStride, bitMaskUS);
    sppsmi1 = new SinglePixelPackedSampleModel(DataBuffer.TYPE_INT, w, h, bitMaskI);
    sppsmi2 = new SinglePixelPackedSampleModel(DataBuffer.TYPE_INT, w, h, scanlineStride, bitMaskI);
    initTestData();
}
 
开发者ID:shannah,项目名称:cn1,代码行数:18,代码来源:SinglePixelPackedSampleModelTest.java

示例11: setUp

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

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

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

示例12: getShorts

import java.awt.image.DataBufferUShort; //导入依赖的package包/类
/** Extracts pixel data as arrays of unsigned shorts, one per channel. */
public static short[][] getShorts(final WritableRaster r, final int x,
	final int y, final int w, final int h)
{
	if (canUseBankDataDirectly(r, DataBuffer.TYPE_USHORT,
		DataBufferUShort.class) &&
		x == 0 && y == 0 && w == r.getWidth() && h == r.getHeight())
	{
		return ((DataBufferUShort) r.getDataBuffer()).getBankData();
	}
	final int c = r.getNumBands();
	final short[][] samples = new short[c][w * h];
	final int[] buf = new int[w * h];
	for (int i = 0; i < c; i++) {
		r.getSamples(x, y, w, h, i, buf);
		for (int j = 0; j < buf.length; j++)
			samples[i][j] = (short) buf[j];
	}
	return samples;
}
 
开发者ID:scifio,项目名称:scifio,代码行数:21,代码来源:AWTImageTools.java

示例13: clone

import java.awt.image.DataBufferUShort; //导入依赖的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: convert

import java.awt.image.DataBufferUShort; //导入依赖的package包/类
@Override
public DataBuffer convert(FieldAccessor fa, Instance instance) throws FieldAccessor.InvalidFieldException {
    int size = fa.getInt(instance, "size");                        // NOI18N
    int[] offsets = fa.getIntArray(instance, "offsets", false);      // NOI18N
    short[][] bankdata = fa.getShortArray2(instance, "bankdata", false); // NOI18N
    return new DataBufferUShort(bankdata, size, offsets);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:ImageBuilder.java

示例15: read

import java.awt.image.DataBufferUShort; //导入依赖的package包/类
/**
*
* @param x
* @param y
* @param width
* @param height
* @param band
* @return
*/
public int[] read(int x, int y,int w,int h, int band) {
    Rectangle rect = new Rectangle(x, y, w, h);
    rect = rect.intersection(getImage(band).getBounds());
    int data[]=null;

     TIFF tiff=(TIFF)getImage(band);
     BufferedImage bi=null;
     try {
     	bi=tiff.read(0, rect);
     } catch (Exception ex) {
     	try {
     		//try again
     		Thread.sleep(100);
	bi=tiff.read(0, rect);
} catch (IOException | InterruptedException e) {
	logger.warn(ex.getMessage());
}
     }finally{
     }
     if(bi!=null){
DataBufferUShort raster=(DataBufferUShort)bi.getRaster().getDataBuffer();
short[] b=raster.getData();
data=new int[b.length];
  	for(int i=0;i<b.length;i++)
  		data[i]=b[i];
     }
    return data;
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:38,代码来源:Sentinel1.java


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