setrgbjava_JavaBufferedImage.setRGB⽅法代碼⽰例
本⽂整理匯總了Java中java.awt.image.BufferedImage.setRGB⽅法的典型⽤法代碼⽰例。如果您正苦於以下問題:Java BufferedImage.setRGB⽅法的具體⽤法?Java BufferedImage.setRGB怎麽⽤?Java BufferedImage.setRGB使⽤的例⼦?那麽恭喜您, 這裏精選的⽅法代碼⽰例或許可以為您提供幫助。您也可以進⼀步了解該⽅法所在類java.awt.image.BufferedImage的⽤法⽰例。
在下⽂中⼀共展⽰了BufferedImage.setRGB⽅法的19個代碼⽰例,這些例⼦默認根據受歡迎程度排序。您可以為喜歡或者感覺有⽤的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼⽰例。
⽰例1: createTestImage
點讚 4
import java.awt.image.BufferedImage; //導⼊⽅法依賴的package包/類
private static ImageInputStream createTestImage(int type) throws IOException {
int w = 100;
int h = 100;
BufferedImage img = new BufferedImage(w, h, type);
int dx = w / colors.length;
for (int i = 0; i < colors.length; i++) {
for (int x = i *dx; (x < (i + 1) * dx) && (x < w) ; x++) {
for (int y = 0; y < h; y++) {
img.setRGB(x, y, colors[i].getRGB());
}
}
}
File pwd = new File(".");
File out = ateTempFile("rgba_", ".png", pwd);
java replace方法
System.out.println("Create file: " + AbsolutePath());
ImageIO.write(img, "PNG", out);
ateImageInputStream(out);
}
開發者ID:lambdalab-mirror,項⽬名稱:jdk8u-jdk,代碼⾏數:23,
⽰例2: testCopySrcIntoDstAt4
點讚 3
import java.awt.image.BufferedImage; //導⼊⽅法依賴的package包/類
@Test ()
public void testCopySrcIntoDstAt4()
{
System.out.println("copySrcIntoDstAt: send image with 1 pixel(RGB), expects 1 pixel(RGB)");
BufferedImage src = new BufferedImage(1, 1, BufferedImage.TYPE_3BYTE_BGR);
src.setRGB(0, 0, 10);
BufferedImage dst = new BufferedImage(1, 1, BufferedImage.TYPE_3BYTE_BGR);
DataBufferByte expected = (DataBufferByte) Raster().getDataBuffer();
DataBufferByte result = (DataBufferByte) Raster().getDataBuffer();
Data(), Data());
}
開發者ID:buni-rock,項⽬名稱:Pixie,代碼⾏數:18,
⽰例3: getTexture
點讚 3
import java.awt.image.BufferedImage; //導⼊⽅法依賴的package包/類
@Override
public BufferedImage getTexture(double seed) {
mainColor = new Color(128,128,128);
BufferedImage bi = new BufferedImage(TextureGenerator.TEX_W, TextureGenerator.TEX_H,
BufferedImage.TYPE_4BYTE_ABGR);
Color c;
for(int i = 0;i < bi.getWidth();i++) {
for(int j = 0;j < bi.getHeight();j++) {
c = TextureGenerator.fade(ick(mainColor, -10),Math.d(i-j,
32)-16)/16); //strength != 0 && weakStrength != 0 ? trick(mainc,turbulence(i+3.1f,j+3.1f,1,seed)*80) : mainc;
bi.setRGB(i, j, c.getRGB());
}
}
return bi;
}
開發者ID:vanyle,項⽬名稱:Explorium,代碼⾏數:17,
⽰例4: createImage
點讚 3
import java.awt.image.BufferedImage; //導⼊⽅法依賴的package包/類
private static BufferedImage createImage(String content, String imgPath,
boolean needCompress) throws Exception {
Hashtable hints = new Hashtable();
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
hints.put(EncodeHintType.CHARACTER_SET, CHARSET);
hints.put(EncodeHintType.MARGIN, 1);
BitMatrix bitMatrix = new MultiFormatWriter().encode(content,
BarcodeFormat.QR_CODE, QRCODE_SIZE, QRCODE_SIZE, hints);
int width = Width();
int height = Height();
BufferedImage image = new BufferedImage(width, height,
BufferedImage.TYPE_INT_RGB);
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
image.setRGB(x, y, (x, y) ? 0xFF000000
: 0xFFFFFFFF);
}
}
if (imgPath == null || "".equals(imgPath)) {
return image;
}
// 插⼊圖⽚
CodeUtil.insertImage(image, imgPath, needCompress);
return image;
}
開發者ID:Fetax,項⽬名稱:Fetax-AI,代碼⾏數:26,
⽰例5: makeIcon
點讚 3
import java.awt.image.BufferedImage; //導⼊⽅法依賴的package包/類
private static Image makeIcon(long hIcon, boolean getLargeIcon) {
if (hIcon != 0L && hIcon != -1L) {
// Get the bits. This has the side effect of setting the imageHash value for this object.
final int[] iconBits = getIconBits(hIcon);
if (iconBits != null) {
/
/ icons are always square
final int size = (int) Math.sqrt(iconBits.length);
final int baseSize = getLargeIcon ? 32 : 16;
final BufferedImage img =
new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB);
img.setRGB(0, 0, size, size, iconBits, 0, size);
return size == baseSize
img
: new MultiResolutionIconImage(baseSize, img);
}
}
return null;
}
開發者ID:AdoptOpenJDK,項⽬名稱:openjdk-jdk10,代碼⾏數:19,
⽰例6: getTexture
點讚 3
import java.awt.image.BufferedImage; //導⼊⽅法依賴的package包/類
@Override
public BufferedImage getTexture(double seed) {
mainColor = new Color(139,69,19);
BufferedImage bi = new BufferedImage(TextureGenerator.TEX_W, TextureGenerator.TEX_H,
BufferedImage.TYPE_4BYTE_ABGR);
Color c;
for(int i = 0;i < bi.getWidth();i++) {
for(int j = 0;j < bi.getHeight();j++) {
c = TextureGenerator.fade(ick(mainColor,-40),Math.d(i-j,32)-16)/16); //strength != 0 && weakStrength != 0 ? trick(mainc,turbulence(i+3.1f,j+3.1f,1,seed)*80) : mainc;
bi.setRGB(i, j, c.getRGB());
}
}
return bi;
}
開發者ID:vanyle,項⽬名稱:Explorium,代碼⾏數:17,
⽰例7: BufferedImageLuminanceSource
點讚 3
import java.awt.image.BufferedImage; //導⼊⽅法依賴的package包/類
public BufferedImageLuminanceSource(BufferedImage image, int left, int top, int width, int height) {
super(width, height);
int sourceWidth = Width();
int sourceHeight = Height();
if (left + width > sourceWidth || top + height > sourceHeight) {
throw new IllegalArgumentException(
"Crop rectangle does not fit within image data.");
}
for (int y = top; y < top + height; y++) {
for (int x = left; x < left + width; x++) {
if ((RGB(x, y) & 0xFF000000) == 0) {
image.setRGB(x, y, 0xFFFFFFFF);// = white
}
}
}
this.image = new BufferedImage(sourceWidth, sourceHeight, BufferedImage.TYPE_BYTE_GRAY);
Graphics().drawImage(image, 0, 0, null);
this.left = left;

}
開發者ID:binarywang,項⽬名稱:qrcode-utils,代碼⾏數:26,
⽰例8: read
點讚 3
import java.awt.image.BufferedImage; //導⼊⽅法依賴的package包/類
protected void read(InputStream in, BufferedImage dst) throws IOException {

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。