private void setRGB(final WritableImage IMAGE, final int X, final int Y, final int[] PIXELS) {
   final PixelWriter RASTER = IMAGE.getPixelWriter();
   for (int x = 0; x < PIXELS.length; x++) {
     RASTER.setColor(
         X + x,
         Y,
         Color.rgb((PIXELS[x] >> 16) & 0xFF, (PIXELS[x] >> 8) & 0xFF, (PIXELS[x] & 0xFF)));
   }
 }
示例#2
0
文件: VideoDHGR.java 项目: gdos/jace
 protected void displayDoubleLores(WritableImage screen, int xOffset, int y, int rowAddress) {
   int c1 =
       ((RAM128k) computer.getMemory()).getAuxVideoMemory().readByte(rowAddress + xOffset) & 0x0FF;
   int c2 =
       ((RAM128k) computer.getMemory()).getMainMemory().readByte(rowAddress + xOffset) & 0x0FF;
   if ((y & 7) < 4) {
     c1 &= 15;
     c2 &= 15;
   } else {
     c1 >>= 4;
     c2 >>= 4;
   }
   PixelWriter writer = screen.getPixelWriter();
   //        int yOffset = xyOffset[y][times14[xOffset]];
   Color color = Palette.color[c1];
   // Unrolled loop, faster
   int xx = xOffset * 7;
   writer.setColor(xx++, y, color);
   writer.setColor(xx++, y, color);
   writer.setColor(xx++, y, color);
   writer.setColor(xx++, y, color);
   writer.setColor(xx++, y, color);
   writer.setColor(xx++, y, color);
   writer.setColor(xx++, y, color);
   color = Palette.color[c2];
   writer.setColor(xx++, y, color);
   writer.setColor(xx++, y, color);
   writer.setColor(xx++, y, color);
   writer.setColor(xx++, y, color);
   writer.setColor(xx++, y, color);
   writer.setColor(xx++, y, color);
   writer.setColor(xx++, y, color);
 }
示例#3
0
文件: VideoDHGR.java 项目: gdos/jace
 protected void displayLores(WritableImage screen, int xOffset, int y, int rowAddress) {
   int c1 =
       ((RAM128k) computer.getMemory()).getMainMemory().readByte(rowAddress + xOffset) & 0x0FF;
   if ((y & 7) < 4) {
     c1 &= 15;
   } else {
     c1 >>= 4;
   }
   Color color = Palette.color[c1];
   // Unrolled loop, faster
   PixelWriter writer = screen.getPixelWriter();
   int xx = xOffset * 7;
   writer.setColor(xx++, y, color);
   writer.setColor(xx++, y, color);
   writer.setColor(xx++, y, color);
   writer.setColor(xx++, y, color);
   writer.setColor(xx++, y, color);
   writer.setColor(xx++, y, color);
   writer.setColor(xx++, y, color);
   writer.setColor(xx++, y, color);
   writer.setColor(xx++, y, color);
   writer.setColor(xx++, y, color);
   writer.setColor(xx++, y, color);
   writer.setColor(xx++, y, color);
   writer.setColor(xx++, y, color);
   writer.setColor(xx++, y, color);
 }
示例#4
0
文件: VideoDHGR.java 项目: gdos/jace
  protected void showBW(WritableImage screen, int xOffset, int y, int dhgrWord) {
    // Using the data buffer directly is about 15 times faster than setRGB
    // This is because setRGB does extra (useless) color model logic
    // For that matter even Graphics.drawLine is faster than setRGB!
    // This is equivilant to y*560 but is 5% faster
    // Also, adding xOffset now makes it additionally 5% faster
    // int yOffset = ((y << 4) + (y << 5) + (y << 9))+xOffset;

    int xx = xOffset * 7;
    PixelWriter writer = screen.getPixelWriter();
    for (int i = 0; i < 28; i++) {
      // yOffset++ is used instead of yOffset+i, because it is faster
      writer.setColor(xx++, y, (dhgrWord & 1) == 1 ? WHITE : BLACK);
      dhgrWord >>= 1;
    }
  }
示例#5
0
文件: VideoDHGR.java 项目: gdos/jace
 protected void showDhgr(WritableImage screen, int xOffset, int y, int dhgrWord) {
   // Graphics2D g = (Graphics2D) screen.getGraphics();
   int xx = xOffset * 7;
   PixelWriter writer = screen.getPixelWriter();
   try {
     for (int i = 0; i < 7; i++) {
       Color color = Palette.color[FLIP_NYBBLE[dhgrWord & 15]];
       writer.setColor(xx++, y, color);
       writer.setColor(xx++, y, color);
       writer.setColor(xx++, y, color);
       writer.setColor(xx++, y, color);
       dhgrWord >>= 4;
     }
   } catch (ArrayIndexOutOfBoundsException ex) {
     Logger.getLogger(getClass().getName()).warning("Went out of bounds in video display");
   }
 }
  /*
   * Write Image to byteArray
   */
  private WritableImage bufferedToWriteable(byte[] byteArray) {
    BufferedImage bf;

    try {
      bf = ImageIO.read(new ByteArrayInputStream(byteArray));
      WritableImage wr = null;
      if (bf != null) {
        wr = new WritableImage(bf.getWidth(), bf.getHeight());
        PixelWriter pw = wr.getPixelWriter();
        for (int x = 0; x < bf.getWidth(); x++) {
          for (int y = 0; y < bf.getHeight(); y++) {
            pw.setArgb(x, y, bf.getRGB(x, y));
          }
        }
      }
      return wr;
    } catch (IOException e) {
      e.printStackTrace();
    }
    return null;
  }
示例#7
0
文件: Filters.java 项目: Vortif/ps
 private static void writePixels(
     PixelWriter pixelWriter,
     double[][] matrixR,
     double[][] matrixB,
     double[][] matrixG,
     int height,
     int width) {
   for (int i = 0; i < width; i++) {
     for (int j = 0; j < height; j++) {
       pixelWriter.setColor(i, j, Color.color(imgR[i][j], (imgG[i][j]), ((imgB[i][j]))));
     }
   }
 }