本文整理汇总了Java中javax.media.jai.PixelAccessor.setPackedPixels方法的典型用法代码示例。如果您正苦于以下问题:Java PixelAccessor.setPackedPixels方法的具体用法?Java PixelAccessor.setPackedPixels怎么用?Java PixelAccessor.setPackedPixels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.media.jai.PixelAccessor
的用法示例。
在下文中一共展示了PixelAccessor.setPackedPixels方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: floatLoop
import javax.media.jai.PixelAccessor; //导入方法依赖的package包/类
private void floatLoop(Raster source,
WritableRaster dest,
Rectangle destRect){
Rectangle srcRect = mapDestRect(destRect,0); // should be identical to destRect
PixelAccessor pa = new PixelAccessor(dest.getSampleModel(), null);
PackedImageData pid = pa.getPackedPixels(dest, destRect, true, false);
int offset = pid.offset;
PixelAccessor srcPa = new PixelAccessor(source.getSampleModel(), null);
UnpackedImageData srcImD = srcPa.getPixels(source, srcRect, DataBuffer.TYPE_FLOAT, false);
int srcOffset = srcImD.bandOffsets[0];
float[] srcData = ((float[][])srcImD.data)[0];
int pixelStride= srcImD.pixelStride;
int ind0 = pid.bitOffset;
for(int h = 0; h < destRect.height; h++){
int indE = ind0 + destRect.width;
for(int b = ind0, s = srcOffset; b < indE; b++, s += pixelStride){
if (srcData[s]>threshold) {
pid.data[offset + (b >> 3)] |= byteTable[b%8];
}
}
offset += pid.lineStride;
srcOffset += srcImD.lineStride;
}
pa.setPackedPixels(pid);
}
示例2: doubleLoop
import javax.media.jai.PixelAccessor; //导入方法依赖的package包/类
private void doubleLoop(Raster source,
WritableRaster dest,
Rectangle destRect){
Rectangle srcRect = mapDestRect(destRect,0); // should be identical to destRect
PixelAccessor pa = new PixelAccessor(dest.getSampleModel(), null);
PackedImageData pid = pa.getPackedPixels(dest, destRect, true, false);
int offset = pid.offset;
PixelAccessor srcPa = new PixelAccessor(source.getSampleModel(), null);
UnpackedImageData srcImD = srcPa.getPixels(source, srcRect, DataBuffer.TYPE_DOUBLE, false);
int srcOffset = srcImD.bandOffsets[0];
double[] srcData = ((double[][])srcImD.data)[0];
int pixelStride= srcImD.pixelStride;
int ind0 = pid.bitOffset;
for(int h = 0; h < destRect.height; h++){
int indE = ind0 + destRect.width;
for(int b = ind0, s = srcOffset; b < indE; b++, s += pixelStride){
if (srcData[s]>threshold) {
pid.data[offset + (b >> 3)] |= byteTable[b%8];
}
}
offset += pid.lineStride;
srcOffset += srcImD.lineStride;
}
pa.setPackedPixels(pid);
}
示例3: setTo1
import javax.media.jai.PixelAccessor; //导入方法依赖的package包/类
private void setTo1(Raster dest, Rectangle destRect){
initBitsOn();
PixelAccessor pa = new PixelAccessor(dest.getSampleModel(), null);
PackedImageData pid = pa.getPackedPixels(dest, destRect, true, false);
int offset = pid.offset;
for(int h = 0; h < destRect.height; h++){
int ind0 = pid.bitOffset;
int indE = ind0 + destRect.width - 1;
if (indE < 8){
// the entire row in data[offset]
pid.data[offset] = (byte)(pid.data[offset] | bitsOn[indE]); // (0<<3) + indE
}else{
//1st byte
pid.data[offset] = (byte)(pid.data[offset] | bitsOn[7]); // (0<<3) + 7
//middle bytes
for(int b = offset + 1; b <= offset + (indE-7)/8; b++){
pid.data[b] = (byte)(0xff);
}
//last byte
int remBits = indE % 8;
if(remBits % 8 != 7){
indE = offset + indE/8;
pid.data[indE] = (byte)(pid.data[indE] | bitsOn[remBits]); // (0<<3)+remBits
}
}
offset += pid.lineStride;
}
pa.setPackedPixels(pid);
}
示例4: byteLoop
import javax.media.jai.PixelAccessor; //导入方法依赖的package包/类
private void byteLoop(Raster source,
WritableRaster dest,
Rectangle destRect){
if(threshold <= 0.0D){
// every bit is 1
setTo1(dest, destRect);
return;
}else if (threshold > 255.0D){
//every bit is zeros;
return;
}
short thresholdI = (short)Math.ceil(threshold);
// computation can be done in integer
// even though threshold is of double type
// int thresholdI = (int)Math.ceil(this.threshold);
// or through a lookup table for byte case
Rectangle srcRect = mapDestRect(destRect,0); // should be identical to destRect
PixelAccessor pa = new PixelAccessor(dest.getSampleModel(), null);
PackedImageData pid = pa.getPackedPixels(dest, destRect, true, false);
int offset = pid.offset;
PixelAccessor srcPa = new PixelAccessor(source.getSampleModel(), null);
UnpackedImageData srcImD = srcPa.getPixels(source, srcRect, DataBuffer.TYPE_BYTE, false);
int srcOffset = srcImD.bandOffsets[0];
byte[] srcData = ((byte[][])srcImD.data)[0];
int pixelStride= srcImD.pixelStride;
int ind0 = pid.bitOffset;
for(int h = 0; h < destRect.height; h++){
int indE = ind0 + destRect.width;
for(int b = ind0, s = srcOffset; b < indE; b++, s += pixelStride){
if((srcData[s]&0xFF) >= thresholdI) {
pid.data[offset + (b >> 3)] |= byteTable[b%8];
}
}
offset += pid.lineStride;
srcOffset += srcImD.lineStride;
}
pa.setPackedPixels(pid);
}
示例5: shortLoop
import javax.media.jai.PixelAccessor; //导入方法依赖的package包/类
private void shortLoop(Raster source,
WritableRaster dest,
Rectangle destRect){
if(threshold <= Short.MIN_VALUE){
// every bit is 1
setTo1(dest, destRect);
return;
}else if (threshold > Short.MAX_VALUE){
//every bit is zeros;
return;
}
short thresholdS = (short)( Math.ceil(threshold));
// computation can be done in integer
// even though threshold is of double type
// int thresholdI = (int)Math.ceil(this.threshold);
// or through a lookup table for byte case
Rectangle srcRect = mapDestRect(destRect,0); // should be identical to destRect
PixelAccessor pa = new PixelAccessor(dest.getSampleModel(), null);
PackedImageData pid = pa.getPackedPixels(dest, destRect, true, false);
int offset = pid.offset;
PixelAccessor srcPa = new PixelAccessor(source.getSampleModel(), null);
UnpackedImageData srcImD = srcPa.getPixels(source, srcRect, DataBuffer.TYPE_SHORT, false);
int srcOffset = srcImD.bandOffsets[0];
short[] srcData = ((short[][])srcImD.data)[0];
int pixelStride= srcImD.pixelStride;
int ind0 = pid.bitOffset;
for(int h = 0; h < destRect.height; h++){
int indE = ind0 + destRect.width;
for(int b = ind0, s = srcOffset; b < indE; b++, s += pixelStride){
if(srcData[s] >= thresholdS) {
pid.data[offset + (b >> 3)] |= byteTable[b%8];
}
}
offset += pid.lineStride;
srcOffset += srcImD.lineStride;
}
pa.setPackedPixels(pid);
}
示例6: ushortLoop
import javax.media.jai.PixelAccessor; //导入方法依赖的package包/类
private void ushortLoop(Raster source,
WritableRaster dest,
Rectangle destRect){
if(threshold <= 0.0D){
// every bit is 1
setTo1(dest, destRect);
return;
}else if (threshold > (double)(0xFFFF)){
//every bit is zeros;
return;
}
int thresholdI = (int)( Math.ceil(threshold));
// computation can be done in integer
// even though threshold is of double type
// int thresholdI = (int)Math.ceil(this.threshold);
// or through a lookup table for byte case
Rectangle srcRect = mapDestRect(destRect,0); // should be identical to destRect
PixelAccessor pa = new PixelAccessor(dest.getSampleModel(), null);
PackedImageData pid = pa.getPackedPixels(dest, destRect, true, false);
int offset = pid.offset;
PixelAccessor srcPa = new PixelAccessor(source.getSampleModel(), null);
UnpackedImageData srcImD = srcPa.getPixels(source, srcRect, DataBuffer.TYPE_USHORT, false);
int srcOffset = srcImD.bandOffsets[0];
short[] srcData = ((short[][])srcImD.data)[0];
int pixelStride= srcImD.pixelStride;
int ind0 = pid.bitOffset;
for(int h = 0; h < destRect.height; h++){
int indE = ind0 + destRect.width;
for(int b = ind0, s = srcOffset; b < indE; b++, s += pixelStride){
if((srcData[s]&0xFFFF) >= thresholdI) {
pid.data[offset + (b >> 3)] |= byteTable[b%8];
}
}
offset += pid.lineStride;
srcOffset += srcImD.lineStride;
}
pa.setPackedPixels(pid);
}
示例7: intLoop
import javax.media.jai.PixelAccessor; //导入方法依赖的package包/类
private void intLoop(Raster source,
WritableRaster dest,
Rectangle destRect){
if(threshold <= Integer.MIN_VALUE){
// every bit is 1
setTo1(dest, destRect);
return;
}else if (threshold > (double)Integer.MAX_VALUE){
//every bit is zeros;
return;
}
// computation can be done in integer
// even though threshold is of double type
int thresholdI = (int)Math.ceil(this.threshold);
// computation can be done in integer
// even though threshold is of double type
// int thresholdI = (int)Math.ceil(this.threshold);
Rectangle srcRect = mapDestRect(destRect,0); // should be identical to destRect
PixelAccessor pa = new PixelAccessor(dest.getSampleModel(), null);
PackedImageData pid = pa.getPackedPixels(dest, destRect, true, false);
int offset = pid.offset;
PixelAccessor srcPa = new PixelAccessor(source.getSampleModel(), null);
UnpackedImageData srcImD = srcPa.getPixels(source, srcRect, DataBuffer.TYPE_INT, false);
int srcOffset = srcImD.bandOffsets[0];
int[] srcData = ((int[][])srcImD.data)[0];
int pixelStride= srcImD.pixelStride;
int ind0 = pid.bitOffset;
for(int h = 0; h < destRect.height; h++){
int indE = ind0 + destRect.width;
for(int b = ind0, s = srcOffset; b < indE; b++, s += pixelStride){
if(srcData[s] >= threshold) {
pid.data[offset + (b >> 3)] |= byteTable[b%8];
}
}
offset += pid.lineStride;
srcOffset += srcImD.lineStride;
}
pa.setPackedPixels(pid);
}