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


Java WritableRaster.getDataElements方法代码示例

本文整理汇总了Java中java.awt.image.WritableRaster.getDataElements方法的典型用法代码示例。如果您正苦于以下问题:Java WritableRaster.getDataElements方法的具体用法?Java WritableRaster.getDataElements怎么用?Java WritableRaster.getDataElements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.image.WritableRaster的用法示例。


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

示例1: renderGlyph

import java.awt.image.WritableRaster; //导入方法依赖的package包/类
/**
 * Loads a single glyph to the backing texture, if it fits.
 * 
 * @param glyph The glyph to be rendered
 * @param width The expected width of the glyph
 * @param height The expected height of the glyph
 * @throws SlickException if the glyph could not be rendered.
 */
private void renderGlyph(Glyph glyph, int width, int height) throws SlickException {
	// Draw the glyph to the scratch image using Java2D.
	scratchGraphics.setComposite(AlphaComposite.Clear);
	scratchGraphics.fillRect(0, 0, MAX_GLYPH_SIZE, MAX_GLYPH_SIZE);
	scratchGraphics.setComposite(AlphaComposite.SrcOver);
	scratchGraphics.setColor(java.awt.Color.white);
	for (Iterator iter = unicodeFont.getEffects().iterator(); iter.hasNext();)
		((Effect)iter.next()).draw(scratchImage, scratchGraphics, unicodeFont, glyph);
	glyph.setShape(null); // The shape will never be needed again.

	WritableRaster raster = scratchImage.getRaster();
	int[] row = new int[width];
	for (int y = 0; y < height; y++) {
		raster.getDataElements(0, y, width, 1, row);
		scratchIntBuffer.put(row);
	}
	GL.glTexSubImage2D(SGL.GL_TEXTURE_2D, 0, pageX, pageY, width, height, SGL.GL_BGRA, SGL.GL_UNSIGNED_BYTE,
		scratchByteBuffer);
	scratchIntBuffer.clear();

	glyph.setImage(pageImage.getSubImage(pageX, pageY, width, height));
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:31,代码来源:GlyphPage.java

示例2: hash

import java.awt.image.WritableRaster; //导入方法依赖的package包/类
private static String hash(BufferedImage image) {
    try {
        MessageDigest digest = MessageDigest.getInstance("SHA1");
        int width = image.getWidth();
        int height = image.getHeight();
        if (image.getType() != BufferedImage.TYPE_INT_ARGB) {
            BufferedImage newImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
            newImage.getGraphics().drawImage(image, 0, 0, null);
            image = newImage;
        }
        WritableRaster raster = image.getRaster();
        int[] pixels = new int[width];
        for (int y = 0; y < height; y++) {
            raster.getDataElements(0, y, width, 1, pixels);
            for (int x = 0; x < width; x++) {
                hash(digest, pixels[x]);
            }
        }
        hash(digest, width);
        hash(digest, height);
        return new BigInteger(1, digest.digest()).toString(16);
    } catch (NoSuchAlgorithmException ex) {
        throw new RuntimeException(ex);
    }
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:26,代码来源:ImageProcessor.java

示例3: preloadLineTile

import java.awt.image.WritableRaster; //导入方法依赖的package包/类
public  void preloadLineTile(int y, int length,int band) {
    if (y < 0) {
        return;
    }
    preloadedInterval = new int[]{y, y + length};
    Rectangle rect = new Rectangle(0, y, getImage(band).getxSize(), length);
    
    TIFF tiff=(TIFF)getImage(band);
    rect=tiff.getBounds().intersection(rect);
    TIFFImageReadParam tirp=new TIFFImageReadParam();
    tirp.setSourceRegion(rect);
    try {
    	BufferedImage bi=null;
    	try{
    			
    		bi=tiff.read(0, tirp);
    	}catch(Exception e){
    		logger.warn("Problem reading image POS x:"+0+ "  y: "+y +"   try to read again");
    		try {
			    Thread.sleep(100);                 
			} catch(InterruptedException exx) {
			    Thread.currentThread().interrupt();
			}
    		bi=tiff.read(0, tirp);
    	}	
    	WritableRaster raster=bi.getRaster();
    	preloadedData=(short[])raster.getDataElements(0, 0, raster.getWidth(), raster.getHeight(), null);//tSamples(0, 0, raster.getWidth(), raster.getHeight(), 0, (short[]) null);
    } catch (Exception ex) {
        logger.error(ex.getMessage(),ex);
    }finally{
    	//tiff.reader.addIIOReadProgressListener(this);
    	//readComplete=false;
    	
    }
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:36,代码来源:Sentinel1GRD.java

示例4: preloadLineTile

import java.awt.image.WritableRaster; //导入方法依赖的package包/类
@Override
public void preloadLineTile(int y, int length, int band) {
	TIFF tiff=(TIFF)getImage(band);
	if (y < 0) {
           return;
       }
       preloadedInterval = new int[]{y, y + length};
       Rectangle rect = new Rectangle(0, y, tiff.xSize, length);


       rect=tiff.getBounds().intersection(rect);

       try {
       	BufferedImage bi=null;
       	try{
       			bi=tiff.read(0, rect);
       	}catch(Exception e){
       		logger.warn("Problem reading image POS x:"+0+ "  y: "+y +"   try to read again");
       		try {
   			    Thread.sleep(100);
   			} catch(InterruptedException exx) {
   			    Thread.currentThread().interrupt();
   			}
       		bi=tiff.read(0, rect);
       	}
       	WritableRaster raster=bi.getRaster();
       	preloadedData=(Short[])raster.getDataElements(0, 0, raster.getWidth(), raster.getHeight(), null);//tSamples(0, 0, raster.getWidth(), raster.getHeight(), 0, (short[]) null);
       } catch (Exception ex) {
           logger.error(ex.getMessage(),ex);
       }finally{
       }

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

示例5: preloadLineTile

import java.awt.image.WritableRaster; //导入方法依赖的package包/类
@Override
public void preloadLineTile(int y, int length, int band) {
	if (y < 0) {
           return;
       }
       preloadedInterval = new int[]{y, y + length};
       Rectangle rect = new Rectangle(0, y, getImage(band).xSize, length);

       TIFF tiff=getImage(band);
       rect=tiff.getBounds().intersection(rect);
       try {
       	BufferedImage bi=null;
       	try{
       			bi=tiff.read(0, rect);
       	}catch(Exception e){
       		logger.warn("Problem reading image POS x:"+0+ "  y: "+y +"   try to read again");
       		try {
   			    Thread.sleep(100);
   			} catch(InterruptedException exx) {
   			    Thread.currentThread().interrupt();
   			}
       		bi=tiff.read(0, rect);
       	}
       	WritableRaster raster=bi.getRaster();
       	short[]ss=(short[])raster.getDataElements(0, 0, raster.getWidth(), raster.getHeight(), null);//tSamples(0, 0, raster.getWidth(), raster.getHeight(), 0, (short[]) null);
       	preloadedData=ArrayUtils.toObject(ss);
       } catch (Exception ex) {
           logger.error(ex.getMessage(),ex);
       }finally{
       	//tiff.reader.addIIOReadProgressListener(this);
       	//readComplete=false;

       }

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

示例6: setRaster

import java.awt.image.WritableRaster; //导入方法依赖的package包/类
public void setRaster(int x, int y, int xerr, int yerr,
                      int w, int h, int bWidth, int bHeight,
                      int colincx, int colincxerr,
                      int colincy, int colincyerr,
                      int rowincx, int rowincxerr,
                      int rowincy, int rowincyerr) {
    Object data = null;
    int rowx = x;
    int rowy = y;
    int rowxerr = xerr;
    int rowyerr = yerr;
    WritableRaster srcRas = this.srcRas;
    WritableRaster outRas = this.outRas;
    int rgbs[] = filter ? new int[4] : null;
    for (int j = 0; j < h; j++) {
        x = rowx;
        y = rowy;
        xerr = rowxerr;
        yerr = rowyerr;
        for (int i = 0; i < w; i++) {
            data = srcRas.getDataElements(x, y, data);
            if (filter) {
                int nextx, nexty;
                if ((nextx = x + 1) >= bWidth) {
                    nextx = 0;
                }
                if ((nexty = y + 1) >= bHeight) {
                    nexty = 0;
                }
                rgbs[0] = colorModel.getRGB(data);
                data = srcRas.getDataElements(nextx, y, data);
                rgbs[1] = colorModel.getRGB(data);
                data = srcRas.getDataElements(x, nexty, data);
                rgbs[2] = colorModel.getRGB(data);
                data = srcRas.getDataElements(nextx, nexty, data);
                rgbs[3] = colorModel.getRGB(data);
                int rgb =
                    TexturePaintContext.blend(rgbs, xerr, yerr);
                data = colorModel.getDataElements(rgb, data);
            }
            outRas.setDataElements(i, j, data);
            if ((xerr += colincxerr) < 0) {
                xerr &= Integer.MAX_VALUE;
                x++;
            }
            if ((x += colincx) >= bWidth) {
                x -= bWidth;
            }
            if ((yerr += colincyerr) < 0) {
                yerr &= Integer.MAX_VALUE;
                y++;
            }
            if ((y += colincy) >= bHeight) {
                y -= bHeight;
            }
        }
        if ((rowxerr += rowincxerr) < 0) {
            rowxerr &= Integer.MAX_VALUE;
            rowx++;
        }
        if ((rowx += rowincx) >= bWidth) {
            rowx -= bWidth;
        }
        if ((rowyerr += rowincyerr) < 0) {
            rowyerr &= Integer.MAX_VALUE;
            rowy++;
        }
        if ((rowy += rowincy) >= bHeight) {
            rowy -= bHeight;
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:73,代码来源:TexturePaintContext.java


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