Canvas: use correct destination width and height

This commit is contained in:
Julian Winkler
2023-07-14 18:06:43 +02:00
parent 5c6b83e8f1
commit c72f3ba7d2
3 changed files with 6 additions and 5 deletions

View File

@@ -38,12 +38,13 @@ JNIEXPORT void JNICALL Java_android_graphics_Canvas_native_1drawLine(JNIEnv *env
cairo_stroke(cr);
}
JNIEXPORT void JNICALL Java_android_graphics_Canvas_native_1drawBitmap(JNIEnv *env , jclass this_class, jlong cairo_context, jlong widget, jlong _pixbuf, jfloat src_x, jfloat src_y , jfloat dest_x , jfloat dest_y, jobject paint)
JNIEXPORT void JNICALL Java_android_graphics_Canvas_native_1drawBitmap(JNIEnv *env , jclass this_class, jlong cairo_context, jlong widget, jlong _pixbuf, jfloat src_x, jfloat src_y, jfloat dest_x , jfloat dest_y, jfloat dest_w , jfloat dest_h, jobject paint)
{
cairo_t *cr = (cairo_t *)_PTR(cairo_context);
GdkPixbuf *pixbuf = (GdkPixbuf *)_PTR(_pixbuf);
cairo_translate(cr, dest_x, dest_y);
cairo_scale(cr, dest_w / gdk_pixbuf_get_width(pixbuf), dest_h / gdk_pixbuf_get_height(pixbuf));
gdk_cairo_set_source_pixbuf(cr, pixbuf, src_x, src_y);
cairo_paint(cr);
cairo_translate(cr, -dest_x, -dest_y);