Java Code Examples for java.awt.image.AffineTransformOp

The following are top voted examples for showing how to use java.awt.image.AffineTransformOp. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: openjdk-jdk10   File: D3DDrawImage.java   View source code 8 votes vote down vote up
@Override
public void transformImage(SunGraphics2D sg, BufferedImage img,
                           BufferedImageOp op, int x, int y)
{
    if (op != null) {
        if (op instanceof AffineTransformOp) {
            AffineTransformOp atop = (AffineTransformOp) op;
            transformImage(sg, img, x, y,
                           atop.getTransform(),
                           atop.getInterpolationType());
            return;
        } else {
            if (D3DBufImgOps.renderImageWithOp(sg, img, op, x, y)) {
                return;
            }
        }
        img = op.filter(img, null);
    }
    copyImage(sg, img, x, y, null);
}
 
Example 2
Project: Cypher   File: Util.java   View source code 6 votes vote down vote up
/**
 * Code taken from: <a href="https://stackoverflow.com/a/40699460">Stackoverflow answer from Kevin G. based on code from davidhampgonsalves.com/Identicons</a>
 * Comments and slight modifications added.
 */
public static javafx.scene.image.Image generateIdenticon(String text, int image_width, int image_height) throws IOException {
	// If the input name/text is null or empty no image can be created.
	if (text == null || text.length() < 3) {
		return null;
	}

	int width = 5, height = 5;

	byte[] hash = text.getBytes();

	BufferedImage identicon = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
	WritableRaster raster = identicon.getRaster();

	int [] background = new int [] {255,255,255, 0};
	int [] foreground = new int [] {hash[0] & 255, hash[1] & 255, hash[2] & 255, 255};

	for(int x=0 ; x < width ; x++) {
		//Enforce horizontal symmetry
		int i = x < 3 ? x : 4 - x;
		for(int y=0 ; y < height; y++) {
			int [] pixelColor;
			//toggle pixels based on bit being on/off
			if((hash[i] >> y & 1) == 1)
				pixelColor = foreground;
			else
				pixelColor = background;
			raster.setPixel(x, y, pixelColor);
		}
	}

	BufferedImage finalImage = new BufferedImage(image_width, image_height, BufferedImage.TYPE_INT_ARGB);

	//Scale image to the size you want
	AffineTransform at = new AffineTransform();
	at.scale(image_width / width, image_height / height);
	AffineTransformOp op = new AffineTransformOp(at, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
	finalImage = op.filter(identicon, finalImage);

	// Convert BufferedImage to javafx image
	return createImage(finalImage);
}
 
Example 3
Project: OpenJSharp   File: DrawImage.java   View source code 6 votes vote down vote up
public static boolean isSimpleTranslate(SunGraphics2D sg) {
    int ts = sg.transformState;
    if (ts <= SunGraphics2D.TRANSFORM_INT_TRANSLATE) {
        // Integer translates are always "simple"
        return true;
    }
    if (ts >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
        // Scales and beyond are always "not simple"
        return false;
    }
    // non-integer translates are only simple when not interpolating
    if (sg.interpolationType == AffineTransformOp.TYPE_NEAREST_NEIGHBOR) {
        return true;
    }
    return false;
}
 
Example 4
Project: OpenJSharp   File: DrawImage.java   View source code 6 votes vote down vote up
public void transformImage(SunGraphics2D sg, BufferedImage img,
                           BufferedImageOp op, int x, int y)
{
    if (op != null) {
        if (op instanceof AffineTransformOp) {
            AffineTransformOp atop = (AffineTransformOp) op;
            transformImage(sg, img, x, y,
                           atop.getTransform(),
                           atop.getInterpolationType());
            return;
        } else {
            img = op.filter(img, null);
        }
    }
    copyImage(sg, img, x, y, null);
}
 
Example 5
Project: OpenJSharp   File: OGLDrawImage.java   View source code 6 votes vote down vote up
@Override
public void transformImage(SunGraphics2D sg, BufferedImage img,
                           BufferedImageOp op, int x, int y)
{
    if (op != null) {
        if (op instanceof AffineTransformOp) {
            AffineTransformOp atop = (AffineTransformOp) op;
            transformImage(sg, img, x, y,
                           atop.getTransform(),
                           atop.getInterpolationType());
            return;
        } else {
            if (OGLBufImgOps.renderImageWithOp(sg, img, op, x, y)) {
                return;
            }
        }
        img = op.filter(img, null);
    }
    copyImage(sg, img, x, y, null);
}
 
Example 6
Project: OpenJSharp   File: D3DDrawImage.java   View source code 6 votes vote down vote up
@Override
public void transformImage(SunGraphics2D sg, BufferedImage img,
                           BufferedImageOp op, int x, int y)
{
    if (op != null) {
        if (op instanceof AffineTransformOp) {
            AffineTransformOp atop = (AffineTransformOp) op;
            transformImage(sg, img, x, y,
                           atop.getTransform(),
                           atop.getInterpolationType());
            return;
        } else {
            if (D3DBufImgOps.renderImageWithOp(sg, img, op, x, y)) {
                return;
            }
        }
        img = op.filter(img, null);
    }
    copyImage(sg, img, x, y, null);
}
 
Example 7
Project: hearthstone   File: Img.java   View source code 6 votes vote down vote up
/**
 * Rotaciona uma imagem
 *
 * @param image imagem a ser rotacionada
 * @param angle ângulo da rotação
 * @return imagem rotacionada
 */
public static ImageIcon girar(ImageIcon image, double angle) {
    BufferedImage rotateImage = ImageIconToBufferedImage(image);
    angle %= 360;
    if (angle < 0) {
        angle += 360;
    }
    AffineTransform tx = new AffineTransform();
    tx.rotate(Math.toRadians(angle), rotateImage.getWidth() / 2.0, rotateImage.getHeight() / 2.0);

    double ytrans;
    double xtrans;
    if (angle <= 90) {
        xtrans = tx.transform(new Point2D.Double(0, rotateImage.getHeight()), null).getX();
        ytrans = tx.transform(new Point2D.Double(0.0, 0.0), null).getY();
    } else if (angle <= 180) {
        xtrans = tx.transform(new Point2D.Double(rotateImage.getWidth(), rotateImage.getHeight()), null).getX();
        ytrans = tx.transform(new Point2D.Double(0, rotateImage.getHeight()), null).getY();
    } else if (angle <= 270) {
        xtrans = tx.transform(new Point2D.Double(rotateImage.getWidth(), 0), null).getX();
        ytrans = tx.transform(new Point2D.Double(rotateImage.getWidth(), rotateImage.getHeight()), null).getY();
    } else {
        xtrans = tx.transform(new Point2D.Double(0, 0), null).getX();
        ytrans = tx.transform(new Point2D.Double(rotateImage.getWidth(), 0), null).getY();
    }

    AffineTransform translationTransform = new AffineTransform();
    translationTransform.translate(-xtrans, -ytrans);
    tx.preConcatenate(translationTransform);

    return new ImageIcon(new AffineTransformOp(tx, AffineTransformOp.TYPE_BILINEAR).filter(rotateImage, null));
}
 
Example 8
Project: VTerminal   File: FlipShader.java   View source code 6 votes vote down vote up
@Override
public BufferedImage run(final @NonNull BufferedImage image) {
    if (isFlippedHorizontally || isFlippedVertically) {
        final double scaleX = isFlippedHorizontally ? -1 : 1;
        final double scaleY = isFlippedVertically ? -1 : 1;
        final double translateX = isFlippedHorizontally ? -image.getWidth() : 0;
        final double translateY = isFlippedVertically ? -image.getHeight() : 0;

        final AffineTransform tx = AffineTransform.getScaleInstance(scaleX, scaleY);
        tx.translate(translateX, translateY);

        final BufferedImageOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
        return op.filter(image, null);
    }

    return image;
}
 
Example 9
Project: VTerminal   File: Font.java   View source code 6 votes vote down vote up
/**
 * Constructs a new Font.
 *
 * @param characterImages
 *        The base character images.
 *
 * @param scale
 *        The amount to scale each character image by.
 *
 * @throws NullPointerException
 *         If the characterImages is null.
 *
 * @throws IOException
 *         If an I/O error occurs.
 */
public Font(final @NonNull HashMap<Character, BufferedImage> characterImages, final int scale) throws IOException {
    this.characterImages = characterImages;

    final int width = characterImages.get('X').getWidth() * scale;
    final int height = characterImages.get('X').getHeight() * scale;
    dimensions = new Dimension(width, height);

    if (scale > 0) {
        final AffineTransform tx = AffineTransform.getScaleInstance(scale, scale);
        final AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);

        for (final Map.Entry<Character, BufferedImage> entry : characterImages.entrySet()) {
            characterImages.put(entry.getKey(), op.filter(entry.getValue(), null));
        }
    }
}
 
Example 10
Project: VTerminal   File: ImagePrinter.java   View source code 6 votes vote down vote up
/**
 * Flips and scales the image.
 *
 * @return
 *         The flipped and scaled image.
 */
private BufferedImage applyTransformations() {
    final AffineTransform tx;

    if (flipHorizontally && flipVertically) {
        tx = AffineTransform.getScaleInstance(-scaleX, -scaleY);
        tx.translate(-image.getWidth(), -image.getHeight());
    } else if (flipHorizontally) {
        tx = AffineTransform.getScaleInstance(-scaleX, scaleY);
        tx.translate(-image.getWidth(), 0);
    } else if(flipVertically) {
        tx = AffineTransform.getScaleInstance(scaleX, -scaleY);
        tx.translate(0, -image.getHeight());
    } else {
        tx = AffineTransform.getScaleInstance(scaleX, scaleY);
    }

    final AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
    return op.filter(image, null);
}
 
Example 11
Project: jdk8u-jdk   File: DrawImage.java   View source code 6 votes vote down vote up
public static boolean isSimpleTranslate(SunGraphics2D sg) {
    int ts = sg.transformState;
    if (ts <= SunGraphics2D.TRANSFORM_INT_TRANSLATE) {
        // Integer translates are always "simple"
        return true;
    }
    if (ts >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
        // Scales and beyond are always "not simple"
        return false;
    }
    // non-integer translates are only simple when not interpolating
    if (sg.interpolationType == AffineTransformOp.TYPE_NEAREST_NEIGHBOR) {
        return true;
    }
    return false;
}
 
Example 12
Project: jdk8u-jdk   File: DrawImage.java   View source code 6 votes vote down vote up
public void transformImage(SunGraphics2D sg, BufferedImage img,
                           BufferedImageOp op, int x, int y)
{
    if (op != null) {
        if (op instanceof AffineTransformOp) {
            AffineTransformOp atop = (AffineTransformOp) op;
            transformImage(sg, img, x, y,
                           atop.getTransform(),
                           atop.getInterpolationType());
            return;
        } else {
            img = op.filter(img, null);
        }
    }
    copyImage(sg, img, x, y, null);
}
 
Example 13
Project: jdk8u-jdk   File: OGLDrawImage.java   View source code 6 votes vote down vote up
@Override
public void transformImage(SunGraphics2D sg, BufferedImage img,
                           BufferedImageOp op, int x, int y)
{
    if (op != null) {
        if (op instanceof AffineTransformOp) {
            AffineTransformOp atop = (AffineTransformOp) op;
            transformImage(sg, img, x, y,
                           atop.getTransform(),
                           atop.getInterpolationType());
            return;
        } else {
            if (OGLBufImgOps.renderImageWithOp(sg, img, op, x, y)) {
                return;
            }
        }
        img = op.filter(img, null);
    }
    copyImage(sg, img, x, y, null);
}
 
Example 14
Project: jdk8u-jdk   File: D3DDrawImage.java   View source code 6 votes vote down vote up
@Override
public void transformImage(SunGraphics2D sg, BufferedImage img,
                           BufferedImageOp op, int x, int y)
{
    if (op != null) {
        if (op instanceof AffineTransformOp) {
            AffineTransformOp atop = (AffineTransformOp) op;
            transformImage(sg, img, x, y,
                           atop.getTransform(),
                           atop.getInterpolationType());
            return;
        } else {
            if (D3DBufImgOps.renderImageWithOp(sg, img, op, x, y)) {
                return;
            }
        }
        img = op.filter(img, null);
    }
    copyImage(sg, img, x, y, null);
}
 
Example 15
Project: openjdk-jdk10   File: DrawImage.java   View source code 6 votes vote down vote up
public static boolean isSimpleTranslate(SunGraphics2D sg) {
    int ts = sg.transformState;
    if (ts <= SunGraphics2D.TRANSFORM_INT_TRANSLATE) {
        // Integer translates are always "simple"
        return true;
    }
    if (ts >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
        // Scales and beyond are always "not simple"
        return false;
    }
    // non-integer translates are only simple when not interpolating
    if (sg.interpolationType == AffineTransformOp.TYPE_NEAREST_NEIGHBOR) {
        return true;
    }
    return false;
}
 
Example 16
Project: openjdk-jdk10   File: OGLDrawImage.java   View source code 6 votes vote down vote up
@Override
public void transformImage(SunGraphics2D sg, BufferedImage img,
                           BufferedImageOp op, int x, int y)
{
    if (op != null) {
        if (op instanceof AffineTransformOp) {
            AffineTransformOp atop = (AffineTransformOp) op;
            transformImage(sg, img, x, y,
                           atop.getTransform(),
                           atop.getInterpolationType());
            return;
        } else {
            if (OGLBufImgOps.renderImageWithOp(sg, img, op, x, y)) {
                return;
            }
        }
        img = op.filter(img, null);
    }
    copyImage(sg, img, x, y, null);
}
 
Example 17
Project: litiengine   File: ImageProcessing.java   View source code 5 votes vote down vote up
/**
 * Adds a shadow effect by executing the following steps: 1. Transform visible
 * pixels to a semi-transparent black 2. Flip the image vertically 3. Scale it
 * down 4. Render original image and shadow on a buffered image
 *
 * @param image
 *          the image
 * @param xOffset
 *          the x offset
 * @param yOffset
 *          the y offset
 * @return the buffered image
 */
public static BufferedImage addShadow(final BufferedImage image, final int xOffset, final int yOffset) {
  if (image == null) {
    return image;
  }

  // Transform visible pixels to a semi-transparent black
  final BufferedImage shadowImage = flashVisiblePixels(image, new Color(0, 0, 0, 30));
  if (shadowImage == null) {
    return image;
  }

  final AffineTransform tx = new AffineTransform();

  // Flip the image vertically
  tx.concatenate(AffineTransform.getScaleInstance(1, -0.15));
  tx.concatenate(AffineTransform.getTranslateInstance(0, -shadowImage.getHeight()));
  final AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
  final BufferedImage rotatedImage = op.filter(shadowImage, null);

  final BufferedImage shadow = getCompatibleImage(image.getWidth(), image.getHeight() + rotatedImage.getHeight());
  final Graphics2D g2D = shadow.createGraphics();
  g2D.drawImage(rotatedImage, xOffset, yOffset, null);
  g2D.drawImage(image, 0, 0, null);

  g2D.dispose();

  return shadow;
}
 
Example 18
Project: openjdk-jdk10   File: D3DBlitLoops.java   View source code 5 votes vote down vote up
public void Blit(SurfaceData src, SurfaceData dst,
                 Composite comp, Region clip,
                 int sx, int sy, int dx, int dy, int w, int h)
{
    D3DBlitLoops.Blit(src, dst,
                      comp, clip, null,
                      AffineTransformOp.TYPE_NEAREST_NEIGHBOR,
                      sx, sy, sx+w, sy+h,
                      dx, dy, dx+w, dy+h,
                      typeval, true);
}
 
Example 19
Project: omr-dataset-tools   File: SheetProcessor.java   View source code 5 votes vote down vote up
/**
 * 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);
}
 
Example 20
Project: jmonet   File: Transform.java   View source code 5 votes vote down vote up
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);
}
 
Example 21
Project: FileUpload2Spring   File: EasyImage.java   View source code 5 votes vote down vote up
public void affineTransform (double fShxFactor, double fShyFactor) {

        try {
          AffineTransform shearer =
            AffineTransform.getShearInstance (fShxFactor, fShyFactor);
          AffineTransformOp shear_op =
            new AffineTransformOp (shearer, null);
          bufferedImage = shear_op.filter (bufferedImage, null);
        }
        catch (Exception e) {
          System.out.println("Shearing exception = " + e);
        }
      }
 
Example 22
Project: openjdk-jdk10   File: OGLBlitLoops.java   View source code 5 votes vote down vote up
public void Blit(SurfaceData src, SurfaceData dst,
                 Composite comp, Region clip,
                 int sx, int sy, int dx, int dy, int w, int h)
{
    OGLBlitLoops.Blit(src, dst,
                      comp, clip, null,
                      AffineTransformOp.TYPE_NEAREST_NEIGHBOR,
                      sx, sy, sx+w, sy+h,
                      dx, dy, dx+w, dy+h,
                      typeval, true);
}
 
Example 23
Project: DigitRecognizer   File: DigitManipulator.java   View source code 5 votes vote down vote up
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;
}
 
Example 24
Project: jaer   File: ImageCreatorSlave.java   View source code 5 votes vote down vote up
@Override
public void run() {
    BufferedImage img = new BufferedImage(display.getWidth(), display.getHeight(), BufferedImage.TYPE_INT_RGB);
    for (int y = 0; y < display.getHeight(); y++) {
        for (int x = 0; x < display.getWidth(); x++) {
            int idx = getIndex(x, y);
            int nIdx = 3 * idx;
            int r = ((int) (rgbValues[nIdx++] * 255)); // red component 0...255
            int g = ((int) (rgbValues[nIdx++] * 255)); // green component 0...255
            int b = ((int) (rgbValues[nIdx] * 255)); // blue component 0...255
            int col = (r << 16) | (g << 8) | b;
            img.setRGB(x, y, col);
        }
    }
    AffineTransform tx = AffineTransform.getScaleInstance(1, -1);
    tx.translate(0, -img.getHeight(null));
    AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
    img = op.filter(img, null);
    SimpleDateFormat sdfDate = new SimpleDateFormat("_yyyy_MM_dd_HH_mm_ss");//dd/MM/yyyy
    Date now = new Date();
    String strDate = sdfDate.format(now);
    try {
        ImageIO.write(img, "png", new File(String.format("%s/ImageCreator%s.png", path, strDate)));
    } catch (IOException ex) {
        log.warning("can not save Image, Error: " + ex.toString());
    }
}
 
Example 25
Project: jaer   File: ImageCreator.java   View source code 5 votes vote down vote up
@Override
public void run() {
    BufferedImage img = new BufferedImage(display.getWidth(), display.getHeight(), BufferedImage.TYPE_INT_RGB);
    for (int y = 0; y < display.getHeight(); y++) {
        for (int x = 0; x < display.getWidth(); x++) {
            int idx = getIndex(x, y);
            int nIdx = 3 * idx;
            int r = ((int) (rgbValues[nIdx++] * 255)); // red component 0...255
            int g = ((int) (rgbValues[nIdx++] * 255)); // green component 0...255
            int b = ((int) (rgbValues[nIdx] * 255)); // blue component 0...255
            int col = (r << 16) | (g << 8) | b;
            img.setRGB(x, y, col);
        }
    }
    AffineTransform tx = AffineTransform.getScaleInstance(1, -1);  //alligns the image correctly
    tx.translate(0, -img.getHeight(null));
    AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
    img = op.filter(img, null);
    SimpleDateFormat sdfDate = new SimpleDateFormat("_yyyy_MM_dd_HH_mm_ss");//dd/MM/yyyy
    Date now = new Date();
    String strDate = sdfDate.format(now);
    try {
        ImageIO.write(img, "png", new File(String.format("%s/ImageCreator%s.png", path, strDate)));
    } catch (IOException ex) {
        log.warning("can not save Image, Error: " + ex.toString());
    }
}
 
Example 26
Project: Elune   File: ImageUtil.java   View source code 5 votes vote down vote up
/**
 * 缩放图片
 *
 * @param imgPath 源图片绝对路径
 * @param disPath 目标图片绝对路径
 * @param height 目标高度
 * @param width 目标宽度
 * @param whiteFill 是否补白
 */
public final static void scale(String imgPath, String disPath, int height, int width, boolean whiteFill) {
    try {
        double ratio = 0.0;
        File file = new File(imgPath);
        BufferedImage bufferedImage = ImageIO.read(file);
        Image tempImg = bufferedImage.getScaledInstance(width, height, BufferedImage.SCALE_SMOOTH);
        // 计算比例
        if ((bufferedImage.getHeight() > height) || (bufferedImage.getWidth() > width)) {
            double ratioV = (new Integer(height).doubleValue() / bufferedImage.getHeight());
            double ratioH = (new Integer(width).doubleValue() / bufferedImage.getWidth());
            ratio = Math.max(ratioV, ratioH);
            AffineTransformOp op = new AffineTransformOp(AffineTransform.getScaleInstance(ratio, ratio), null);
            tempImg = op.filter(bufferedImage, null);
        }
        if (whiteFill) {
            BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
            Graphics2D g = img.createGraphics();
            g.setColor(Color.WHITE);
            g.fillRect(0, 0, width, height);
            if (width == tempImg.getWidth(null)) {
                g.drawImage(tempImg, 0, (height - tempImg.getHeight(null)) / 2, tempImg.getWidth(null), tempImg.getHeight(null), Color.WHITE, null);
            } else {
                g.drawImage(tempImg, (width - tempImg.getWidth(null)) / 2, 0, tempImg.getWidth(null), tempImg.getHeight(null), Color.WHITE, null);
            }
            g.dispose();
            tempImg = img;
        }
        ImageIO.write((BufferedImage)tempImg, "JPEG", new File(disPath));
    } catch (IOException e) {
        //
        e.printStackTrace();
    }
}
 
Example 27
Project: openjdk-jdk10   File: OGLBlitLoops.java   View source code 5 votes vote down vote up
public void Scale(SurfaceData src, SurfaceData dst,
                  Composite comp, Region clip,
                  int sx1, int sy1,
                  int sx2, int sy2,
                  double dx1, double dy1,
                  double dx2, double dy2)
{
    OGLBlitLoops.IsoBlit(src, dst,
                         null, null,
                         comp, clip, null,
                         AffineTransformOp.TYPE_NEAREST_NEIGHBOR,
                         sx1, sy1, sx2, sy2,
                         dx1, dy1, dx2, dy2,
                         true);
}
 
Example 28
Project: OpenJSharp   File: SunGraphics2D.java   View source code 5 votes vote down vote up
public SunGraphics2D(SurfaceData sd, Color fg, Color bg, Font f) {
    surfaceData = sd;
    foregroundColor = fg;
    backgroundColor = bg;

    transform = new AffineTransform();
    stroke = defaultStroke;
    composite = defaultComposite;
    paint = foregroundColor;

    imageComp = CompositeType.SrcOverNoEa;

    renderHint = SunHints.INTVAL_RENDER_DEFAULT;
    antialiasHint = SunHints.INTVAL_ANTIALIAS_OFF;
    textAntialiasHint = SunHints.INTVAL_TEXT_ANTIALIAS_DEFAULT;
    fractionalMetricsHint = SunHints.INTVAL_FRACTIONALMETRICS_OFF;
    lcdTextContrast = lcdTextContrastDefaultValue;
    interpolationHint = -1;
    strokeHint = SunHints.INTVAL_STROKE_DEFAULT;
    resolutionVariantHint = SunHints.INTVAL_RESOLUTION_VARIANT_DEFAULT;

    interpolationType = AffineTransformOp.TYPE_NEAREST_NEIGHBOR;

    validateColor();

    devScale = sd.getDefaultScale();
    if (devScale != 1) {
        transform.setToScale(devScale, devScale);
        invalidateTransform();
    }

    font = f;
    if (font == null) {
        font = defaultFont;
    }

    setDevClip(sd.getBounds());
    invalidatePipe();
}
 
Example 29
Project: OpenJSharp   File: SunGraphics2D.java   View source code 5 votes vote down vote up
/**
 * Sets the preferences for the rendering algorithms.
 * Hint categories include controls for rendering quality and
 * overall time/quality trade-off in the rendering process.
 * @param hints The rendering hints to be set
 * @see RenderingHints
 */
public void setRenderingHints(Map<?,?> hints) {
    this.hints = null;
    renderHint = SunHints.INTVAL_RENDER_DEFAULT;
    antialiasHint = SunHints.INTVAL_ANTIALIAS_OFF;
    textAntialiasHint = SunHints.INTVAL_TEXT_ANTIALIAS_DEFAULT;
    fractionalMetricsHint = SunHints.INTVAL_FRACTIONALMETRICS_OFF;
    lcdTextContrast = lcdTextContrastDefaultValue;
    interpolationHint = -1;
    interpolationType = AffineTransformOp.TYPE_NEAREST_NEIGHBOR;
    boolean customHintPresent = false;
    Iterator<?> iter = hints.keySet().iterator();
    while (iter.hasNext()) {
        Object key = iter.next();
        if (key == SunHints.KEY_RENDERING ||
            key == SunHints.KEY_ANTIALIASING ||
            key == SunHints.KEY_TEXT_ANTIALIASING ||
            key == SunHints.KEY_FRACTIONALMETRICS ||
            key == SunHints.KEY_TEXT_ANTIALIAS_LCD_CONTRAST ||
            key == SunHints.KEY_STROKE_CONTROL ||
            key == SunHints.KEY_INTERPOLATION)
        {
            setRenderingHint((Key) key, hints.get(key));
        } else {
            customHintPresent = true;
        }
    }
    if (customHintPresent) {
        this.hints = makeHints(hints);
    }
    invalidatePipe();
}
 
Example 30
Project: OpenJSharp   File: OGLBlitLoops.java   View source code 5 votes vote down vote up
public void Blit(SurfaceData src, SurfaceData dst,
                 Composite comp, Region clip,
                 int sx, int sy, int dx, int dy, int w, int h)
{
    OGLBlitLoops.IsoBlit(src, dst,
                         null, null,
                         comp, clip, null,
                         AffineTransformOp.TYPE_NEAREST_NEIGHBOR,
                         sx, sy, sx+w, sy+h,
                         dx, dy, dx+w, dy+h,
                         false);
}
 
Example 31
Project: OpenJSharp   File: OGLBlitLoops.java   View source code 5 votes vote down vote up
public void Scale(SurfaceData src, SurfaceData dst,
                  Composite comp, Region clip,
                  int sx1, int sy1,
                  int sx2, int sy2,
                  double dx1, double dy1,
                  double dx2, double dy2)
{
    OGLBlitLoops.IsoBlit(src, dst,
                         null, null,
                         comp, clip, null,
                         AffineTransformOp.TYPE_NEAREST_NEIGHBOR,
                         sx1, sy1, sx2, sy2,
                         dx1, dy1, dx2, dy2,
                         false);
}
 
Example 32
Project: OpenJSharp   File: OGLBlitLoops.java   View source code 5 votes vote down vote up
public void Blit(SurfaceData src, SurfaceData dst,
                 Composite comp, Region clip,
                 int sx, int sy, int dx, int dy, int w, int h)
{
    OGLBlitLoops.IsoBlit(src, dst,
                         null, null,
                         comp, clip, null,
                         AffineTransformOp.TYPE_NEAREST_NEIGHBOR,
                         sx, sy, sx+w, sy+h,
                         dx, dy, dx+w, dy+h,
                         true);
}
 
Example 33
Project: openjdk-jdk10   File: OGLBlitLoops.java   View source code 5 votes vote down vote up
public void Scale(SurfaceData src, SurfaceData dst,
                  Composite comp, Region clip,
                  int sx1, int sy1,
                  int sx2, int sy2,
                  double dx1, double dy1,
                  double dx2, double dy2)
{
    OGLBlitLoops.Blit(src, dst,
                      comp, clip, null,
                      AffineTransformOp.TYPE_NEAREST_NEIGHBOR,
                      sx1, sy1, sx2, sy2,
                      dx1, dy1, dx2, dy2,
                      typeval, false);
}
 
Example 34
Project: openjdk-jdk10   File: D3DBlitLoops.java   View source code 5 votes vote down vote up
public void Scale(SurfaceData src, SurfaceData dst,
                  Composite comp, Region clip,
                  int sx1, int sy1,
                  int sx2, int sy2,
                  double dx1, double dy1,
                  double dx2, double dy2)
{
    D3DBlitLoops.IsoBlit(src, dst,
                         null, null,
                         comp, clip, null,
                         AffineTransformOp.TYPE_NEAREST_NEIGHBOR,
                         sx1, sy1, sx2, sy2,
                         dx1, dy1, dx2, dy2,
                         true);
}
 
Example 35
Project: OpenJSharp   File: OGLBlitLoops.java   View source code 5 votes vote down vote up
public void Scale(SurfaceData src, SurfaceData dst,
                  Composite comp, Region clip,
                  int sx1, int sy1,
                  int sx2, int sy2,
                  double dx1, double dy1,
                  double dx2, double dy2)
{
    OGLBlitLoops.Blit(src, dst,
                      comp, clip, null,
                      AffineTransformOp.TYPE_NEAREST_NEIGHBOR,
                      sx1, sy1, sx2, sy2,
                      dx1, dy1, dx2, dy2,
                      typeval, false);
}
 
Example 36
Project: OpenJSharp   File: OGLBlitLoops.java   View source code 5 votes vote down vote up
public void Blit(SurfaceData src, SurfaceData dst,
                 Composite comp, Region clip,
                 int sx, int sy, int dx, int dy, int w, int h)
{
    OGLBlitLoops.Blit(src, dst,
                      comp, clip, null,
                      AffineTransformOp.TYPE_NEAREST_NEIGHBOR,
                      sx, sy, sx+w, sy+h,
                      dx, dy, dx+w, dy+h,
                      typeval, true);
}
 
Example 37
Project: openjdk-jdk10   File: OGLBlitLoops.java   View source code 5 votes vote down vote up
public void Scale(SurfaceData src, SurfaceData dst,
                  Composite comp, Region clip,
                  int sx1, int sy1,
                  int sx2, int sy2,
                  double dx1, double dy1,
                  double dx2, double dy2)
{
    OGLBlitLoops.IsoBlit(src, dst,
                         null, null,
                         comp, clip, null,
                         AffineTransformOp.TYPE_NEAREST_NEIGHBOR,
                         sx1, sy1, sx2, sy2,
                         dx1, dy1, dx2, dy2,
                         true);
}
 
Example 38
Project: OpenJSharp   File: OGLBlitLoops.java   View source code 5 votes vote down vote up
public void Scale(SurfaceData src, SurfaceData dst,
                  Composite comp, Region clip,
                  int sx1, int sy1,
                  int sx2, int sy2,
                  double dx1, double dy1,
                  double dx2, double dy2)
{
    OGLBlitLoops.IsoBlit(src, dst,
                         null, null,
                         comp, clip, null,
                         AffineTransformOp.TYPE_NEAREST_NEIGHBOR,
                         sx1, sy1, sx2, sy2,
                         dx1, dy1, dx2, dy2,
                         true);
}
 
Example 39
Project: OpenJSharp   File: D3DDrawImage.java   View source code 5 votes vote down vote up
@Override
protected void renderImageXform(SunGraphics2D sg, Image img,
                                AffineTransform tx, int interpType,
                                int sx1, int sy1, int sx2, int sy2,
                                Color bgColor)
{
    // punt to the MediaLib-based transformImage() in the superclass if:
    //     - bicubic interpolation is specified
    //     - a background color is specified and will be used
    //     - an appropriate TransformBlit primitive could not be found
    if (interpType != AffineTransformOp.TYPE_BICUBIC) {
        SurfaceData dstData = sg.surfaceData;
        SurfaceData srcData =
            dstData.getSourceSurfaceData(img,
                                         sg.TRANSFORM_GENERIC,
                                         sg.imageComp,
                                         bgColor);

        if (srcData != null && !isBgOperation(srcData, bgColor)) {
            SurfaceType srcType = srcData.getSurfaceType();
            SurfaceType dstType = dstData.getSurfaceType();
            TransformBlit blit = TransformBlit.getFromCache(srcType,
                                                            sg.imageComp,
                                                            dstType);

            if (blit != null) {
                blit.Transform(srcData, dstData,
                               sg.composite, sg.getCompClip(),
                               tx, interpType,
                               sx1, sy1, 0, 0, sx2-sx1, sy2-sy1);
                return;
            }
        }
    }

    super.renderImageXform(sg, img, tx, interpType,
                           sx1, sy1, sx2, sy2, bgColor);
}
 
Example 40
Project: OpenJSharp   File: D3DBlitLoops.java   View source code 5 votes vote down vote up
public void Blit(SurfaceData src, SurfaceData dst,
                 Composite comp, Region clip,
                 int sx, int sy, int dx, int dy, int w, int h)
{
    D3DBlitLoops.IsoBlit(src, dst,
                         null, null,
                         comp, clip, null,
                         AffineTransformOp.TYPE_NEAREST_NEIGHBOR,
                         sx, sy, sx+w, sy+h,
                         dx, dy, dx+w, dy+h,
                         false);
}