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


Java PixelWriter.setArgb方法代码示例

本文整理汇总了Java中javafx.scene.image.PixelWriter.setArgb方法的典型用法代码示例。如果您正苦于以下问题:Java PixelWriter.setArgb方法的具体用法?Java PixelWriter.setArgb怎么用?Java PixelWriter.setArgb使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.image.PixelWriter的用法示例。


在下文中一共展示了PixelWriter.setArgb方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateColorBar

import javafx.scene.image.PixelWriter; //导入方法依赖的package包/类
/** Update color bar in UI from current 'map' */
private void updateColorBar()
{
    // On Mac OS X it was OK to create an image sized 256 x 1:
    // 256 wide to easily set the 256 colors,
    // 1 pixel height which is then stretched via the BackgroundSize().
    // On Linux, the result was garbled unless the image height matched the
    // actual height, so it's now fixed to COLOR_BAR_HEIGHT
    final WritableImage colors = new WritableImage(256, COLOR_BAR_HEIGHT);
    final PixelWriter writer = colors.getPixelWriter();
    for (int x=0; x<256; ++x)
    {
        final int arfb = ColorMappingFunction.getRGB(map.getColor(x));
        for (int y=0; y<COLOR_BAR_HEIGHT; ++y)
            writer.setArgb(x, y, arfb);
    }
    // Stretch image to fill color_bar
    color_bar.setBackground(new Background(
            new BackgroundImage(colors, BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT,
                                BackgroundPosition.DEFAULT,
                                new BackgroundSize(BackgroundSize.AUTO, BackgroundSize.AUTO, true, true, true, true))));
}
 
开发者ID:kasemir,项目名称:org.csstudio.display.builder,代码行数:23,代码来源:ColorMapDialog.java

示例2: copy

import javafx.scene.image.PixelWriter; //导入方法依赖的package包/类
public void copy(float srcX, float srcY, float toX, float toY, float width, float height, boolean reversalX, boolean reversalY) {
	PixelReader reader = srcImage.getPixelReader();
	PixelWriter writer = newImage.getPixelWriter();
	int srcScaleX = (int) srcImage.getWidth();
	int srcScaleY = (int) srcImage.getHeight();
	int newScaleX = (int) newImage.getWidth();
	int newScaleY = (int) newImage.getHeight();
	int srcWidth  = (int) (width * srcScaleX);
	int srcHeight = (int) (height * srcScaleY);
	
	for (int x = 0; x < srcWidth; x++)
		for (int y = 0; y < srcHeight; y++)
			writer.setArgb((int) (toX * newScaleX + x), (int) (toY * newScaleY + y),
					reader.getArgb((int) (srcX * srcScaleX + (reversalX ? srcWidth - x - 1 : x)),
							(int) (srcY * srcScaleY + (reversalY ? srcHeight - y - 1 : y))));
}
 
开发者ID:InfinityStudio,项目名称:minecraft-jfx-skin,代码行数:17,代码来源:SkinHelper.java

示例3: getImage

import javafx.scene.image.PixelWriter; //导入方法依赖的package包/类
@Override
protected Image getImage() {
    WritableImage image = new WritableImage(256, 256);
    PixelWriter pixelWriter = image.getPixelWriter();

    for (int i = 0; i < 256; i++) {
        for (int j = 0; j < 256; j++) {
            int color = i + j;

            pixelWriter.setArgb(i, j,
                    getColorComponentProvider().getARGBColor(
                    ((color > 255) ? 255 : color)));
        }
    }

    return image;
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:18,代码来源:WriteSingleARGBImageTestBase.java

示例4: resampleImage

import javafx.scene.image.PixelWriter; //导入方法依赖的package包/类
/**
 * This method receives an image scales it
 * @param input Input image
 * @param scaleFactor Output scale factor
 * @return The resampled image
 */
public Image resampleImage(Image input, int scaleFactor) {
    int W = (int) input.getWidth();
    int H = (int) input.getHeight();
    WritableImage output = new WritableImage(
            W * scaleFactor,
            H * scaleFactor
    );
    PixelReader reader = input.getPixelReader();
    PixelWriter writer = output.getPixelWriter();
    for (int y = 0; y < H; y++) {
        for (int x = 0; x < W; x++) {
            int argb = reader.getArgb(x, y);
            for (int dy = 0; dy < scaleFactor; dy++) {
                for (int dx = 0; dx < scaleFactor; dx++) {
                    writer.setArgb(x * scaleFactor + dx, y * scaleFactor + dy, argb);
                }
            }
        }
    }
    return output;
}
 
开发者ID:DarkLBP,项目名称:Krothium-Launcher,代码行数:28,代码来源:Kernel.java

示例5: visualize

import javafx.scene.image.PixelWriter; //导入方法依赖的package包/类
/**
 * Visualize the map.
 *
 * @param Maximum
 *            color
 * @param winner
 *            Winners array
 */
public void visualize(int max, int[][] winner) {
   LOG.warn("Producing visualization.");
	// Randomly assign colors for visualization:
	Random r = new Random();
	int[] cols = new int[max + 1];
	for (int i = 1; i < cols.length; i++) {
		cols[i] = r.nextInt(0x1000000) | 0xFF000000;
	}
	try {
		WritableImage writableImage = new WritableImage(viewport.width,
				viewport.height);
		PixelWriter writer = writableImage.getPixelWriter();
		for (int y = 0; y < viewport.height; y++) {
			// Note: visualization is drawn upside down.
			int[] row = winner[viewport.height - 1 - y];
			for (int x = 0; x < viewport.width; x++) {
				writer.setArgb(x, y, cols[row[x]]);
			}
		}
		ImageIO.write(SwingFXUtils.fromFXImage(writableImage, null), "png",
				imfile);
	} catch (IOException e) {
		LOG.error("IO error writing visualization.", e);
	}
}
 
开发者ID:kno10,项目名称:reversegeocode,代码行数:34,代码来源:BuildLayeredIndex.java

示例6: testARGB

import javafx.scene.image.PixelWriter; //导入方法依赖的package包/类
private void testARGB(PixelReader reader, int width, int height) {
    for (int i = 0; i < 10; i++) {
        WritableImage dest = new WritableImage(width, height);
        PixelWriter writer = dest.getPixelWriter();

        for (int x = 0; x < width; x++) {
            for (int y = 0; y < height; y++) {
                // reading a pixel from src image,
                // then writing a pixel to dest image
                //Color color = reader.getColor(x, y);
                //writer.setColor(x, y, color);

                // this way is also OK
                int argb = reader.getArgb(x, y);
                writer.setArgb(x, y, argb);


            }
        }

    }
}
 
开发者ID:amoAHCP,项目名称:JavaOne2015JavaFXPitfalls,代码行数:23,代码来源:PixelWriterTest.java

示例7: enlarge

import javafx.scene.image.PixelWriter; //导入方法依赖的package包/类
public static Image enlarge(Image srcSkin, int multiple) {
	WritableImage newSkin = new WritableImage((int) srcSkin.getWidth() * multiple, (int) srcSkin.getHeight() * multiple);
	PixelReader reader = srcSkin.getPixelReader();
	PixelWriter writer = newSkin.getPixelWriter();
	
	for (int x = 0, lenX = (int) srcSkin.getWidth(); x < lenX; x++)
		for (int y = 0, lenY = (int) srcSkin.getHeight(); y < lenY; y++)
			for (int mx = 0; mx < multiple; mx++)
				for (int my = 0; my < multiple; my++) {
					int argb = reader.getArgb(x, y);
					writer.setArgb(x * multiple + mx, y * multiple + my, argb);
				}
	
	return newSkin;
}
 
开发者ID:InfinityStudio,项目名称:minecraft-jfx-skin,代码行数:16,代码来源:SkinHelper.java

示例8: update

import javafx.scene.image.PixelWriter; //导入方法依赖的package包/类
@Override
public void update(){
    WritableImage wr = new WritableImage(resX, resY);
    PixelWriter pw = wr.getPixelWriter();
    for (int y = 0; y < wr.getWidth(); y++) {
        for (int x = 0; x < wr.getHeight(); x++) {
            pw.setArgb(x, y, input.getData()[(y * resX) + x]);
        }
    }
    this.setImage(wr);
}
 
开发者ID:FloppidyDingo,项目名称:Dingo-Engine,代码行数:12,代码来源:BufferedVideo.java

示例9: copy

import javafx.scene.image.PixelWriter; //导入方法依赖的package包/类
public static void copy(BufferedImage bimg, WritableImage wimg) {
    PixelWriter pw = wimg.getPixelWriter();
    for (int y = 0; y < TESTH; y++) {
        for (int x = 0; x < TESTW; x++) {
            pw.setArgb(x, y, bimg.getRGB(x, y));
        }
    }
}
 
开发者ID:bourgesl,项目名称:marlin-fx,代码行数:9,代码来源:TestNonAARasterization.java

示例10: makeGraphic

import javafx.scene.image.PixelWriter; //导入方法依赖的package包/类
private static Image makeGraphic(double[][][] distortion) {
	WritableImage output = new WritableImage(distortion[0][0].length, distortion[0].length);
	PixelWriter writer = output.getPixelWriter();
	for (int y = 0; y < distortion[0].length; y ++) {
		for (int x = 0; x < distortion[0][y].length; x ++) {
			final double sizeDistort = distortion[0][y][x], shapeDistort = distortion[1][y][x];
			final double sizeContour = Math.round(sizeDistort/(LN_10/10))*LN_10/10; //contour the size by decibels
			final double shapeContour = Math.round(shapeDistort/(LN_10/20))*LN_10/20; //contour the size by semidecibels
			if (Double.isNaN(sizeDistort) || Double.isNaN(shapeDistort)) {
				writer.setArgb(x, y, 0);
				continue;
			}
			
			final int r, g, b;
			if (sizeDistort < 0) { //if compressing
				r = (int)(255.9*Math.exp(-shapeContour*.6));
				g = (int)(255.9*Math.exp(-shapeContour*.6)*Math.exp(sizeContour*.6));
				b = g;
			}
			else { //if dilating
				r = (int)(255.9*Math.exp(-shapeContour*.6)*Math.exp(-sizeContour*.6));
				g = r; //I find .6 to be a rather visually pleasing sensitivity
				b = (int)(255.9*Math.exp(-shapeContour*.6));
			}
			
			final int argb = ((((((0xFF)<<8)+r)<<8)+g)<<8)+b;
			writer.setArgb(x, y, argb);
		}
	}
	return output;
}
 
开发者ID:jkunimune15,项目名称:Map-Projections,代码行数:32,代码来源:MapAnalyzer.java

示例11: visualize

import javafx.scene.image.PixelWriter; //导入方法依赖的package包/类
/**
 * Visualize the map.
 *
 * @param Maximum color
 * @param Comp Compressed winners array
 */
public void visualize(int max, byte[][] comp) {
  LOG.warn("Producing visualization.");
  // Randomly assign colors for visualization:
  Random r = new Random();
  int[] cols = new int[max + 1];
  for(int i = 1; i < cols.length; i++) {
    cols[i] = r.nextInt(0x1000000) | 0xFF000000;
  }
  int[] pos = { 0 };
  try {
    WritableImage writableImage = new WritableImage(gviewport.width, gviewport.height);
    PixelWriter writer = writableImage.getPixelWriter();
    for(int y = 0; y < gviewport.height; y++) {
      // Note: visualization is drawn upside down.
      byte[] row = comp[gviewport.height - 1 - y];
      pos[0] = 0;
      for(int x = 0; x < gviewport.width && pos[0] < row.length;) {
        int col = readUnsignedVarint(row, pos);
        int cnt = readUnsignedVarint(row, pos) + 1;
        if(col >= 0) {
          for(int i = 0; i < cnt; i++, x++) {
            writer.setArgb(x, y, cols[col]);
          }
        }
        else {
          x += cnt;
        }
      }
    }
    ImageIO.write(SwingFXUtils.fromFXImage(writableImage, null), "png", imfile);
  }
  catch(IOException e) {
    LOG.error("IO error writing visualization.", e);
  }
}
 
开发者ID:kno10,项目名称:reversegeocode,代码行数:42,代码来源:BuildLayeredIndexSliced.java

示例12: testAAAWarmup

import javafx.scene.image.PixelWriter; //导入方法依赖的package包/类
@Test
public void testAAAWarmup() {
    Image src = new Image("file:/Users/amo/Pictures/April_Mai/DSCF5453.jpg");
    PixelReader reader = src.getPixelReader();

    int width = (int) src.getWidth();
    int height = (int) src.getHeight();

    long startTime = System.currentTimeMillis();
    for (int i = 0; i < 2; i++) {
        WritableImage dest = new WritableImage(width, height);
        PixelWriter writer = dest.getPixelWriter();

        for (int x = 0; x < width; x++) {
            for (int y = 0; y < height; y++) {
                // reading a pixel from src image,
                // then writing a pixel to dest image
                Color color = reader.getColor(x, y);
                writer.setColor(x, y, color);

                // this way is also OK
                int argb = reader.getArgb(x, y);
                writer.setArgb(x, y, argb);
            }
        }

    }


}
 
开发者ID:amoAHCP,项目名称:JavaOne2015JavaFXPitfalls,代码行数:31,代码来源:PixelWriterTest.java

示例13: copyImage

import javafx.scene.image.PixelWriter; //导入方法依赖的package包/类
public Image copyImage(PixelReader reader, int imageWidth, int imageHeight, int offsetX, int offsetY) {
	WritableImage dest = new WritableImage(imageWidth, imageHeight);
	PixelWriter writer = dest.getPixelWriter();
	for (int x = 0; x < imageWidth; x++) {
		for (int y = 0; y < imageHeight; y++) {
			// reading a pixel from src image,
			// then writing a pixel to dest image
			int col = reader.getArgb(x + offsetX, y + offsetY);
			writer.setArgb(x, y, col);
		}
	}
	return dest;
}
 
开发者ID:rfrerich,项目名称:hex4j,代码行数:14,代码来源:TileMapImages.java

示例14: onButtonLoadProjClick

import javafx.scene.image.PixelWriter; //导入方法依赖的package包/类
/**
 * 加载工程文件
 *
 * @param actionEvent
 * @throws ClassNotFoundException
 */
public void onButtonLoadProjClick(ActionEvent actionEvent) throws ClassNotFoundException {
    FileChooser fileChooser = new FileChooser();
    fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("PhotoScrip file -- PSG (*.psg)", "*.psg"));
    File file = fileChooser.showOpenDialog(this.stage);
    ProjectSaver tempObj;
    int tempNum;
    if (file != null) {
        try {
            ObjectInputStream objIn = new ObjectInputStream(new FileInputStream(file));
            mainPane.getChildren().remove(1, mainPane.getChildren().size());
            for (int i = objIn.readInt(); i > 1; i--) {
                tempNum = objIn.readInt();
                switch (tempNum) {
                    case IMAGE:
                        tempObj = (ProjectSaver) objIn.readObject();
                        ImageBox imageBox = tempObj.constructImage();
                        int[] buffer = (int[]) objIn.readObject();
                        int k = 0;
                        int tempW = buffer[k++];
                        int tempH = buffer[k++];
                        WritableImage wImage = new WritableImage(tempW, tempH);
                        PixelWriter pixelWriter = wImage.getPixelWriter();
                        for (int x = 0; x < tempW; x++) {
                            for (int y = 0; y < tempH; y++) {
                                pixelWriter.setArgb(x, y, buffer[k++]);
                            }
                        }
                        imageBox.setContentNode(new ImageView(), (node, Parent) -> {
                            ((ImageView) node).setImage(wImage);
                            ((ImageView) node).xProperty().set(10);
                            ((ImageView) node).yProperty().set(10);
                            ((ImageView) node).fitWidthProperty().bind(Parent.widthProperty().subtract(20));
                            ((ImageView) node).fitHeightProperty().bind(Parent.heightProperty().subtract(20));
                            mainPane.getChildren().add(Parent);
                            mainPane.setChooseListener(Parent);
                        });
                        break;
                    case NORMAL:
                        tempObj = (ProjectSaver) objIn.readObject();
                        DragBox dragBox = tempObj.construtDragBox();
                        Color fill = new Color(tempObj.fr, tempObj.fg, tempObj.fb, tempObj.fa);
                        Color stroke = new Color(tempObj.r, tempObj.g, tempObj.b, tempObj.a);
                        switch (tempObj.getType()) {
                            case ELLIPSE:
                                circle(dragBox, tempObj.strokeWidth, tempObj.rotate, fill, stroke);
                                break;
                            case RECT:
                                rectangle(dragBox, tempObj.strokeWidth, tempObj.rotate, fill, stroke);
                                break;
                            case SVG:
                                svg(dragBox, tempObj.svgPath, fill, stroke, tempObj.strokeWidth, tempObj.rotate);
                                break;
                            case TEXT:
                                text(dragBox, new Font(tempObj.fontFamily, tempObj.fontSize), tempObj.getText(),
                                        fill, stroke, tempObj.w, tempObj.strokeWidth, tempObj.rotate);
                                break;
                            case LINE:
                                DragBoxWithLine dragBoxWithLine = tempObj.construtLineDragBox();
                                line(dragBoxWithLine, tempObj.x, tempObj.y, tempObj.xStart, tempObj.yStart,
                                        tempObj.xEnd, tempObj.yEnd, stroke, tempObj.strokeWidth);
                                break;

                        }
                        break;
                }
            }
            mainPane.chooseNothing();
            objIn.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
 
开发者ID:xfangfang,项目名称:PhotoScript,代码行数:81,代码来源:Controller.java

示例15: renderScanline

import javafx.scene.image.PixelWriter; //导入方法依赖的package包/类
private void renderScanline(WritableImage screen, int y) {
        int p = 0;
        if (rowStart != 0) {
//            getCurrentWriter().markDirty(y);
            p = rowStart * 28;
            if (rowStart < 0) {
                return;
            }
        }
        PixelWriter writer = screen.getPixelWriter();
        // Reset scanline position
        int byteCounter = 0;
        for (int s = rowStart; s < 20; s++) {
            int add = 0;
            int bits;
            if (hiresMode) {
                bits = scanline[s] << 2;
                if (s > 0) {
                    bits |= (scanline[s - 1] >> 26) & 3;
                }
            } else {
                bits = scanline[s] << 3;
                if (s > 0) {
                    bits |= (scanline[s - 1] >> 25) & 7;
                }
            }
            if (s < 19) {
                add = (scanline[s + 1] & 7);
            }
            boolean isBW = false;
            boolean mixed = enableVideo7 && dhgrMode && graphicsMode == rgbMode.MIX;
            for (int i = 0; i < 28; i++) {
                if (i % 7 == 0) {
                    isBW = monochomeMode || !colorActive[byteCounter] || (mixed && !hiresMode && !useColor[byteCounter]);
                    byteCounter++;
                }
                if (isBW) {
                    writer.setColor(p++, y, ((bits & 0x8) == 0) ? BLACK : WHITE);
                } else {
                    writer.setArgb(p++, y, activePalette[i % 4][bits & 0x07f]);
                }
                bits >>= 1;
                if (i == 20) {
                    bits |= add << (hiresMode ? 9 : 10);
                }
            }
//                    } else {
//                        for (int i = 0; i < 28; i++) {
//                            writer.setArgb(p++, y, activePalette[i % 4][bits & 0x07f]);
//                            bits >>= 1;
//                            if (i == 20) {
//                                bits |= add << (hiresMode ? 9 : 10);
//                            }
//                        }
//                    }
        }
        Arrays.fill(scanline, 0);
        rowStart = -1;
    }
 
开发者ID:badvision,项目名称:jace,代码行数:60,代码来源:VideoNTSC.java


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