// Path: ios-moe/src/org/oscim/ios_moe/backend/IosBitmap.java
// static CGColorRef getCGColor(int color) {
// 
//     return UIColor.colorWithRedGreenBlueAlpha(
//             Color.r(color) / 255.0,
//             Color.g(color) / 255.0,
//             Color.b(color) / 255.0,
//             Color.a(color) / 255.0
//     ).CGColor();
// }


import apple.coregraphics.opaque.CGContextRef;
import apple.coregraphics.struct.CGPoint;
import apple.coregraphics.struct.CGRect;
import apple.coregraphics.struct.CGSize;
import apple.uikit.c.UIKit;
import org.oscim.backend.canvas.Bitmap;
import org.oscim.backend.canvas.Canvas;
import org.oscim.backend.canvas.Paint;
import static apple.coregraphics.c.CoreGraphics.*;
import static org.oscim.ios_moe.backend.IosBitmap.getCGColor;
        }
        bmp.createImageFromContext();
    }

    @Override
    public void drawLine(float x1, float y1, float x2, float y2, Paint paint) {
        bmp.createContext();

        //flip Y-axis
        y1 = (int) (this.bmp.getHeight() - y1);
        y2 = (int) (this.bmp.getHeight() - y2);

        // set Stroke properties
        CGContextSetLineWidth(bmp.cgBitmapContext, ((IosPaint) paint).strokeWidth);
        CGContextSetLineCap(bmp.cgBitmapContext, ((IosPaint) paint).getIosStrokeCap());
        CGContextSetLineJoin(bmp.cgBitmapContext, ((IosPaint) paint).getIosStrokeJoin());
        setStrokeColor(bmp.cgBitmapContext, (paint.getColor()));

        //draw line
        CGContextBeginPath(bmp.cgBitmapContext);
        CGContextMoveToPoint(bmp.cgBitmapContext, x1, y1);
        CGContextAddLineToPoint(bmp.cgBitmapContext, x2, y2);
        CGContextStrokePath(bmp.cgBitmapContext);
        bmp.createImageFromContext();
    }

    @Override
    public void fillColor(int color) {
        bmp.createContext();
        CGSize size = new CGSize(bmp.width, bmp.height);
// Path: ios-moe/src/org/oscim/ios_moe/backend/IosBitmap.java
// static CGColorRef getCGColor(int color) {
// 
//     return UIColor.colorWithRedGreenBlueAlpha(
//             Color.r(color) / 255.0,
//             Color.g(color) / 255.0,
//             Color.b(color) / 255.0,
//             Color.a(color) / 255.0
//     ).CGColor();
// }


// Path: ios-moe/src/org/oscim/ios_moe/backend/IosCanvas.java
import apple.coregraphics.opaque.CGContextRef;
import apple.coregraphics.struct.CGPoint;
import apple.coregraphics.struct.CGRect;
import apple.coregraphics.struct.CGSize;
import apple.uikit.c.UIKit;
import org.oscim.backend.canvas.Bitmap;
import org.oscim.backend.canvas.Canvas;
import org.oscim.backend.canvas.Paint;
import static apple.coregraphics.c.CoreGraphics.*;
import static org.oscim.ios_moe.backend.IosBitmap.getCGColor;

        }
        bmp.createImageFromContext();
    }

    @Override
    public void drawLine(float x1, float y1, float x2, float y2, Paint paint) {
        bmp.createContext();

        //flip Y-axis
        y1 = (int) (this.bmp.getHeight() - y1);
        y2 = (int) (this.bmp.getHeight() - y2);

        // set Stroke properties
        CGContextSetLineWidth(bmp.cgBitmapContext, ((IosPaint) paint).strokeWidth);
        CGContextSetLineCap(bmp.cgBitmapContext, ((IosPaint) paint).getIosStrokeCap());
        CGContextSetLineJoin(bmp.cgBitmapContext, ((IosPaint) paint).getIosStrokeJoin());
        setStrokeColor(bmp.cgBitmapContext, (paint.getColor()));

        //draw line
        CGContextBeginPath(bmp.cgBitmapContext);
        CGContextMoveToPoint(bmp.cgBitmapContext, x1, y1);
        CGContextAddLineToPoint(bmp.cgBitmapContext, x2, y2);
        CGContextStrokePath(bmp.cgBitmapContext);
        bmp.createImageFromContext();
    }

    @Override
    public void fillColor(int color) {
        bmp.createContext();
        CGSize size = new CGSize(bmp.width, bmp.height);
        CGContextSetFillColorWithColor(bmp.cgBitmapContext, getCGColor(color));