當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。