@Override public float height() { return scale.invScaled(image.getHeight()); }
public RoboImage (Graphics gfx, Scale scale, CGImage img, String source) { super(gfx, scale, (int)img.getWidth(), (int)img.getHeight(), source, img); }
private ImageImpl.Data toData (Scale scale, UIImage image) { CGImage bitmap = image.getCGImage(); return new ImageImpl.Data(scale, bitmap, (int)bitmap.getWidth(), (int)bitmap.getHeight()); }
void updateTexture(int tex, CGImage image) { int width = (int)image.getWidth(), height = (int)image.getHeight(); if (width <= 0 || height <= 0) { platform.log().warn( "Ignoring texture update for empty image (" + width + "x" + height + ")."); return; } CGBitmapContext bctx = RoboGraphics.createCGBitmap(width, height); CGRect rect = new CGRect(0, 0, width, height); bctx.clearRect(rect); bctx.drawImage(rect, image); updateTexture(tex, width, height, bctx.getData()); bctx.dispose(); }
@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(); }
@Override public void draw(Object ctx, 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 image = cgImage(); CGBitmapContext bctx = (CGBitmapContext)ctx; float iw = image.getWidth(), ih = image.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), image); bctx.restoreGState(); }