當前位置: 首頁>>代碼示例>>Java>>正文


Java AffineTransformOp.TYPE_BILINEAR屬性代碼示例

本文整理匯總了Java中java.awt.image.AffineTransformOp.TYPE_BILINEAR屬性的典型用法代碼示例。如果您正苦於以下問題:Java AffineTransformOp.TYPE_BILINEAR屬性的具體用法?Java AffineTransformOp.TYPE_BILINEAR怎麽用?Java AffineTransformOp.TYPE_BILINEAR使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在java.awt.image.AffineTransformOp的用法示例。


在下文中一共展示了AffineTransformOp.TYPE_BILINEAR屬性的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: rotate

public static BufferedImage rotate(final BufferedImage bufferedImage, final double radians) {

    final AffineTransform tx = new AffineTransform();
    tx.rotate(radians, bufferedImage.getWidth() / 2.0, bufferedImage.getHeight() / 2.0);

    final AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_BILINEAR);
    return op.filter(bufferedImage, null);
  }
 
開發者ID:gurkenlabs,項目名稱:litiengine,代碼行數:8,代碼來源:ImageProcessing.java

示例2: scale

/**
 * Build a scaled version of an image.
 *
 * @param img   image to scale
 * @param ratio scaling ratio
 * @return the scaled image
 */
public static BufferedImage scale (BufferedImage img,
                                   double ratio)
{
    AffineTransform at = AffineTransform.getScaleInstance(ratio, ratio);
    AffineTransformOp atop = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR);
    BufferedImage scaledImg = new BufferedImage(
            (int) Math.ceil(img.getWidth() * ratio),
            (int) Math.ceil(img.getHeight() * ratio),
            img.getType());

    return atop.filter(img, scaledImg);
}
 
開發者ID:Audiveris,項目名稱:omr-dataset-tools,代碼行數:19,代碼來源:SheetProcessor.java

示例3: slant

public static BufferedImage slant(BufferedImage image, FlexQuadrilateral quadrilateral, int xTranslation) {
    Point p = new Point(quadrilateral.getBottomLeft().x, quadrilateral.getTopLeft().y);
    double theta = Geometry.theta(quadrilateral.getBottomLeft(), p, quadrilateral.getTopLeft());

    AffineTransform transform = AffineTransform.getTranslateInstance(xTranslation, 0);
    transform.shear(Math.tan(theta), 0);

    transform.translate(xTranslation, 0);
    AffineTransformOp op = new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR);
    return op.filter(image, null);
}
 
開發者ID:defano,項目名稱:jmonet,代碼行數:11,代碼來源:Transform.java

示例4: resizeImage

public static BufferedImage resizeImage(BufferedImage image, int wantedWidth, int wantedHeight) {
    int w = image.getWidth();
    int h = image.getHeight();
    AffineTransform at = new AffineTransform();
    at.scale((double) wantedWidth / (double) w, (double) wantedHeight / (double) h);
    AffineTransformOp scaleOp = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR);

    BufferedImage rescaledImage = new BufferedImage(wantedWidth, wantedHeight, BufferedImage.TYPE_INT_ARGB);
    rescaledImage = scaleOp.filter(image, rescaledImage);

    return rescaledImage;
}
 
開發者ID:trebonius0,項目名稱:Photato,代碼行數:12,代碼來源:ImageHelper.java

示例5: scaleSmooth

private static BufferedImage scaleSmooth(BufferedImage im, double newWidth, double newHeigth)
{
    int w = im.getWidth();
    int h = im.getHeight();
    BufferedImage result = new BufferedImage((int)newWidth, (int)newHeigth, BufferedImage.TYPE_INT_ARGB);
    AffineTransform at = new AffineTransform();
    at.scale(newWidth / w, newHeigth / h);
    AffineTransformOp scaleOp = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR);
    result = scaleOp.filter(im, result);
    return result;
}
 
開發者ID:mirkoruether,項目名稱:DigitRecognizer,代碼行數:11,代碼來源:DigitManipulator.java

示例6: testImageTransform

public static BufferedImage testImageTransform(BufferedImage image,
                                               AffineTransform transform) {
    AffineTransformOp op =
            new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR);

    BufferedImage transformedImage = new BufferedImage(image.getWidth(),
                                                       image.getHeight(),
                                                       image.getType());

    return op.filter(image, transformedImage);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:11,代碼來源:InvalidTransformParameterTest.java

示例7: testRasterTransform

public static Raster testRasterTransform(Raster src, WritableRaster dst,
                                         AffineTransform transform) {
    AffineTransformOp op =
            new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR);

    return op.filter(src, dst);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:7,代碼來源:InvalidTransformParameterTest.java

示例8: generate

/**
 * generate captcha.
 *
 * @param sb records the captcha 記錄驗證碼
 * @return generated buffered image 生成的圖片
 */
public BufferedImage generate(StringBuilder sb) {
        BufferedImage img = new BufferedImage(x, y, BufferedImage.TYPE_INT_RGB);
        Graphics2D g = (Graphics2D) img.getGraphics();
        g.setColor(Color.white);
        g.fillRect(1, 1, x - 2, y - 2);

        /*java.util.List<String> badfonts = Arrays.asList(new String[]{ "Droid Sans Fallback","OpenSymbol", "Standard Symbols L"});
        //"MathJax_Script","MathJax_Size2", "MathJax_WinChrome","MathJax_AMS","MathJax_WinIE6", "MathJax_Size4", "MathJax_Caligraphic",
        String[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
        //g.setFont(new Font("Arial", Font.BOLD, size));
        int fnum = 0;
        do{
        	fnum = (int) (Math.random() * fonts.length);
        }while(badfonts.contains(fonts[fnum])|| fonts[fnum].startsWith("STIX")||fonts[fnum].startsWith("MathJax"));
        Log.get().finest("Capcha font:"+fnum+" "+fonts[fnum]);
        g.setFont(new Font(fonts[fnum], Font.BOLD, size));*/
        //g.setFont(new Font("Arial", Font.BOLD, nSize));
        g.setFont(new Font("DialogInput", Font.BOLD, nSize));

        int inc = x / (n + 2);

        int currentX = inc;
        int Y = (y + size / 2) / 2;
        for (int i = 0; i < n; ++i) {
                g.setColor(randColor());
                String s = randStr();
                sb.append(s);

                int wX = currentX + (int) (inc / 2 * (Math.random() * p * 2 - p));
                int wY = Y + (int) (Math.random() * v * 2 - v);

                g.translate(wX, wY);
                double rotate = (Math.random() * 2 - 1) * d * Math.PI / 180;
                g.rotate(rotate);
                g.drawString(s, 0, 0);
                currentX += inc;
                g.rotate(-rotate);
                g.translate(-wX, -wY);
        }

        //g.setFont(new Font(fonts[fnum], Font.BOLD, size));
        //g.setFont(new Font("Arial", Font.BOLD, nSize));
        g.setFont(new Font("DialogInput", Font.BOLD, nSize));
        for (int i = 0; i < m; ++i) {
                g.setColor(randColor());
                int nX = (int) (Math.random() * x);
                int nY = (int) (Math.random() * y);
                g.drawLine(nX, nY, nX + (int) (Math.random() * l * 2 - l), nY + (int) (Math.random() * l * 2 - l));
        }

        g.setColor(Color.black);
        g.drawRect(0, 0, x, y);
        g.dispose();
        
        //scale
        BufferedImage after = new BufferedImage(x*3, y*3, BufferedImage.TYPE_INT_RGB);
        AffineTransform at = new AffineTransform();
        at.scale(3.0, 3.0);
        AffineTransformOp scaleOp = 
           new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR);
        return scaleOp.filter(img, after);
}
 
開發者ID:Anoncheg1,項目名稱:diboard,代碼行數:68,代碼來源:CaptchaGen.java


注:本文中的java.awt.image.AffineTransformOp.TYPE_BILINEAR屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。