本文整理汇总了Java中java.awt.image.WritableRaster.setSample方法的典型用法代码示例。如果您正苦于以下问题:Java WritableRaster.setSample方法的具体用法?Java WritableRaster.setSample怎么用?Java WritableRaster.setSample使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.image.WritableRaster
的用法示例。
在下文中一共展示了WritableRaster.setSample方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createOverview
import java.awt.image.WritableRaster; //导入方法依赖的package包/类
/**
* create a quicklook image from the GeoImageReader
* @param gir the source image
* @param width the output width
* @param height the output height
* @return a BufferedImage representing the quicklook
*/
public static BufferedImage createOverview(GeoImageReader gir, int width, int height,int band){
int nPass=gir.getHeight()/Constant.GEOIMAGE_TILE_SIZE;
int xstep=gir.getWidth()/width;
int ystep=gir.getHeight()/height;
width=gir.getWidth()/xstep;
height= gir.getHeight()/ystep;
BufferedImage out=new BufferedImage(width,height, BufferedImage.TYPE_USHORT_GRAY);
WritableRaster raster=out.getRaster();
for(int i=0;i<nPass;i++){
int[] t=gir.readTile(0, i*Constant.GEOIMAGE_TILE_SIZE, gir.getWidth(), Constant.GEOIMAGE_TILE_SIZE,band);
for(int x=0;x<width;x++){
for(int y=i*height/nPass;y<(i+1)*height/nPass;y++){
raster.setSample(x, y, 0, t[x*xstep*(y-i*height/nPass)*ystep]);
}
}
}
return out;
}
示例2: output
import java.awt.image.WritableRaster; //导入方法依赖的package包/类
public void output(File paramFile)
{
BufferedImage localBufferedImage = new BufferedImage(width, height, 10);
WritableRaster localWritableRaster = localBufferedImage.getRaster();
int i = 0;
if (i >= height) {
ImageIO.write(localBufferedImage, "png", paramFile);
} else {
for (int j = 0;; j++)
{
if (j >= width)
{
i++; break;
}
localWritableRaster.setSample(j, i, 0, data[(i * height + j)]);
}
}
}
示例3: getIndexedImage
import java.awt.image.WritableRaster; //导入方法依赖的package包/类
protected RenderedImage getIndexedImage() {
IndexColorModel icm = getIndexColorModel();
BufferedImage dst =
new BufferedImage(src.getWidth(), src.getHeight(),
BufferedImage.TYPE_BYTE_INDEXED, icm);
WritableRaster wr = dst.getRaster();
for (int y =0; y < dst.getHeight(); y++) {
for (int x = 0; x < dst.getWidth(); x++) {
Color aColor = getSrcColor(x,y);
wr.setSample(x, y, 0, findColorIndex(root, aColor));
}
}
return dst;
}
示例4: createIndexedImage
import java.awt.image.WritableRaster; //导入方法依赖的package包/类
protected static BufferedImage createIndexedImage(int w, int h,
IndexColorModel icm)
{
BufferedImage img = new BufferedImage(w, h,
BufferedImage.TYPE_BYTE_INDEXED,
icm);
int mapSize = icm.getMapSize();
int width = w / mapSize;
WritableRaster wr = img.getRaster();
for (int i = 0; i < mapSize; i++) {
for (int y = 0; y < h; y++) {
for (int x = 0; x < width; x++) {
wr.setSample(i * width + x, y, 0, i);
}
}
}
return img;
}
示例5: output
import java.awt.image.WritableRaster; //导入方法依赖的package包/类
public void output(File out, short data[]) throws IOException {
BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_GRAY);
WritableRaster r = img.getRaster();
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
// System.out.print(" "+x+","+y);
r.setSample(x, y, 0, data[y * height + x]);
}
// System.out.println();
}
ImageIO.write(img, "png", out);
}
示例6: output
import java.awt.image.WritableRaster; //导入方法依赖的package包/类
@Ignore
public void output(File out) throws IOException {
BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_GRAY);
WritableRaster r = img.getRaster();
for(int y = 0; y < height; y++) {
for(int x = 0; x < width; x++) {
r.setSample(x, y, 0, data[y * height + x]);
}
}
ImageIO.write(img, "png", out);
}
示例7: propertyChange
import java.awt.image.WritableRaster; //导入方法依赖的package包/类
@Override
synchronized public void propertyChange(PropertyChangeEvent evt) {
if ((aviOutputStream != null && isWriteEnabled())
&& (evt.getPropertyName() == AEFrameChipRenderer.EVENT_NEW_FRAME_AVAILBLE)
&& !chip.getAeViewer().isPaused()) {
FloatBuffer frame = ((AEFrameChipRenderer)chip.getRenderer()).getPixmap();
BufferedImage bufferedImage = new BufferedImage(chip.getSizeX(), chip.getSizeY(), BufferedImage.TYPE_3BYTE_BGR);
WritableRaster raster = bufferedImage.getRaster();
int sx = chip.getSizeX(), sy = chip.getSizeY();
for (int y = 0; y < sy; y++) {
for (int x = 0; x < sx; x++) {
int k = renderer.getPixMapIndex(x, y);
// bufferedImage.setRGB(x, y, (int) (frame[k] * 1024));
int yy = sy - y - 1;
int r = (int) (frame.get(k) * 255); // must flip image vertially according to java convention that image starts at upper left
int g = (int) (frame.get(k+1) * 255); // must flip image vertially according to java convention that image starts at upper left
int b = (int) (frame.get(k+2) * 255); // must flip image vertially according to java convention that image starts at upper left
raster.setSample(x, yy, 0, r);
raster.setSample(x, yy, 1, g);
raster.setSample(x, yy, 2, b);
}
}
try {
aviOutputStream.writeFrame(bufferedImage);
int timestamp = renderer.getTimestampFrameEnd();
writeTimecode(timestamp);
incrementFramecountAndMaybeCloseOutput();
} catch (IOException ex) {
Logger.getLogger(DavisFrameAviWriter.class.getName()).log(Level.SEVERE, null, ex);
}
} else if (evt.getPropertyName() == AEInputStream.EVENT_REWIND) {
doCloseFile();
}
}
示例8: reformatDiscontiguousData
import java.awt.image.WritableRaster; //导入方法依赖的package包/类
/**
* Reformats bit-discontiguous data into the {@code DataBuffer}
* of the supplied {@code WritableRaster}.
*/
private static void reformatDiscontiguousData(byte[] buf,
int[] bitsPerSample,
int stride,
int w,
int h,
WritableRaster raster)
throws IOException {
// Get SampleModel info.
SampleModel sm = raster.getSampleModel();
int numBands = sm.getNumBands();
// Initialize input stream.
ByteArrayInputStream is = new ByteArrayInputStream(buf);
ImageInputStream iis = new MemoryCacheImageInputStream(is);
// Reformat.
long iisPosition = 0L;
int y = raster.getMinY();
for(int j = 0; j < h; j++, y++) {
iis.seek(iisPosition);
int x = raster.getMinX();
for(int i = 0; i < w; i++, x++) {
for(int b = 0; b < numBands; b++) {
long bits = iis.readBits(bitsPerSample[b]);
raster.setSample(x, y, b, (int)bits);
}
}
iisPosition += stride;
}
}