summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--html/en/drv/gdk.html14
-rw-r--r--src/gdk/cdgdk.c35
-rw-r--r--src/gdk/cdgdk.h2
3 files changed, 44 insertions, 7 deletions
diff --git a/html/en/drv/gdk.html b/html/en/drv/gdk.html
index ea59708..e4a531b 100644
--- a/html/en/drv/gdk.html
+++ b/html/en/drv/gdk.html
@@ -84,7 +84,19 @@
<h4>Exclusive Attributes</h4>
<ul>
<li>&quot;<b><font face="Courier">GC</font></b>&quot;:&nbsp; returns the GDK graphics
- context (get only). In Lua is returned as a user data.</li>
+ context (get only). In Lua is returned as an user data.</li>
+</ul>
+
+<ul>
+ <li>&quot;<b><font face="Courier">IMGDITHER</font></b>&quot;:&nbsp; changes
+ how dithering is used in images when bpp&lt;=8. Can be &quot;NORMAL&quot; or &quot;NONE&quot;.
+ Default: &quot;NONE&quot;.</li>
+</ul>
+
+<ul>
+ <li>&quot;<b><font face="Courier">IMGINTERP</font></b>&quot;:&nbsp; changes
+ how interpolation is used in image scale. Can be &quot;BILINEAR&quot; or &quot;NEAREST&quot;.
+ Default: &quot;NEAREST&quot;.</li>
</ul>
<ul>
diff --git a/src/gdk/cdgdk.c b/src/gdk/cdgdk.c
index 76eb3db..b0c8ea8 100644
--- a/src/gdk/cdgdk.c
+++ b/src/gdk/cdgdk.c
@@ -1163,7 +1163,7 @@ static void cdputimagerectrgba_matrix(cdCtxCanvas* ctxcanvas, int iw, int ih, co
if (!pixbuf)
return;
- gdk_draw_pixbuf(ctxcanvas->wnd, ctxcanvas->gc, pixbuf, 0, 0, ex, ey, ew, eh, ctxcanvas->img_dither, 0, 0);
+ gdk_draw_pixbuf(ctxcanvas->wnd, ctxcanvas->gc, pixbuf, 0, 0, ex, ey, -1, -1, ctxcanvas->img_dither, 0, 0);
/* reset clipping */
gdk_region_destroy(clip_polygon);
@@ -1248,7 +1248,7 @@ static void cdputimagerectmap_matrix(cdCtxCanvas* ctxcanvas, int iw, int ih, con
if (!pixbuf)
return;
- gdk_draw_pixbuf(ctxcanvas->wnd, ctxcanvas->gc, pixbuf, 0, 0, ex, ey, ew, eh, ctxcanvas->img_dither, 0, 0);
+ gdk_draw_pixbuf(ctxcanvas->wnd, ctxcanvas->gc, pixbuf, 0, 0, ex, ey, -1, -1, ctxcanvas->img_dither, 0, 0);
/* reset clipping */
gdk_region_destroy(clip_polygon);
@@ -1289,7 +1289,7 @@ static void cdputimagerectrgb(cdCtxCanvas *ctxcanvas, int iw, int ih, const unsi
if (bw!=ew || bh!=eh)
{
- GdkPixbuf *pixbuf_scaled = gdk_pixbuf_scale_simple(pixbuf, ew, eh, GDK_INTERP_NEAREST);
+ GdkPixbuf *pixbuf_scaled = gdk_pixbuf_scale_simple(pixbuf, ew, eh, ctxcanvas->img_interp);
gdk_draw_pixbuf(ctxcanvas->wnd, ctxcanvas->gc, pixbuf_scaled, 0, 0, ex, ey, -1, -1, ctxcanvas->img_dither, 0, 0);
g_object_unref(pixbuf_scaled);
}
@@ -1328,7 +1328,7 @@ static void cdputimagerectrgba(cdCtxCanvas *ctxcanvas, int iw, int ih, const uns
if (bw!=ew || bh!=eh)
{
- GdkPixbuf *pixbuf_scaled = gdk_pixbuf_scale_simple(pixbuf, ew, eh, GDK_INTERP_NEAREST);
+ GdkPixbuf *pixbuf_scaled = gdk_pixbuf_scale_simple(pixbuf, ew, eh, ctxcanvas->img_interp);
gdk_draw_pixbuf(ctxcanvas->wnd, ctxcanvas->gc, pixbuf_scaled, 0, 0, ex, ey, -1, -1, ctxcanvas->img_dither, 0, 0);
g_object_unref(pixbuf_scaled);
}
@@ -1367,7 +1367,7 @@ static void cdputimagerectmap(cdCtxCanvas *ctxcanvas, int iw, int ih, const unsi
if (bw!=ew || bh!=eh)
{
- GdkPixbuf *pixbuf_scaled = gdk_pixbuf_scale_simple(pixbuf, ew, eh, GDK_INTERP_NEAREST);
+ GdkPixbuf *pixbuf_scaled = gdk_pixbuf_scale_simple(pixbuf, ew, eh, ctxcanvas->img_interp);
gdk_draw_pixbuf(ctxcanvas->wnd, ctxcanvas->gc, pixbuf_scaled, 0, 0, ex, ey, -1, -1, ctxcanvas->img_dither, 0, 0);
g_object_unref(pixbuf_scaled);
}
@@ -1553,6 +1553,29 @@ static cdAttribute imgdither_attrib =
get_imgdither_attrib
};
+static void set_interp_attrib(cdCtxCanvas* ctxcanvas, char* data)
+{
+ if (data && cdStrEqualNoCase(data, "BILINEAR"))
+ ctxcanvas->img_interp = GDK_INTERP_BILINEAR;
+ else
+ ctxcanvas->img_interp = GDK_INTERP_NEAREST;
+}
+
+static char* get_interp_attrib(cdCtxCanvas* ctxcanvas)
+{
+ if (ctxcanvas->img_interp)
+ return "BILINEAR";
+ else
+ return "NEAREST";
+}
+
+static cdAttribute interp_attrib =
+{
+ "IMGINTERP",
+ set_interp_attrib,
+ get_interp_attrib
+};
+
static char* get_gc_attrib(cdCtxCanvas *ctxcanvas)
{
return (char*)ctxcanvas->gc;
@@ -1626,6 +1649,8 @@ cdCtxCanvas *cdgdkCreateCanvas(cdCanvas* canvas, GdkDrawable* wnd, GdkScreen* sc
cdRegisterAttribute(canvas, &gc_attrib);
cdRegisterAttribute(canvas, &rotate_attrib);
cdRegisterAttribute(canvas, &pangoversion_attrib);
+ cdRegisterAttribute(canvas, &imgdither_attrib);
+ cdRegisterAttribute(canvas, &interp_attrib);
return ctxcanvas;
}
diff --git a/src/gdk/cdgdk.h b/src/gdk/cdgdk.h
index e05e650..af3cdc0 100644
--- a/src/gdk/cdgdk.h
+++ b/src/gdk/cdgdk.h
@@ -50,7 +50,7 @@ struct _cdCtxCanvas {
float rotate_angle;
int rotate_center_x;
int rotate_center_y;
- int img_dither;
+ int img_dither, img_interp;
GdkRegion* new_rgn;
GdkRegion* clip_rgn;