java.awt.Canvas.createImage()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(242)

本文整理了Java中java.awt.Canvas.createImage()方法的一些代码示例,展示了Canvas.createImage()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Canvas.createImage()方法的具体详情如下:
包路径:java.awt.Canvas
类名称:Canvas
方法名:createImage

Canvas.createImage介绍

暂无

代码示例

代码示例来源:origin: com.itextpdf/itextpdf

  1. java.awt.Image img = canvas.createImage(new java.awt.image.MemoryImageSource(w, h, pix, 0, w));
  2. return img;

代码示例来源:origin: itext/itext7

  1. /**
  2. * Creates a <CODE>java.awt.Image</CODE>. A successful call to the method <CODE>generate()</CODE>
  3. * before calling this method is required.
  4. *
  5. * @param foreground the color of the bars
  6. * @param background the color of the background
  7. * @return the image
  8. */
  9. public java.awt.Image createAwtImage(java.awt.Color foreground, java.awt.Color background) {
  10. if (image == null)
  11. return null;
  12. int f = foreground.getRGB();
  13. int g = background.getRGB();
  14. java.awt.Canvas canvas = new java.awt.Canvas();
  15. int w = width + 2 * ws;
  16. int h = height + 2 * ws;
  17. int[] pix = new int[w * h];
  18. int stride = (w + 7) / 8;
  19. int ptr = 0;
  20. for (int k = 0; k < h; ++k) {
  21. int p = k * stride;
  22. for (int j = 0; j < w; ++j) {
  23. int b = image[p + j / 8] & 0xff;
  24. b <<= j % 8;
  25. pix[ptr++] = (b & 0x80) == 0 ? g : f;
  26. }
  27. }
  28. java.awt.Image img = canvas.createImage(new java.awt.image.MemoryImageSource(w, h, pix, 0, w));
  29. return img;
  30. }

代码示例来源:origin: es.gob.afirma/afirma-crypto-pdf-itext

  1. /**
  2. * Creates a <CODE>java.awt.Image</CODE>. A successful call to the method <CODE>generate()</CODE>
  3. * before calling this method is required.
  4. * @param foreground the color of the bars
  5. * @param background the color of the background
  6. * @return the image
  7. */
  8. public java.awt.Image createAwtImage(Color foreground, Color background) {
  9. if (image == null)
  10. return null;
  11. int f = foreground.getRGB();
  12. int g = background.getRGB();
  13. Canvas canvas = new Canvas();
  14. int w = width + 2 * ws;
  15. int h = height + 2 * ws;
  16. int pix[] = new int[w * h];
  17. int stride = (w + 7) / 8;
  18. int ptr = 0;
  19. for (int k = 0; k < h; ++k) {
  20. int p = k * stride;
  21. for (int j = 0; j < w; ++j) {
  22. int b = image[p + (j / 8)] & 0xff;
  23. b <<= j % 8;
  24. pix[ptr++] = (b & 0x80) == 0 ? g : f;
  25. }
  26. }
  27. java.awt.Image img = canvas.createImage(new MemoryImageSource(w, h, pix, 0, w));
  28. return img;
  29. }

代码示例来源:origin: com.github.librepdf/openpdf

  1. /**
  2. * Creates a <CODE>java.awt.Image</CODE>. A successful call to the method <CODE>generate()</CODE>
  3. * before calling this method is required.
  4. * @param foreground the color of the bars
  5. * @param background the color of the background
  6. * @return the image
  7. */
  8. public java.awt.Image createAwtImage(Color foreground, Color background) {
  9. if (image == null)
  10. return null;
  11. int f = foreground.getRGB();
  12. int g = background.getRGB();
  13. Canvas canvas = new Canvas();
  14. int w = width + 2 * ws;
  15. int h = height + 2 * ws;
  16. int[] pix = new int[w * h];
  17. int stride = (w + 7) / 8;
  18. int ptr = 0;
  19. for (int k = 0; k < h; ++k) {
  20. int p = k * stride;
  21. for (int j = 0; j < w; ++j) {
  22. int b = image[p + (j / 8)] & 0xff;
  23. b <<= j % 8;
  24. pix[ptr++] = (b & 0x80) == 0 ? g : f;
  25. }
  26. }
  27. java.awt.Image img = canvas.createImage(new MemoryImageSource(w, h, pix, 0, w));
  28. return img;
  29. }

代码示例来源:origin: com.itextpdf/itextpdf

  1. java.awt.Image img = canvas.createImage(new java.awt.image.MemoryImageSource(bitColumns, codeRows * h, pix, 0, bitColumns));
  2. return img;

代码示例来源:origin: es.gob.afirma/afirma-crypto-pdf-itext

  1. java.awt.Image img = canvas.createImage(new MemoryImageSource(bitColumns, codeRows * h, pix, 0, bitColumns));
  2. return img;

代码示例来源:origin: itext/itext7

  1. java.awt.Image img = canvas.createImage(new java.awt.image.MemoryImageSource(bitColumns, codeRows * h, pix, 0, bitColumns));
  2. return img;

代码示例来源:origin: com.github.librepdf/openpdf

  1. java.awt.Image img = canvas.createImage(new MemoryImageSource(bitColumns, codeRows * h, pix, 0, bitColumns));
  2. return img;

代码示例来源:origin: itext/itext7

  1. /**
  2. * Creates a <CODE>java.awt.Image</CODE>. This image only
  3. * contains the bars without any text.
  4. *
  5. * @param foreground the color of the bars
  6. * @param background the color of the background
  7. * @return the image
  8. */
  9. @Override
  10. public Image createAwtImage(java.awt.Color foreground, java.awt.Color background) {
  11. int foregroundColor = (foreground == null) ? DEFAULT_BAR_FOREGROUND_COLOR.getRGB() : foreground.getRGB();
  12. int backgroundColor = (background == null) ? DEFAULT_BAR_BACKGROUND_COLOR.getRGB() : background.getRGB();
  13. java.awt.Canvas canvas = new java.awt.Canvas();
  14. String bCode = this.code;
  15. if (this.generateChecksum) {
  16. bCode = bCode + Integer.toString(getChecksum(this.code));
  17. }
  18. byte[] bars = getBarsMSI(bCode);
  19. int fullWidth = bars.length;
  20. int fullHeight = (int) this.barHeight;
  21. int[] pix = new int[fullWidth * fullHeight];
  22. for (int x = 0; x < bars.length; x++) {
  23. int color = (bars[x] == 1 ? foregroundColor : backgroundColor);
  24. for (int y = 0; y < fullHeight; y++) {
  25. int currentPixel = x + (y * fullWidth);
  26. pix[currentPixel] = color;
  27. }
  28. }
  29. return canvas.createImage(new java.awt.image.MemoryImageSource(fullWidth, fullHeight, pix, 0, fullWidth));
  30. }

代码示例来源:origin: itext/itext7

  1. System.arraycopy(pix, 0, pix, k, fullWidth);
  2. return canvas.createImage(new java.awt.image.MemoryImageSource(fullWidth, height, pix, 0, fullWidth));

代码示例来源:origin: itext/itext7

  1. System.arraycopy(pix, 0, pix, k, fullWidth);
  2. return canvas.createImage(new java.awt.image.MemoryImageSource(fullWidth, height, pix, 0, fullWidth));

代码示例来源:origin: com.itextpdf/itextpdf

  1. System.arraycopy(pix, 0, pix, k, fullWidth);
  2. java.awt.Image img = canvas.createImage(new java.awt.image.MemoryImageSource(fullWidth, height, pix, 0, fullWidth));

代码示例来源:origin: com.itextpdf/itextpdf

  1. /** Creates a <CODE>java.awt.Image</CODE>.
  2. * @param foreground the color of the bars
  3. * @param background the color of the background
  4. * @return the image
  5. */
  6. public java.awt.Image createAwtImage(java.awt.Color foreground, java.awt.Color background) {
  7. int f = foreground.getRGB();
  8. int g = background.getRGB();
  9. java.awt.Canvas canvas = new java.awt.Canvas();
  10. int width = bm.getWidth();
  11. int height = bm.getHeight();
  12. int pix[] = new int[width * height];
  13. byte[][] mt = bm.getArray();
  14. for (int y = 0; y < height; ++y) {
  15. byte[] line = mt[y];
  16. for (int x = 0; x < width; ++x) {
  17. pix[y * width + x] = line[x] == 0 ? f : g;
  18. }
  19. }
  20. java.awt.Image img = canvas.createImage(new java.awt.image.MemoryImageSource(width, height, pix, 0, width));
  21. return img;
  22. }

代码示例来源:origin: com.github.librepdf/openpdf

  1. System.arraycopy(pix, 0, pix, k, fullWidth);
  2. Image img = canvas.createImage(new MemoryImageSource(fullWidth, height, pix, 0, fullWidth));

代码示例来源:origin: es.gob.afirma/afirma-crypto-pdf-itext

  1. System.arraycopy(pix, 0, pix, k, fullWidth);
  2. Image img = canvas.createImage(new MemoryImageSource(fullWidth, height, pix, 0, fullWidth));

代码示例来源:origin: com.github.librepdf/openpdf

  1. System.arraycopy(pix, 0, pix, k, fullWidth);
  2. Image img = canvas.createImage(new MemoryImageSource(fullWidth, height, pix, 0, fullWidth));

代码示例来源:origin: com.itextpdf/itextpdf

  1. System.arraycopy(pix, 0, pix, k, fullWidth);
  2. java.awt.Image img = canvas.createImage(new java.awt.image.MemoryImageSource(fullWidth, height, pix, 0, fullWidth));

代码示例来源:origin: itext/itext7

  1. /**
  2. * Creates a <CODE>java.awt.Image</CODE>.
  3. *
  4. * @param foreground the color of the bars
  5. * @param background the color of the background
  6. * @return the image
  7. */
  8. public java.awt.Image createAwtImage(java.awt.Color foreground, java.awt.Color background) {
  9. int f = foreground.getRGB();
  10. int g = background.getRGB();
  11. java.awt.Canvas canvas = new java.awt.Canvas();
  12. int width = bm.getWidth();
  13. int height = bm.getHeight();
  14. int[] pix = new int[width * height];
  15. byte[][] mt = bm.getArray();
  16. for (int y = 0; y < height; ++y) {
  17. byte[] line = mt[y];
  18. for (int x = 0; x < width; ++x) {
  19. pix[y * width + x] = line[x] == 0 ? f : g;
  20. }
  21. }
  22. java.awt.Image img = canvas.createImage(new java.awt.image.MemoryImageSource(width, height, pix, 0, width));
  23. return img;
  24. }

代码示例来源:origin: com.itextpdf/itextpdf

  1. System.arraycopy(pix, 0, pix, k, fullWidth);
  2. java.awt.Image img = canvas.createImage(new java.awt.image.MemoryImageSource(fullWidth, height, pix, 0, fullWidth));

代码示例来源:origin: es.gob.afirma/afirma-crypto-pdf-itext

  1. System.arraycopy(pix, 0, pix, k, fullWidth);
  2. Image img = canvas.createImage(new MemoryImageSource(fullWidth, height, pix, 0, fullWidth));

相关文章