本文整理了Java中java.awt.image.Raster.getWidth
方法的一些代码示例,展示了Raster.getWidth
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Raster.getWidth
方法的具体详情如下:
包路径:java.awt.image.Raster
类名称:Raster
方法名:getWidth
暂无
代码示例来源:origin: geoserver/geoserver
/** Recycle the given tile. */
public void recycleTile(Raster tile) {
if (tile.getWidth() != tile.getHeight() || tile.getWidth() > 512) {
return;
}
recycledArrays.recycleTile(tile);
}
}
代码示例来源:origin: stackoverflow.com
File f = new File("/path/imagefile.jpg");
//Find a suitable ImageReader
Iterator readers = ImageIO.getImageReadersByFormatName("JPEG");
ImageReader reader = null;
while(readers.hasNext()) {
reader = (ImageReader)readers.next();
if(reader.canReadRaster()) {
break;
}
}
//Stream the image file (the original CMYK image)
ImageInputStream input = ImageIO.createImageInputStream(f);
reader.setInput(input);
//Read the image raster
Raster raster = reader.readRaster(0, null);
//Create a new RGB image
BufferedImage bi = new BufferedImage(raster.getWidth(), raster.getHeight(),
BufferedImage.TYPE_4BYTE_ABGR);
//Fill the new image with the old raster
bi.getRaster().setRect(raster);
代码示例来源:origin: graphhopper/graphhopper
private void fillDataAccessWithElevationData(Raster raster, DataAccess heights, int dataAccessWidth) {
final int height = raster.getHeight();
final int width = raster.getWidth();
int x = 0;
int y = 0;
try {
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
short val = (short) raster.getPixel(x, y, (int[]) null)[0];
if (val < -1000 || val > 12000)
val = Short.MIN_VALUE;
heights.setShort(2 * (y * dataAccessWidth + x), val);
}
}
heights.flush();
} catch (Exception ex) {
throw new RuntimeException("Problem at x:" + x + ", y:" + y, ex);
}
}
代码示例来源:origin: geoserver/geoserver
for (int band = 0; band < raster.getNumBands(); band++) {
ps.println("Band " + band + ":");
for (int j = raster.getMinY(); j < (raster.getMinY() + raster.getHeight()); j++) {
for (int i = raster.getMinX(); i < (raster.getMinX() + raster.getWidth()); i++) {
if (raster.getTransferType() == DataBuffer.TYPE_DOUBLE)
ps.print(raster.getSampleDouble(i, j, band));
ps.print(raster.getSampleFloat(i, j, band));
else ps.print(raster.getSample(i, j, band));
if (i < (raster.getMinX() + raster.getWidth() - 1)) {
ps.print(" ");
代码示例来源:origin: nutzam/nutz
int w = raster.getWidth();
int h = raster.getHeight();
byte[] rgb = new byte[w * h * 3];
代码示例来源:origin: stackoverflow.com
cmykProfile = ICC_Profile.getInstance(JpegReader.class.getResourceAsStream("/ISOcoated_v2_300_eci.icc"));
ICC_ColorSpace cmykCS = new ICC_ColorSpace(cmykProfile);
BufferedImage rgbImage = new BufferedImage(cmykRaster.getWidth(), cmykRaster.getHeight(), BufferedImage.TYPE_INT_RGB);
WritableRaster rgbRaster = rgbImage.getRaster();
ColorSpace rgbCS = rgbImage.getColorModel().getColorSpace();
代码示例来源:origin: stackoverflow.com
BufferedImage rgbImage = new BufferedImage(cmykRaster.getWidth(), cmykRaster.getHeight(), BufferedImage.TYPE_INT_RGB);
WritableRaster rgbRaster = rgbImage.getRaster();
ColorSpace rgbCS = rgbImage.getColorModel().getColorSpace();
代码示例来源:origin: haraldk/TwelveMonkeys
public Rectangle2D getBounds2D(Raster src) {
return new Rectangle(src.getWidth(), src.getHeight());
}
代码示例来源:origin: haraldk/TwelveMonkeys
/**
* Creates a compatible {@code Raster} to dither into.
*
* @param pSrc the source raster.
* @param pIndexColorModel the index color model used to create a {@code Raster}.
*
* @return a {@code WritableRaster}
*/
public final WritableRaster createCompatibleDestRaster(Raster pSrc, IndexColorModel pIndexColorModel) {
return pIndexColorModel.createCompatibleWritableRaster(pSrc.getWidth(), pSrc.getHeight());
}
代码示例来源:origin: haraldk/TwelveMonkeys
public final WritableRaster createCompatibleDestRaster(Raster pSrc, IndexColorModel pIndexColorModel) {
return pIndexColorModel.createCompatibleWritableRaster(pSrc.getWidth(), pSrc.getHeight());
}
代码示例来源:origin: dermotte/LIRE
private static int[][][] hsvImage(Raster r) {
int[][][] pixels = new int[r.getWidth()][r.getHeight()][3];
// quantize colors for each pixel (done in HSV color space):
int[] pixel = new int[3];
for (int x = 0; x < r.getWidth(); x++) {
for (int y = 0; y < r.getHeight(); y++) {
// converting to HSV:
int[] hsv = new int[3];
convertRgbToHsv(r.getPixel(x, y, pixel), hsv);
// quantize the actual pixel:
pixels[x][y] = hsv;
}
}
return pixels;
}
代码示例来源:origin: dermotte/LIRE
private static int[][][] hsvImage(Raster r) {
int[][][] pixels = new int[r.getWidth()][r.getHeight()][3];
// quantize colors for each pixel (done in HSV color space):
int[] pixel = new int[3];
for (int x = 0; x < r.getWidth(); x++) {
for (int y = 0; y < r.getHeight(); y++) {
// converting to HSV:
int[] hsv = new int[3];
convertRgbToHsv(r.getPixel(x, y, pixel), hsv);
// quantize the actual pixel:
pixels[x][y] = hsv;
}
}
return pixels;
}
代码示例来源:origin: haraldk/TwelveMonkeys
private IndexColorModel createIndexColorModel(Raster pSource) {
BufferedImage image = new BufferedImage(pSource.getWidth(), pSource.getHeight(),
BufferedImage.TYPE_INT_ARGB);
image.setData(pSource);
return IndexImage.getIndexColorModel(image, 256, IndexImage.TRANSPARENCY_BITMASK);
}
代码示例来源:origin: haraldk/TwelveMonkeys
private IndexColorModel createIndexColorModel(Raster pSource) {
BufferedImage image = new BufferedImage(pSource.getWidth(), pSource.getHeight(), BufferedImage.TYPE_INT_ARGB);
image.setData(pSource);
return IndexImage.getIndexColorModel(image, 256, IndexImage.TRANSPARENCY_BITMASK | IndexImage.COLOR_SELECTION_QUALITY);
}
代码示例来源:origin: haraldk/TwelveMonkeys
private static void convertYCbCr2RGB(final Raster raster, final int numComponents) {
final int height = raster.getHeight();
final int width = raster.getWidth();
final byte[] data = ((DataBufferByte) raster.getDataBuffer()).getData();
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
YCbCrConverter.convertYCbCr2RGB(data, data, (x + y * width) * numComponents);
}
}
}
代码示例来源:origin: haraldk/TwelveMonkeys
public WritableRaster createCompatibleDestRaster(final Raster src) {
// WHAT?? This code no longer work for JRE 7u45+... JRE bug?!
// Raster child = src.createChild(0, 0, src.getWidth(), src.getHeight(), 0, 0, new int[] {0, 1, 2});
// return child.createCompatibleWritableRaster(); // Throws an exception complaining about the scanline stride from the verify() method
// This is a workaround for the above code that no longer works.
// It wil use 25% more memory, but it seems to work...
WritableRaster raster = src.createCompatibleWritableRaster();
return raster.createWritableChild(0, 0, src.getWidth(), src.getHeight(), 0, 0, new int[] {0, 1, 2});
}
代码示例来源:origin: haraldk/TwelveMonkeys
private static void convertYCCK2CMYK(final Raster raster) {
final int height = raster.getHeight();
final int width = raster.getWidth();
final byte[] data = ((DataBufferByte) raster.getDataBuffer()).getData();
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
int offset = (x + y * width) * 4;
// YCC -> CMY
YCbCrConverter.convertYCbCr2RGB(data, data, offset);
// Inverse K
data[offset + 3] = (byte) (0xff - data[offset + 3] & 0xff);
}
}
}
代码示例来源:origin: geotools/geotools
/**
* Constructs multi-dimensional grid envelope defined by a {@link Raster}. The two first
* dimensions are set to the [{@linkplain Raster#getMinX x} .. x+{@linkplain Raster#getWidth
* width}-1] and [{@linkplain Raster#getMinY y} .. y+{@linkplain Raster#getHeight height}-1]
* inclusive ranges respectively. Extra dimensions (if any) are set to the [0..0] inclusive
* range.
*
* <p>Notice that this method ensure interoperability between {@link Raster} dimensions in
* Java2D style and {@link GridEnvelope} dimensions in ISO 19123 style providing that the user
* remember to add 1 to the {@link GridEnvelope#getHigh(int)} values.
*
* @param raster The raster for which to construct a grid envelope.
* @param dimension Number of dimensions for this grid envelope. Must be equals or greater than
* 2.
*/
public GeneralGridEnvelope(final Raster raster, final int dimension) {
this(raster.getMinX(), raster.getMinY(), raster.getWidth(), raster.getHeight(), dimension);
}
代码示例来源:origin: dermotte/LIRE
public double[] getFeature(BufferedImage image) {
image = ImageUtils.scaleImage(image, MAX_IMG_HEIGHT);
Raster imageRaster = image.getRaster();
int[][] grayLevel = new int[imageRaster.getWidth()][imageRaster.getHeight()];
int[] tmp = new int[3];
for (int i = 0; i < imageRaster.getWidth(); i++) {
for (int j = 0; j < imageRaster.getHeight(); j++) {
grayLevel[i][j] = imageRaster.getPixel(i, j, tmp)[0];
代码示例来源:origin: dermotte/LIRE
public double[] getFeature(BufferedImage image) {
image = ImageUtils.scaleImage(image, MAX_IMG_HEIGHT);
Raster imageRaster = image.getRaster();
int[][] grayLevel = new int[imageRaster.getWidth()][imageRaster.getHeight()];
int[] tmp = new int[3];
for (int i = 0; i < imageRaster.getWidth(); i++) {
for (int j = 0; j < imageRaster.getHeight(); j++) {
grayLevel[i][j] = imageRaster.getPixel(i, j, tmp)[0];
内容来源于网络,如有侵权,请联系作者删除!