本文整理汇总了Java中java.awt.image.ColorModel.getRGB方法的典型用法代码示例。如果您正苦于以下问题:Java ColorModel.getRGB方法的具体用法?Java ColorModel.getRGB怎么用?Java ColorModel.getRGB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.image.ColorModel
的用法示例。
在下文中一共展示了ColorModel.getRGB方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setPixels
import java.awt.image.ColorModel; //导入方法依赖的package包/类
/**
* Set the pixels in our image array from the passed
* array of bytes. Xlate the pixels into our default
* color model (RGB).
* @see ImageConsumer#setPixels
*/
public void setPixels(int x, int y, int w, int h,
ColorModel model, byte pixels[],
int off, int scansize) {
int index = y * originalSpace.width + x;
int srcindex = off;
int srcinc = scansize - w;
int indexinc = originalSpace.width - w;
for (int dy = 0; dy < h; dy++) {
for (int dx = 0; dx < w; dx++) {
inPixels[index++] = model.getRGB(pixels[srcindex++] & 0xff);
}
srcindex += srcinc;
index += indexinc;
}
}
示例2: setThePixels
import java.awt.image.ColorModel; //导入方法依赖的package包/类
private void setThePixels (int x, int y, int width, int height,
ColorModel cm, Object pixels, int offset, int scansize) {
int sourceOffset = offset;
int destinationOffset = y * savedWidth + x;
boolean bytearray = (pixels instanceof byte[]);
for (int yy=0;yy<height;yy++) {
for (int xx=0;xx<width;xx++)
if (bytearray)
savedPixels[destinationOffset++]=
cm.getRGB(((byte[])pixels)[sourceOffset++]&0xff);
else
savedPixels[destinationOffset++]=
cm.getRGB(((int[])pixels)[sourceOffset++]);
sourceOffset += (scansize - width);
destinationOffset += (savedWidth - width);
}
}
示例3: setPixels
import java.awt.image.ColorModel; //导入方法依赖的package包/类
/**
* If the ColorModel object is the same one that has already
* been converted, then simply passes the pixels through with the
* converted ColorModel. Otherwise converts the buffer of byte
* pixels to the default RGB ColorModel and passes the converted
* buffer to the filterRGBPixels method to be converted one by one.
* <p>
* Note: This method is intended to be called by the
* <code>ImageProducer</code> of the <code>Image</code> whose pixels
* are being filtered. Developers using
* this class to filter pixels from an image should avoid calling
* this method directly since that operation could interfere
* with the filtering operation.
* @see ColorModel#getRGBdefault
* @see #filterRGBPixels
*/
public void setPixels(int x, int y, int w, int h,
ColorModel model, byte pixels[], int off,
int scansize) {
if (model == origmodel) {
consumer.setPixels(x, y, w, h, newmodel, pixels, off, scansize);
} else {
int filteredpixels[] = new int[w];
int index = off;
for (int cy = 0; cy < h; cy++) {
for (int cx = 0; cx < w; cx++) {
filteredpixels[cx] = model.getRGB((pixels[index] & 0xff));
index++;
}
index += scansize - w;
filterRGBPixels(x, y + cy, w, 1, filteredpixels, 0, w);
}
}
}
示例4: setPixels
import java.awt.image.ColorModel; //导入方法依赖的package包/类
/**
* If the ColorModel object is the same one that has already
* been converted, then simply passes the pixels through with the
* converted ColorModel. Otherwise converts the buffer of byte
* pixels to the default RGB ColorModel and passes the converted
* buffer to the filterRGBPixels method to be converted one by one.
* <p>
* Note: This method is intended to be called by the
* {@code ImageProducer} of the {@code Image} whose pixels
* are being filtered. Developers using
* this class to filter pixels from an image should avoid calling
* this method directly since that operation could interfere
* with the filtering operation.
* @see ColorModel#getRGBdefault
* @see #filterRGBPixels
*/
public void setPixels(int x, int y, int w, int h,
ColorModel model, byte pixels[], int off,
int scansize) {
if (model == origmodel) {
consumer.setPixels(x, y, w, h, newmodel, pixels, off, scansize);
} else {
int filteredpixels[] = new int[w];
int index = off;
for (int cy = 0; cy < h; cy++) {
for (int cx = 0; cx < w; cx++) {
filteredpixels[cx] = model.getRGB((pixels[index] & 0xff));
index++;
}
index += scansize - w;
filterRGBPixels(x, y + cy, w, 1, filteredpixels, 0, w);
}
}
}
示例5: setPixels
import java.awt.image.ColorModel; //导入方法依赖的package包/类
@Override
public void setPixels(
int x,
int y,
int width,
int height,
ColorModel model,
byte pixels[],
int off,
int scansize
)
{
// If setDimensions() hasn't been called - and we haven't allocated
// our pixels array, just blow off this call to setPixels(). Hopefully,
// we'll see a subsequent call to setDimensions() and redelivery of
// the pixels in question.
if (_pixels == null)
return;
for (int n = y; n < (y + height); n++)
{
for (int m = x; m < (x + width); m++)
{
byte value = pixels[n * scansize + m + off];
_pixels[n * _width + m] = model.getRGB((value & 0xff));
}
}
}
示例6: setPixels
import java.awt.image.ColorModel; //导入方法依赖的package包/类
@Override
public void setPixels(int x, int y, int w, int h, ColorModel model, byte[] pixels, int off, int scansize){
int[] pixeli = new int[pixels.length];
for (int i = 0; i < pixels.length; i++)
{
pixeli[i] = model.getRGB(pixels[i] & 0xff);
}
setPixels(x, y, w, h, model, pixeli, off, scansize);
}
示例7: compare
import java.awt.image.ColorModel; //导入方法依赖的package包/类
private boolean compare(BufferedImage in, BufferedImage out) {
int width = in.getWidth();
int height = in.getHeight();
if (out.getWidth() != width || out.getHeight() != height) {
throw new RuntimeException("Dimensions changed!");
}
Raster oldras = in.getRaster();
ColorModel oldcm = in.getColorModel();
Raster newras = out.getRaster();
ColorModel newcm = out.getColorModel();
for (int j = 0; j < height; j++) {
for (int i = 0; i < width; i++) {
Object oldpixel = oldras.getDataElements(i, j, null);
int oldrgb = oldcm.getRGB(oldpixel);
int oldalpha = oldcm.getAlpha(oldpixel);
Object newpixel = newras.getDataElements(i, j, null);
int newrgb = newcm.getRGB(newpixel);
int newalpha = newcm.getAlpha(newpixel);
if (newrgb != oldrgb ||
newalpha != oldalpha) {
throw new RuntimeException("Pixels differ at " + i +
", " + j);
}
}
}
return true;
}
示例8: compare
import java.awt.image.ColorModel; //导入方法依赖的package包/类
private boolean compare(final BufferedImage in, final BufferedImage out) {
final int width = in.getWidth();
int height = in.getHeight();
if (out.getWidth() != width || out.getHeight() != height) {
throw new RuntimeException("Dimensions changed!");
}
Raster oldras = in.getRaster();
ColorModel oldcm = in.getColorModel();
Raster newras = out.getRaster();
ColorModel newcm = out.getColorModel();
for (int j = 0; j < height; j++) {
for (int i = 0; i < width; i++) {
Object oldpixel = oldras.getDataElements(i, j, null);
int oldrgb = oldcm.getRGB(oldpixel);
int oldalpha = oldcm.getAlpha(oldpixel);
Object newpixel = newras.getDataElements(i, j, null);
int newrgb = newcm.getRGB(newpixel);
int newalpha = newcm.getAlpha(newpixel);
if (newrgb != oldrgb ||
newalpha != oldalpha) {
// showDiff(in, out);
throw new RuntimeException("Pixels differ at " + i +
", " + j + " new = " + Integer.toHexString(newrgb) + " old = " + Integer.toHexString(oldrgb));
}
}
}
return true;
}
示例9: compare
import java.awt.image.ColorModel; //导入方法依赖的package包/类
private static boolean compare(final BufferedImage in,
final BufferedImage out)
{
final int width = in.getWidth();
int height = in.getHeight();
if (out.getWidth() != width || out.getHeight() != height) {
throw new RuntimeException("Dimensions changed!");
}
Raster oldras = in.getRaster();
ColorModel oldcm = in.getColorModel();
Raster newras = out.getRaster();
ColorModel newcm = out.getColorModel();
for (int j = 0; j < height; j++) {
for (int i = 0; i < width; i++) {
Object oldpixel = oldras.getDataElements(i, j, null);
int oldrgb = oldcm.getRGB(oldpixel);
int oldalpha = oldcm.getAlpha(oldpixel);
Object newpixel = newras.getDataElements(i, j, null);
int newrgb = newcm.getRGB(newpixel);
int newalpha = newcm.getAlpha(newpixel);
if (newrgb != oldrgb ||
newalpha != oldalpha) {
// showDiff(in, out);
throw new RuntimeException("Pixels differ at " + i +
", " + j + " new = " + Integer.toHexString(newrgb) + " old = " + Integer.toHexString(oldrgb));
}
}
}
return true;
}
示例10: compare
import java.awt.image.ColorModel; //导入方法依赖的package包/类
public static void compare(BufferedImage oldimg,
BufferedImage newimg) {
int width = oldimg.getWidth();
int height = oldimg.getHeight();
if (newimg.getWidth() != width || newimg.getHeight() != height) {
throw new RuntimeException("Dimensions changed!");
}
Raster oldras = oldimg.getRaster();
ColorModel oldcm = oldimg.getColorModel();
Raster newras = newimg.getRaster();
ColorModel newcm = newimg.getColorModel();
for (int j = 0; j < height; j++) {
for (int i = 0; i < width; i++) {
Object oldpixel = oldras.getDataElements(i, j, null);
int oldrgb = oldcm.getRGB(oldpixel);
int oldalpha = oldcm.getAlpha(oldpixel);
Object newpixel = newras.getDataElements(i, j, null);
int newrgb = newcm.getRGB(newpixel);
int newalpha = newcm.getAlpha(newpixel);
if (newrgb != oldrgb ||
newalpha != oldalpha) {
throw new RuntimeException("Pixels differ at " + i +
", " + j);
}
}
}
}
示例11: Blit
import java.awt.image.ColorModel; //导入方法依赖的package包/类
public void Blit(SurfaceData src, SurfaceData dst,
Composite comp, Region clip,
int srcx, int srcy, int dstx, int dsty, int w, int h)
{
Raster srcRast = src.getRaster(srcx, srcy, w, h);
ColorModel srcCM = src.getColorModel();
Raster dstRast = dst.getRaster(dstx, dsty, w, h);
IntegerComponentRaster icr = (IntegerComponentRaster) dstRast;
int[] dstPix = icr.getDataStorage();
Region roi = CustomComponent.getRegionOfInterest(src, dst, clip,
srcx, srcy,
dstx, dsty, w, h);
SpanIterator si = roi.getSpanIterator();
Object srcPix = null;
int dstScan = icr.getScanlineStride();
// assert(icr.getPixelStride() == 1);
srcx -= dstx;
srcy -= dsty;
int span[] = new int[4];
while (si.nextSpan(span)) {
int rowoff = icr.getDataOffset(0) + span[1] * dstScan + span[0];
for (int y = span[1]; y < span[3]; y++) {
int off = rowoff;
for (int x = span[0]; x < span[2]; x++) {
srcPix = srcRast.getDataElements(x+srcx, y+srcy, srcPix);
dstPix[off++] = srcCM.getRGB(srcPix);
}
rowoff += dstScan;
}
}
// Pixels in the dest were modified directly, we must
// manually notify the raster that it was modified
icr.markDirty();
// REMIND: We need to do something to make sure that dstRast
// is put back to the destination (as in the native Release
// function)
// src.releaseRaster(srcRast); // NOP?
// dst.releaseRaster(dstRast);
}