mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-11 13:10:07 +00:00
reverted the expose everything changes, I'm not sure why these went in.
1999-07-16 Larry Ewing <lewing@gimp.org> * src/testpixbuf.c (expose_func): reverted the expose everything changes, I'm not sure why these went in. (config_func): bring this up to date with the new pixbuf_scale semantics. * src/gdk-pixbuf-io.c: added a couple of warnings to the module loading code so that poeple can diagnose problems better. * src/gdk-pixbuf.c (gdk_pixbux_scale): fix the borkedness, also it no longer allocates a new pixbuf, which make things nicer for the rest of the code. Unfortunately there is still a problem with scaling rgba images.
This commit is contained in:
parent
f12fbc1b32
commit
e9ed2c18a7
@ -45,29 +45,34 @@ quit_func (GtkWidget *widget, gpointer dummy)
|
|||||||
|
|
||||||
expose_func (GtkWidget *drawing_area, GdkEventExpose *event, gpointer data)
|
expose_func (GtkWidget *drawing_area, GdkEventExpose *event, gpointer data)
|
||||||
{
|
{
|
||||||
GdkPixBuf *pixbuf;
|
GdkPixBuf *pixbuf;
|
||||||
|
gint x1, y1, x2, y2;
|
||||||
|
|
||||||
pixbuf = (GdkPixBuf *)gtk_object_get_data(GTK_OBJECT(drawing_area), "pixbuf");
|
pixbuf = (GdkPixBuf *)gtk_object_get_data(GTK_OBJECT(drawing_area), "pixbuf");
|
||||||
|
|
||||||
if (pixbuf->art_pixbuf->has_alpha){
|
if (pixbuf->art_pixbuf->has_alpha){
|
||||||
gdk_draw_rgb_32_image (drawing_area->window,
|
gdk_draw_rgb_32_image (drawing_area->window,
|
||||||
drawing_area->style->black_gc,
|
drawing_area->style->black_gc,
|
||||||
0, 0,
|
event->area.x, event->area.y,
|
||||||
pixbuf->art_pixbuf->width,
|
event->area.width,
|
||||||
pixbuf->art_pixbuf->height,
|
event->area.height,
|
||||||
GDK_RGB_DITHER_NORMAL,
|
GDK_RGB_DITHER_MAX,
|
||||||
pixbuf->art_pixbuf->pixels,
|
pixbuf->art_pixbuf->pixels
|
||||||
pixbuf->art_pixbuf->rowstride);
|
+ (event->area.y * pixbuf->art_pixbuf->rowstride)
|
||||||
} else {
|
+ (event->area.x * pixbuf->art_pixbuf->n_channels),
|
||||||
gdk_draw_rgb_image (drawing_area->window,
|
pixbuf->art_pixbuf->rowstride);
|
||||||
drawing_area->style->white_gc,
|
}else{
|
||||||
0, 0,
|
gdk_draw_rgb_image (drawing_area->window,
|
||||||
pixbuf->art_pixbuf->width,
|
drawing_area->style->white_gc,
|
||||||
pixbuf->art_pixbuf->height,
|
event->area.x, event->area.y,
|
||||||
GDK_RGB_DITHER_NORMAL,
|
event->area.width,
|
||||||
pixbuf->art_pixbuf->pixels,
|
event->area.height,
|
||||||
pixbuf->art_pixbuf->rowstride);
|
GDK_RGB_DITHER_NORMAL,
|
||||||
}
|
pixbuf->art_pixbuf->pixels
|
||||||
|
+ (event->area.y * pixbuf->art_pixbuf->rowstride)
|
||||||
|
+ (event->area.x * pixbuf->art_pixbuf->n_channels),
|
||||||
|
pixbuf->art_pixbuf->rowstride);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
config_func (GtkWidget *drawing_area, GdkEventConfigure *event, gpointer data)
|
config_func (GtkWidget *drawing_area, GdkEventConfigure *event, gpointer data)
|
||||||
@ -79,11 +84,9 @@ config_func (GtkWidget *drawing_area, GdkEventConfigure *event, gpointer data)
|
|||||||
g_print("X:%d Y:%d\n", event->width, event->height);
|
g_print("X:%d Y:%d\n", event->width, event->height);
|
||||||
|
|
||||||
if (((event->width) != (pixbuf->art_pixbuf->width)) ||
|
if (((event->width) != (pixbuf->art_pixbuf->width)) ||
|
||||||
((event->height) != (pixbuf->art_pixbuf->height))) {
|
((event->height) != (pixbuf->art_pixbuf->height)))
|
||||||
spb = gdk_pixbuf_scale(pixbuf, event->width, event->height);
|
gdk_pixbuf_scale(pixbuf, event->width, event->height);
|
||||||
gdk_pixbuf_free (pixbuf);
|
|
||||||
gtk_object_set_data (GTK_OBJECT(drawing_area), "pixbuf", spb);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -155,14 +158,14 @@ main (int argc, char **argv)
|
|||||||
gtk_widget_set_default_visual (gdk_rgb_get_visual ());
|
gtk_widget_set_default_visual (gdk_rgb_get_visual ());
|
||||||
|
|
||||||
i = 1;
|
i = 1;
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++)
|
||||||
if (argv[i]) {
|
{
|
||||||
pixbuf = gdk_pixbuf_load_image (argv[i]);
|
pixbuf = gdk_pixbuf_load_image (argv[i]);
|
||||||
|
|
||||||
if (pixbuf) {
|
if (pixbuf)
|
||||||
new_testrgb_window (pixbuf);
|
{
|
||||||
found_valid = TRUE;
|
new_testrgb_window (pixbuf);
|
||||||
}
|
found_valid = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,18 @@
|
|||||||
|
1999-07-16 Larry Ewing <lewing@gimp.org>
|
||||||
|
|
||||||
|
* src/testpixbuf.c (expose_func): reverted the expose everything
|
||||||
|
changes, I'm not sure why these went in.
|
||||||
|
(config_func): bring this up to date with the new pixbuf_scale
|
||||||
|
semantics.
|
||||||
|
|
||||||
|
* src/gdk-pixbuf-io.c: added a couple of warnings to the module
|
||||||
|
loading code so that poeple can diagnose problems better.
|
||||||
|
|
||||||
|
* src/gdk-pixbuf.c (gdk_pixbux_scale): fix the borkedness, also it
|
||||||
|
no longer allocates a new pixbuf, which make things nicer for the
|
||||||
|
rest of the code. Unfortunately there is still a problem with
|
||||||
|
scaling rgba images.
|
||||||
|
|
||||||
1999-07-16 Mark Crichton <crichton@gimp.org>
|
1999-07-16 Mark Crichton <crichton@gimp.org>
|
||||||
|
|
||||||
* src/testpixbuf.c (config_func): ConfigureEvent handler. This
|
* src/testpixbuf.c (config_func): ConfigureEvent handler. This
|
||||||
|
@ -148,9 +148,11 @@ image_handler_load (int idx)
|
|||||||
g_free (module_name);
|
g_free (module_name);
|
||||||
|
|
||||||
module = g_module_open (path, G_MODULE_BIND_LAZY);
|
module = g_module_open (path, G_MODULE_BIND_LAZY);
|
||||||
if (!module)
|
if (!module) {
|
||||||
|
g_warning ("Unable to load module: %s", path);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
file_formats [idx].module = module;
|
file_formats [idx].module = module;
|
||||||
|
|
||||||
if (g_module_symbol (module, "image_load", &load_sym))
|
if (g_module_symbol (module, "image_load", &load_sym))
|
||||||
@ -196,6 +198,12 @@ gdk_pixbuf_load_image (const char *file)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fclose (f);
|
fclose (f);
|
||||||
|
g_warning ("Unable to find handler for file: %s", file);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Local variables:
|
||||||
|
* c-basic-offset: 8
|
||||||
|
* End:
|
||||||
|
*/
|
||||||
|
@ -51,42 +51,38 @@ gdk_pixbuf_scale (GdkPixBuf *pixbuf, gint w, gint h)
|
|||||||
{
|
{
|
||||||
GdkPixBuf *spb;
|
GdkPixBuf *spb;
|
||||||
art_u8 *pixels;
|
art_u8 *pixels;
|
||||||
|
gint rowstride;
|
||||||
double affine[6];
|
double affine[6];
|
||||||
ArtAlphaGamma *alphagamma;
|
ArtAlphaGamma *alphagamma;
|
||||||
|
ArtPixBuf *art_pixbuf = NULL;
|
||||||
|
|
||||||
alphagamma = NULL;
|
alphagamma = NULL;
|
||||||
|
|
||||||
affine[1] = affine[2] = affine[4] = affine[5] = 0;
|
affine[1] = affine[2] = affine[4] = affine[5] = 0;
|
||||||
|
|
||||||
affine[0] = w / (pixbuf->art_pixbuf->width);
|
|
||||||
affine[3] = h / (pixbuf->art_pixbuf->height);
|
affine[0] = w / (double)(pixbuf->art_pixbuf->width);
|
||||||
|
affine[3] = h / (double)(pixbuf->art_pixbuf->height);
|
||||||
|
|
||||||
spb = g_new (GdkPixBuf, 1);
|
// rowstride = w * pixbuf->art_pixbuf->n_channels;
|
||||||
|
rowstride = w * 3;
|
||||||
|
|
||||||
if (pixbuf->art_pixbuf->has_alpha) {
|
pixels = art_alloc (h * rowstride);
|
||||||
/* Following code is WRONG....of course, the code for this
|
art_rgb_pixbuf_affine( pixels, 0, 0, w, h, rowstride,
|
||||||
* transform isn't in libart yet.
|
pixbuf->art_pixbuf,
|
||||||
*/
|
affine, ART_FILTER_NEAREST, alphagamma);
|
||||||
#if 0
|
|
||||||
pixels = art_alloc (h * w * 4);
|
if (pixbuf->art_pixbuf->has_alpha)
|
||||||
art_rgb_affine( pixels, 0, 0, w, h, (w * 4),
|
// should be rgba
|
||||||
pixbuf->art_pixbuf->pixels,
|
art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride);
|
||||||
pixbuf->art_pixbuf->width,
|
else
|
||||||
pixbuf->art_pixbuf->height,
|
art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride);
|
||||||
pixbuf->art_pixbuf->rowstride,
|
|
||||||
affine, ART_FILTER_NEAREST, alphagamma);
|
art_pixbuf_free (pixbuf->art_pixbuf);
|
||||||
spb->art_pixbuf = art_pixbuf_new_rgba(pixels, w, h, (w * 4));
|
pixbuf->art_pixbuf = art_pixbuf;
|
||||||
#endif
|
|
||||||
} else {
|
return pixbuf;
|
||||||
pixels = art_alloc (h * w * 3);
|
|
||||||
art_rgb_affine( pixels, 0, 0, w, h, (w * 3),
|
|
||||||
pixbuf->art_pixbuf->pixels,
|
|
||||||
pixbuf->art_pixbuf->width,
|
|
||||||
pixbuf->art_pixbuf->height,
|
|
||||||
pixbuf->art_pixbuf->rowstride,
|
|
||||||
affine, ART_FILTER_NEAREST, alphagamma);
|
|
||||||
spb->art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, (w * 3));
|
|
||||||
spb->ref_count = 0;
|
|
||||||
spb->unref_func = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user