java getcolormodel_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

​點讚 3

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,

示例2: setThePixels

​點讚 3

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

for (int xx=0;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,

示例3: setPixels

​點讚 3

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.

*

* Note: This method is intended to be called by the

* ImageProducer of the 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:SunburstApps,項目名稱:OpenJSharp,代碼行數:35,

示例4: setPixels

​點讚 3

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.

*

* 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,

示例5: setPixels

​點讚 2

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,

示例6: setPixels

​點讚 2

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,

示例7: compare

​點讚 2

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,

示例8: compare

​點讚 2

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,

示例9: compare

​點讚 2

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,

示例10: compare

​點讚 2

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,

示例11: Blit

​點讚 2

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,

注:本文中的java.awt.image.ColorModel.getRGB方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值