Hello,
I'm using android ndk to run a simple skia example but it's failing.
My Code:
int drawnow () {
//
SkAutoGraphics ag;
//Output filename
SkString path("/data/local/tmp/skhello.png");
//Set Text To Draw
SkString text("Hydra v0.0.1a");
SkPaint paint;
//Set Text ARGB Color
paint.setARGB(255, 255, 255, 255);
Turn AntiAliasing On
paint.setAntiAlias(true);
paint.setLCDRenderText(true);
paint.setTypeface(SkTypeface::CreateFromName("DroidSans", SkTypeface::kNormal));
//Set Text Size
paint.setTextSize(SkIntToScalar(40));
//Set Image Width & Height
int width = 500;
int height = 600;
SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
bitmap.allocPixels();
//Create Canvas
SkCanvas canvas(new SkDevice(bitmap));
canvas.drawARGB(255, 25, 25, 25);
//Text X, Y Position Varibles
int x = 80;
int y = 60;
//canvas.drawText(text.c_str(), text.size(), x, y, paint);
//Set Style and Stroke Width
paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeWidth(3);
//Draw A Rectangle
SkRect rect;
paint.setARGB(255, 255, 255, 255);
//Left, Top, Right, Bottom
rect.set(50, 100, 200, 200);
canvas.drawRoundRect(rect, 20, 20, paint);
canvas.drawOval(rect, paint);
//Draw A Line
canvas.drawLine(10, 300, 300, 300, paint);
//Draw Circle (X, Y, Size, Paint)
canvas.drawCircle(100, 400, 50, paint);
//Same Image (file, bitmap, image_type, quality)
bool success = SkImageEncoder::EncodeFile(path.c_str(), bitmap, SkImageEncoder::kPNG_Type, 100);
return success ;
}
the drawnow function returns "false" and the output file /data/local/tmp/skhello.png is not created also. I'm very new to skia and cant figure how to make it work. Is There any SkError class or any other way to capture error ? Where is the error happening ?
no error is shown is logcat.
i'm using android ics 4.0.4 and linking against the /system/lib/libskia.so (builtin)