Search in sources :

Example 1 with CGImage

use of org.robovm.apple.coregraphics.CGImage in project playn by threerings.

the class RoboAbstractImage method draw.

@Override
public void draw(CGBitmapContext bctx, float dx, float dy, float dw, float dh, float sx, float sy, float sw, float sh) {
    // adjust our source rect to account for the scale factor
    sx *= scale.factor;
    sy *= scale.factor;
    sw *= scale.factor;
    sh *= scale.factor;
    CGImage cgImage = cgImage();
    float iw = cgImage.getWidth(), ih = cgImage.getHeight();
    float scaleX = dw / sw, scaleY = dh / sh;
    // pesky fiddling to cope with the fact that UIImages are flipped
    bctx.saveGState();
    bctx.translateCTM(dx, dy + dh);
    bctx.scaleCTM(1, -1);
    bctx.clipToRect(new CGRect(0, 0, dw, dh));
    bctx.translateCTM(-sx * scaleX, -(ih - (sy + sh)) * scaleY);
    bctx.drawImage(new CGRect(0, 0, iw * scaleX, ih * scaleY), cgImage);
    bctx.restoreGState();
}
Also used : CGImage(org.robovm.apple.coregraphics.CGImage) CGRect(org.robovm.apple.coregraphics.CGRect)

Aggregations

CGImage (org.robovm.apple.coregraphics.CGImage)1 CGRect (org.robovm.apple.coregraphics.CGRect)1