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


Java ColorModel.getRGB方法代码示例

本文整理汇总了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;
  }
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:22,代码来源:RotateFilter.java

示例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);
  }
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:19,代码来源:ImprovedAveragingScaleFilter.java

示例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);
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:35,代码来源:RGBImageFilter.java

示例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);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:35,代码来源:RGBImageFilter.java

示例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));
    }
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:29,代码来源:MirrorImageFilter.java

示例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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:ImageRepresentation.java

示例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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:WBMPPluginTest.java

示例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;
        }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:34,代码来源:BMPCompressionTest.java

示例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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:35,代码来源:BMPWriteParamTest.java

示例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);
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:ImageCompare.java

示例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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:44,代码来源:CustomComponent.java


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