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


Java Canvas.createImage方法代码示例

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


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

示例1: createAwtImage

import java.awt.Canvas; //导入方法依赖的package包/类
/**
 * Creates a <CODE>java.awt.Image</CODE>. A successful call to the method <CODE>generate()</CODE>
 * before calling this method is required.
 * @param foreground the color of the bars
 * @param background the color of the background
 * @return the image
 */    
public java.awt.Image createAwtImage(Color foreground, Color background) {
    if (image == null)
        return null;
    int f = foreground.getRGB();
    int g = background.getRGB();
    Canvas canvas = new Canvas();

    int w = width + 2 * ws;
    int h = height + 2 * ws;
    int pix[] = new int[w * h];
    int stride = (w + 7) / 8;
    int ptr = 0;
    for (int k = 0; k < h; ++k) {
        int p = k * stride;
        for (int j = 0; j < w; ++j) {
            int b = image[p + (j / 8)] & 0xff;
            b <<= j % 8;
            pix[ptr++] = (b & 0x80) == 0 ? g : f;
        }
    }
    java.awt.Image img = canvas.createImage(new MemoryImageSource(w, h, pix, 0, w));
    return img;
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:31,代码来源:BarcodeDatamatrix.java

示例2: createAwtImage

import java.awt.Canvas; //导入方法依赖的package包/类
/** Creates a <CODE>java.awt.Image</CODE>.
 * @param foreground the color of the bars
 * @param background the color of the background
 * @return the image
 */    
public java.awt.Image createAwtImage(Color foreground, Color background) {
    int f = foreground.getRGB();
    int g = background.getRGB();
    Canvas canvas = new Canvas();

    paintCode();
    int h = (int)yHeight;
    int pix[] = new int[bitColumns * codeRows * h];
    int stride = (bitColumns + 7) / 8;
    int ptr = 0;
    for (int k = 0; k < codeRows; ++k) {
        int p = k * stride;
        for (int j = 0; j < bitColumns; ++j) {
            int b = outBits[p + (j / 8)] & 0xff;
            b <<= j % 8;
            pix[ptr++] = (b & 0x80) == 0 ? g : f;
        }
        for (int j = 1; j < h; ++j) {
            System.arraycopy(pix, ptr - bitColumns, pix, ptr + bitColumns * (j - 1), bitColumns);
        }
        ptr += bitColumns * (h - 1);
    }
    
    java.awt.Image img = canvas.createImage(new MemoryImageSource(bitColumns, codeRows * h, pix, 0, bitColumns));
    return img;
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:32,代码来源:BarcodePDF417.java

示例3: createAwtImage

import java.awt.Canvas; //导入方法依赖的package包/类
/** Creates a <CODE>java.awt.Image</CODE>. This image only
 * contains the bars without any text.
 * @param foreground the color of the bars
 * @param background the color of the background
 * @return the image
 */    
public java.awt.Image createAwtImage(Color foreground, Color background) {
    int f = foreground.getRGB();
    int g = background.getRGB();
    Canvas canvas = new Canvas();

    String bCode = keepNumbers(code);
    if (generateChecksum)
        bCode += getChecksum(bCode);
    int len = bCode.length();
    int nn = (int)n;
    int fullWidth = len * (3 + 2 * nn) + (6 + nn );
    byte bars[] = getBarsInter25(bCode);
    boolean print = true;
    int ptr = 0;
    int height = (int)barHeight;
    int pix[] = new int[fullWidth * height];
    for (int k = 0; k < bars.length; ++k) {
        int w = (bars[k] == 0 ? 1 : nn);
        int c = g;
        if (print)
            c = f;
        print = !print;
        for (int j = 0; j < w; ++j)
            pix[ptr++] = c;
    }
    for (int k = fullWidth; k < pix.length; k += fullWidth) {
        System.arraycopy(pix, 0, pix, k, fullWidth); 
    }
    Image img = canvas.createImage(new MemoryImageSource(fullWidth, height, pix, 0, fullWidth));
    
    return img;
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:39,代码来源:BarcodeInter25.java

示例4: createAwtImage

import java.awt.Canvas; //导入方法依赖的package包/类
/** Creates a <CODE>java.awt.Image</CODE>. This image only
 * contains the bars without any text.
 * @param foreground the color of the bars
 * @param background the color of the background
 * @return the image
 */    
public java.awt.Image createAwtImage(Color foreground, Color background) {
    int f = foreground.getRGB();
    int g = background.getRGB();
    Canvas canvas = new Canvas();
    String bCode;
    if (codeType == CODE128_RAW) {
        int idx = code.indexOf('\uffff');
        if (idx >= 0)
            bCode = code.substring(0, idx);
        else
            bCode = code;
    }
    else {
        bCode = getRawText(code, codeType == CODE128_UCC);
    }
    int len = bCode.length();
    int fullWidth = (len + 2) * 11 + 2;
    byte bars[] = getBarsCode128Raw(bCode);
    
    boolean print = true;
    int ptr = 0;
    int height = (int)barHeight;
    int pix[] = new int[fullWidth * height];
    for (int k = 0; k < bars.length; ++k) {
        int w = bars[k];
        int c = g;
        if (print)
            c = f;
        print = !print;
        for (int j = 0; j < w; ++j)
            pix[ptr++] = c;
    }
    for (int k = fullWidth; k < pix.length; k += fullWidth) {
        System.arraycopy(pix, 0, pix, k, fullWidth); 
    }
    Image img = canvas.createImage(new MemoryImageSource(fullWidth, height, pix, 0, fullWidth));
    
    return img;
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:46,代码来源:Barcode128.java

示例5: createAwtImage

import java.awt.Canvas; //导入方法依赖的package包/类
/** Creates a <CODE>java.awt.Image</CODE>. This image only
 * contains the bars without any text.
 * @param foreground the color of the bars
 * @param background the color of the background
 * @return the image
 */    
public java.awt.Image createAwtImage(Color foreground, Color background) {
    int f = foreground.getRGB();
    int g = background.getRGB();
    Canvas canvas = new Canvas();

    String bCode = code;
    if (extended)
        bCode = getCode39Ex(code);
    if (generateChecksum)
        bCode += getChecksum(bCode);
    int len = bCode.length() + 2;
    int nn = (int)n;
    int fullWidth = len * (6 + 3 * nn) + (len - 1);
    byte bars[] = getBarsCode39(bCode);
    boolean print = true;
    int ptr = 0;
    int height = (int)barHeight;
    int pix[] = new int[fullWidth * height];
    for (int k = 0; k < bars.length; ++k) {
        int w = (bars[k] == 0 ? 1 : nn);
        int c = g;
        if (print)
            c = f;
        print = !print;
        for (int j = 0; j < w; ++j)
            pix[ptr++] = c;
    }
    for (int k = fullWidth; k < pix.length; k += fullWidth) {
        System.arraycopy(pix, 0, pix, k, fullWidth); 
    }
    Image img = canvas.createImage(new MemoryImageSource(fullWidth, height, pix, 0, fullWidth));
    
    return img;
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:41,代码来源:Barcode39.java

示例6: createAwtImage

import java.awt.Canvas; //导入方法依赖的package包/类
/** Creates a <CODE>java.awt.Image</CODE>. This image only
 * contains the bars without any text.
 * @param foreground the color of the bars
 * @param background the color of the background
 * @return the image
 */    
public java.awt.Image createAwtImage(Color foreground, Color background) {
    int f = foreground.getRGB();
    int g = background.getRGB();
    Canvas canvas = new Canvas();

    String fullCode = code;
    if (generateChecksum && checksumText)
        fullCode = calculateChecksum(code);
    if (!startStopText)
        fullCode = fullCode.substring(1, fullCode.length() - 1);
    byte bars[] = getBarsCodabar(generateChecksum ? calculateChecksum(code) : code);
    int wide = 0;
    for (int k = 0; k < bars.length; ++k) {
        wide += bars[k];
    }
    int narrow = bars.length - wide;
    int fullWidth = narrow + wide * (int)n;
    boolean print = true;
    int ptr = 0;
    int height = (int)barHeight;
    int pix[] = new int[fullWidth * height];
    for (int k = 0; k < bars.length; ++k) {
        int w = (bars[k] == 0 ? 1 : (int)n);
        int c = g;
        if (print)
            c = f;
        print = !print;
        for (int j = 0; j < w; ++j)
            pix[ptr++] = c;
    }
    for (int k = fullWidth; k < pix.length; k += fullWidth) {
        System.arraycopy(pix, 0, pix, k, fullWidth); 
    }
    Image img = canvas.createImage(new MemoryImageSource(fullWidth, height, pix, 0, fullWidth));
    
    return img;
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:44,代码来源:BarcodeCodabar.java

示例7: makeImage

import java.awt.Canvas; //导入方法依赖的package包/类
public Image makeImage(TestEnvironment env, int w, int h) {
    Canvas c = env.getCanvas();
    return c.createImage(w, h);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:ImageTests.java

示例8: createAwtImage

import java.awt.Canvas; //导入方法依赖的package包/类
/** Creates a <CODE>java.awt.Image</CODE>. This image only
 * contains the bars without any text.
 * @param foreground the color of the bars
 * @param background the color of the background
 * @return the image
 *
 */
public java.awt.Image createAwtImage(Color foreground, Color background) {
    int f = foreground.getRGB();
    int g = background.getRGB();
    Canvas canvas = new Canvas();
    int barWidth = (int)x;
    if (barWidth <= 0)
        barWidth = 1;
    int barDistance = (int)n;
    if (barDistance <= barWidth)
        barDistance = barWidth + 1;
    int barShort = (int)size;
    if (barShort <= 0)
        barShort = 1;
    int barTall = (int)barHeight;
    if (barTall <= barShort)
        barTall = barShort + 1;
    int width = ((code.length() + 1) * 5 + 1) * barDistance + barWidth;
    int pix[] = new int[width * barTall];
    byte bars[] = getBarsPostnet(code);
    byte flip = 1;
    if (codeType == PLANET) {
        flip = 0;
        bars[0] = 0;
        bars[bars.length - 1] = 0;
    }
    int idx = 0;
    for (int k = 0; k < bars.length; ++k) {
        boolean dot = (bars[k] == flip);
        for (int j = 0; j < barDistance; ++j) {
            pix[idx + j] = ((dot && j < barWidth) ? f : g);
        }
        idx += barDistance;
    }
    int limit = width * (barTall - barShort);
    for (int k = width; k < limit; k += width)
        System.arraycopy(pix, 0, pix, k, width);
    idx = limit;
    for (int k = 0; k < bars.length; ++k) {
        for (int j = 0; j < barDistance; ++j) {
            pix[idx + j] = ((j < barWidth) ? f : g);
        }
        idx += barDistance;
    }
    for (int k = limit + width; k < pix.length; k += width)
        System.arraycopy(pix, limit, pix, k, width);
    Image img = canvas.createImage(new MemoryImageSource(width, barTall, pix, 0, width));
    
    return img;
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:57,代码来源:BarcodePostnet.java

示例9: createAwtImage

import java.awt.Canvas; //导入方法依赖的package包/类
/** Creates a <CODE>java.awt.Image</CODE>. This image only
 * contains the bars without any text.
 * @param foreground the color of the bars
 * @param background the color of the background
 * @return the image
 */    
public java.awt.Image createAwtImage(Color foreground, Color background) {
    int f = foreground.getRGB();
    int g = background.getRGB();
    Canvas canvas = new Canvas();

    int width = 0;
    byte bars[] = null;
    switch (codeType) {
        case EAN13:
            bars = getBarsEAN13(code);
            width = 11 + 12 * 7;
            break;
        case EAN8:
            bars = getBarsEAN8(code);
            width = 11 + 8 * 7;
            break;
        case UPCA:
            bars = getBarsEAN13("0" + code);
            width = 11 + 12 * 7;
            break;
        case UPCE:
            bars = getBarsUPCE(code);
            width = 9 + 6 * 7;
            break;
        case SUPP2:
            bars = getBarsSupplemental2(code);
            width = 6 + 2 * 7;
            break;
        case SUPP5:
            bars = getBarsSupplemental5(code);
            width = 4 + 5 * 7 + 4 * 2;
            break;
        default:
            throw new RuntimeException("Invalid code type.");
    }

    boolean print = true;
    int ptr = 0;
    int height = (int)barHeight;
    int pix[] = new int[width * height];
    for (int k = 0; k < bars.length; ++k) {
        int w = bars[k];
        int c = g;
        if (print)
            c = f;
        print = !print;
        for (int j = 0; j < w; ++j)
            pix[ptr++] = c;
    }
    for (int k = width; k < pix.length; k += width) {
        System.arraycopy(pix, 0, pix, k, width); 
    }
    Image img = canvas.createImage(new MemoryImageSource(width, height, pix, 0, width));
    
    return img;
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:63,代码来源:BarcodeEAN.java


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