Most of this patch is based on a patch by Havoc Pennington (hp@redhat.com)
2000-04-11 Federico Mena Quintero <federico@helixcode.com> Most of this patch is based on a patch by Havoc Pennington (hp@redhat.com) to make GdkPixbuf's structures opaque and to remove the libart dependency. * gdk-pixbuf/gdk-pixbuf.h: Removed the public structures. (GdkColorspace): New enum that for now only contains GDK_COLORSPACE_RGB. (GdkPixbufDestroyNotify): New type for the pixbuf's pixels destroy notification function. (GdkInterpType): New num with interpolation types. * *.[ch]: Replace the libart stuff with our own stuff. * pixops/*.[ch]: Likewise. * gdk-pixbuf/gdk-pixbuf-private.h: New file with the private declarations of the GdkPixbuf structures. * gdk-pixbuf/gdk-pixbuf.c (gdk_pixbuf_new_from_art_pixbuf): Removed function. (gdk_pixbuf_get_format): Constify. (gdk_pixbuf_get_n_channels): Constify. (gdk_pixbuf_get_has_alpha): Constify. (gdk_pixbuf_get_bits_per_sample): Constify. (gdk_pixbuf_get_pixels): Constify. (gdk_pixbuf_get_width): Constify. (gdk_pixbuf_get_height): Constify. (gdk_pixbuf_get_rowstride): Constify. * gdk-pixbuf/gdk-pixbuf.c (gdk_pixbuf_copy): New function to copy a pixbuf. * gdk-pixbuf/gdk-pixbuf-data.c (gdk_pixbuf_new_from_data): Added a bits_per_sample argument; currently only 8 bits per sample are supported. * gdk-pixbuf/gdk-pixbuf-animation.c (gdk_pixbuf_frame_get_pixbuf): New accessor. (gdk_pixbuf_frame_get_x_offset): New accessor. (gdk_pixbuf_frame_get_y_offset): New accessor. (gdk_pixbuf_frame_get_delay_time): New accessor. (gdk_pixbuf_frame_get_action): New accessor. * gdk-pixbuf/gdk-pixbuf-render.c (gdk_pixbuf_render_pixmap_and_mask): Instead of returning a solid mask rectangle for pixbufs without an alpha channel, set the *mask_return to NULL. * gdk-pixbuf/gdk-pixbuf-util.c (gdk_pixbuf_add_alpha): Constify. * gdk-pixbuf/gdk-pixbuf-scale.c: Fix includes. * gdk-pixbuf/gdk-pixbuf-scale.c (gdk_pixbuf_scale): Added some preconditions. Maybe we should also check for the colorspace, bits per pixel, and such. (gdk_pixbuf_composite): Likewise. (gdk_pixbuf_composite_color): Likewise. (gdk_pixbuf_scale_simple): Likewise, and fail gracefully if we cannot allocate the new pixbuf. (gdk_pixbuf_composite_color_simple): Likewise. * gdk-pixbuf/gnome-canvas-pixbuf.c (gnome_canvas_pixbuf_render): Use art_rgb_rgba_affine() or art_rgb_affine() since we no longer have an ArtPixBuf. * gdk-pixbuf/io-bmp.c: Fix includes. * gdk-pixbuf/pixops/pixops.c (pixops_scale_nearest): Fixed cast in an lvalue. * TODO: Populated. * configure.in: Removed checks for libart. * gdk-pixbuf/Makefile.am: Removed references to libart. (noinst_HEADERS): Added gdk-pixbuf-private.h. * gdk-pixbuf/Makefile.am (libgdk_pixbuf_la_LDFLAGS): Incremented the version number of the libtool library to indicate that this definitely is not compatible with the old usage. I know you love me. I know you do. * configure.in: Bumped version number to 0.7.0. * README: Updated. * gdk-pixbuf-config.in (--libs): We no longer require libart. * DEPENDS.libgdk_pixbuf: We no longer depend on libart. * gdk-pixbuf.spec.in: Updated, but I don't guarantee anything.
This commit is contained in:

committed by
Federico Mena Quintero

parent
daaae930ad
commit
829ed02435
@ -19,12 +19,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include "gdk-pixbuf.h"
|
#include "gdk-pixbuf.h"
|
||||||
#include "gdk-pixbuf-io.h"
|
|
||||||
#include "gdk-pixbuf-loader.h"
|
#include "gdk-pixbuf-loader.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -201,22 +201,17 @@ expose_func (GtkWidget *drawing_area, GdkEventExpose *event, gpointer data)
|
|||||||
|
|
||||||
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) {
|
if (gdk_pixbuf_get_has_alpha (pixbuf)) {
|
||||||
g_warning ("art_pixbuf is NULL in expose_func!!\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
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,
|
||||||
event->area.x, event->area.y,
|
event->area.x, event->area.y,
|
||||||
event->area.width,
|
event->area.width,
|
||||||
event->area.height,
|
event->area.height,
|
||||||
GDK_RGB_DITHER_MAX,
|
GDK_RGB_DITHER_MAX,
|
||||||
pixbuf->art_pixbuf->pixels
|
gdk_pixbuf_get_pixels (pixbuf)
|
||||||
+ (event->area.y * pixbuf->art_pixbuf->rowstride)
|
+ (event->area.y * gdk_pixbuf_get_rowstride (pixbuf))
|
||||||
+ (event->area.x * pixbuf->art_pixbuf->n_channels),
|
+ (event->area.x * gdk_pixbuf_get_n_channels (pixbuf)),
|
||||||
pixbuf->art_pixbuf->rowstride);
|
gdk_pixbuf_get_rowstride (pixbuf));
|
||||||
} else {
|
} else {
|
||||||
gdk_draw_rgb_image (drawing_area->window,
|
gdk_draw_rgb_image (drawing_area->window,
|
||||||
drawing_area->style->white_gc,
|
drawing_area->style->white_gc,
|
||||||
@ -224,10 +219,10 @@ expose_func (GtkWidget *drawing_area, GdkEventExpose *event, gpointer data)
|
|||||||
event->area.width,
|
event->area.width,
|
||||||
event->area.height,
|
event->area.height,
|
||||||
GDK_RGB_DITHER_NORMAL,
|
GDK_RGB_DITHER_NORMAL,
|
||||||
pixbuf->art_pixbuf->pixels
|
gdk_pixbuf_get_pixels (pixbuf)
|
||||||
+ (event->area.y * pixbuf->art_pixbuf->rowstride)
|
+ (event->area.y * gdk_pixbuf_get_rowstride (pixbuf))
|
||||||
+ (event->area.x * pixbuf->art_pixbuf->n_channels),
|
+ (event->area.x * gdk_pixbuf_get_n_channels (pixbuf)),
|
||||||
pixbuf->art_pixbuf->rowstride);
|
gdk_pixbuf_get_rowstride (pixbuf));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,8 +234,8 @@ config_func (GtkWidget *drawing_area, GdkEventConfigure *event, gpointer data)
|
|||||||
pixbuf = (GdkPixbuf *)gtk_object_get_data(GTK_OBJECT(drawing_area), "pixbuf");
|
pixbuf = (GdkPixbuf *)gtk_object_get_data(GTK_OBJECT(drawing_area), "pixbuf");
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (((event->width) != (pixbuf->art_pixbuf->width)) ||
|
if (((event->width) != gdk_pixbuf_get_width (pixbuf)) ||
|
||||||
((event->height) != (pixbuf->art_pixbuf->height)))
|
((event->height) != gdk_pixbuf_get_height (pixbuf)))
|
||||||
gdk_pixbuf_scale(pixbuf, event->width, event->height);
|
gdk_pixbuf_scale(pixbuf, event->width, event->height);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -255,8 +250,8 @@ new_testrgb_window (GdkPixbuf *pixbuf, gchar *title)
|
|||||||
GtkWidget *drawing_area;
|
GtkWidget *drawing_area;
|
||||||
gint w, h;
|
gint w, h;
|
||||||
|
|
||||||
w = pixbuf->art_pixbuf->width;
|
w = gdk_pixbuf_get_width (pixbuf);
|
||||||
h = pixbuf->art_pixbuf->height;
|
h = gdk_pixbuf_get_height (pixbuf);
|
||||||
|
|
||||||
window = gtk_widget_new (gtk_window_get_type (),
|
window = gtk_widget_new (gtk_window_get_type (),
|
||||||
"GtkObject::user_data", NULL,
|
"GtkObject::user_data", NULL,
|
||||||
@ -306,6 +301,7 @@ new_testrgb_window (GdkPixbuf *pixbuf, gchar *title)
|
|||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
update_timeout(gpointer data)
|
update_timeout(gpointer data)
|
||||||
@ -367,6 +363,8 @@ progressive_updated_callback(GdkPixbufLoader* loader, guint x, guint y, guint wi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
static int readlen = 4096;
|
static int readlen = 4096;
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -376,7 +374,6 @@ main (int argc, char **argv)
|
|||||||
int found_valid = FALSE;
|
int found_valid = FALSE;
|
||||||
|
|
||||||
GdkPixbufAnimation *animation;
|
GdkPixbufAnimation *animation;
|
||||||
GdkPixbufLoader *pixbuf_loader;
|
|
||||||
|
|
||||||
gtk_init (&argc, &argv);
|
gtk_init (&argc, &argv);
|
||||||
|
|
||||||
@ -414,16 +411,24 @@ main (int argc, char **argv)
|
|||||||
if (animation) {
|
if (animation) {
|
||||||
gint i = 0;
|
gint i = 0;
|
||||||
GList *listptr;
|
GList *listptr;
|
||||||
for (listptr = animation->frames; listptr; listptr = listptr->next){
|
for (listptr = gdk_pixbuf_animation_get_frames (animation);
|
||||||
|
listptr;
|
||||||
|
listptr = listptr->next) {
|
||||||
|
GdkPixbufFrame *frame;
|
||||||
|
GdkPixbuf *pixbuf;
|
||||||
gchar *title;
|
gchar *title;
|
||||||
|
|
||||||
|
frame = listptr->data;
|
||||||
|
pixbuf = gdk_pixbuf_frame_get_pixbuf (frame);
|
||||||
|
|
||||||
title = g_strdup_printf ("Frame %d", i);
|
title = g_strdup_printf ("Frame %d", i);
|
||||||
g_print ("Frame %d x:%d y:%d width:%d height:%d\n",
|
g_print ("Frame %d x:%d y:%d width:%d height:%d\n",
|
||||||
i,
|
i,
|
||||||
((GdkPixbufFrame *)listptr->data)->x_offset,
|
gdk_pixbuf_frame_get_x_offset (frame),
|
||||||
((GdkPixbufFrame *)listptr->data)->y_offset,
|
gdk_pixbuf_frame_get_y_offset (frame),
|
||||||
gdk_pixbuf_get_width (((GdkPixbufFrame *)listptr->data)->pixbuf),
|
gdk_pixbuf_get_width (pixbuf),
|
||||||
gdk_pixbuf_get_height (((GdkPixbufFrame *)listptr->data)->pixbuf));
|
gdk_pixbuf_get_height (pixbuf));
|
||||||
new_testrgb_window (((GdkPixbufFrame *)listptr->data)->pixbuf, title);
|
new_testrgb_window (pixbuf, title);
|
||||||
g_free (title);
|
g_free (title);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@ -434,6 +439,7 @@ main (int argc, char **argv)
|
|||||||
{
|
{
|
||||||
GtkWidget* rgb_window = NULL;
|
GtkWidget* rgb_window = NULL;
|
||||||
ProgressFileStatus status;
|
ProgressFileStatus status;
|
||||||
|
GdkPixbufLoader *pixbuf_loader;
|
||||||
|
|
||||||
pixbuf_loader = gdk_pixbuf_loader_new ();
|
pixbuf_loader = gdk_pixbuf_loader_new ();
|
||||||
status.loader = pixbuf_loader;
|
status.loader = pixbuf_loader;
|
||||||
|
@ -15,7 +15,7 @@ int expose_cb(GtkWidget *drawing_area, GdkEventExpose *evt, gpointer data)
|
|||||||
|
|
||||||
pixbuf = (GdkPixbuf *) gtk_object_get_data(GTK_OBJECT(drawing_area),
|
pixbuf = (GdkPixbuf *) gtk_object_get_data(GTK_OBJECT(drawing_area),
|
||||||
"pixbuf");
|
"pixbuf");
|
||||||
if(pixbuf->art_pixbuf->has_alpha)
|
if(gdk_pixbuf_get_has_alpha (pixbuf))
|
||||||
{
|
{
|
||||||
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,
|
||||||
@ -23,10 +23,10 @@ int expose_cb(GtkWidget *drawing_area, GdkEventExpose *evt, gpointer data)
|
|||||||
evt->area.width,
|
evt->area.width,
|
||||||
evt->area.height,
|
evt->area.height,
|
||||||
GDK_RGB_DITHER_MAX,
|
GDK_RGB_DITHER_MAX,
|
||||||
pixbuf->art_pixbuf->pixels +
|
gdk_pixbuf_get_pixels (pixbuf) +
|
||||||
(evt->area.y * pixbuf->art_pixbuf->rowstride) +
|
(evt->area.y * gdk_pixbuf_get_rowstride (pixbuf)) +
|
||||||
(evt->area.x * pixbuf->art_pixbuf->n_channels),
|
(evt->area.x * gdk_pixbuf_get_n_channels (pixbuf)),
|
||||||
pixbuf->art_pixbuf->rowstride);
|
gdk_pixbuf_get_rowstride (pixbuf));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -36,10 +36,10 @@ int expose_cb(GtkWidget *drawing_area, GdkEventExpose *evt, gpointer data)
|
|||||||
evt->area.width,
|
evt->area.width,
|
||||||
evt->area.height,
|
evt->area.height,
|
||||||
GDK_RGB_DITHER_NORMAL,
|
GDK_RGB_DITHER_NORMAL,
|
||||||
pixbuf->art_pixbuf->pixels +
|
gdk_pixbuf_get_pixels (pixbuf) +
|
||||||
(evt->area.y * pixbuf->art_pixbuf->rowstride) +
|
(evt->area.y * gdk_pixbuf_get_rowstride (pixbuf)) +
|
||||||
(evt->area.x * pixbuf->art_pixbuf->n_channels),
|
(evt->area.x * gdk_pixbuf_get_n_channels (pixbuf)),
|
||||||
pixbuf->art_pixbuf->rowstride);
|
gdk_pixbuf_get_rowstride (pixbuf));
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -52,7 +52,7 @@ int configure_cb(GtkWidget *drawing_area, GdkEventConfigure *evt, gpointer data)
|
|||||||
"pixbuf");
|
"pixbuf");
|
||||||
|
|
||||||
g_print("X:%d Y:%d\n", evt->width, evt->height);
|
g_print("X:%d Y:%d\n", evt->width, evt->height);
|
||||||
if(evt->width != pixbuf->art_pixbuf->width || evt->height != pixbuf->art_pixbuf->height)
|
if(evt->width != gdk_pixbuf_get_width (pixbuf) || evt->height != gdk_pixbuf_get_height (pixbuf))
|
||||||
{
|
{
|
||||||
GdkWindow *root;
|
GdkWindow *root;
|
||||||
GdkPixbuf *new_pixbuf;
|
GdkPixbuf *new_pixbuf;
|
||||||
@ -97,8 +97,8 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
drawing_area = gtk_drawing_area_new();
|
drawing_area = gtk_drawing_area_new();
|
||||||
gtk_drawing_area_size(GTK_DRAWING_AREA(drawing_area),
|
gtk_drawing_area_size(GTK_DRAWING_AREA(drawing_area),
|
||||||
pixbuf->art_pixbuf->width,
|
gdk_pixbuf_get_width (pixbuf),
|
||||||
pixbuf->art_pixbuf->height);
|
gdk_pixbuf_get_height (pixbuf));
|
||||||
gtk_signal_connect(GTK_OBJECT(drawing_area), "expose_event",
|
gtk_signal_connect(GTK_OBJECT(drawing_area), "expose_event",
|
||||||
GTK_SIGNAL_FUNC(expose_cb), NULL);
|
GTK_SIGNAL_FUNC(expose_cb), NULL);
|
||||||
|
|
||||||
|
@ -3,15 +3,15 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
ArtFilterLevel filter_level = ART_FILTER_BILINEAR;
|
GdkInterpType interp_type = GDK_INTERP_BILINEAR;
|
||||||
int overall_alpha = 255;
|
int overall_alpha = 255;
|
||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
GtkWidget *darea;
|
GtkWidget *darea;
|
||||||
|
|
||||||
void
|
void
|
||||||
set_filter_level (GtkWidget *widget, gpointer data)
|
set_interp_type (GtkWidget *widget, gpointer data)
|
||||||
{
|
{
|
||||||
filter_level = GPOINTER_TO_UINT (data);
|
interp_type = GPOINTER_TO_UINT (data);
|
||||||
gtk_widget_queue_draw (darea);
|
gtk_widget_queue_draw (darea);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,14 +32,14 @@ expose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
|
|||||||
|
|
||||||
gdk_window_set_back_pixmap (widget->window, NULL, FALSE);
|
gdk_window_set_back_pixmap (widget->window, NULL, FALSE);
|
||||||
|
|
||||||
dest = gdk_pixbuf_new (ART_PIX_RGB, FALSE, 8, event->area.width, event->area.height);
|
dest = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, event->area.width, event->area.height);
|
||||||
|
|
||||||
gdk_pixbuf_composite_color (pixbuf, dest,
|
gdk_pixbuf_composite_color (pixbuf, dest,
|
||||||
0, 0, event->area.width, event->area.height,
|
0, 0, event->area.width, event->area.height,
|
||||||
-event->area.x, -event->area.y,
|
-event->area.x, -event->area.y,
|
||||||
(double) widget->allocation.width / pixbuf->art_pixbuf->width,
|
(double) widget->allocation.width / gdk_pixbuf_get_width (pixbuf),
|
||||||
(double) widget->allocation.height / pixbuf->art_pixbuf->height,
|
(double) widget->allocation.height / gdk_pixbuf_get_height (pixbuf),
|
||||||
filter_level, overall_alpha,
|
interp_type, overall_alpha,
|
||||||
event->area.x, event->area.y, 16, 0xaaaaaa, 0x555555);
|
event->area.x, event->area.y, 16, 0xaaaaaa, 0x555555);
|
||||||
|
|
||||||
gdk_pixbuf_render_to_drawable (dest, widget->window, widget->style->fg_gc[GTK_STATE_NORMAL],
|
gdk_pixbuf_render_to_drawable (dest, widget->window, widget->style->fg_gc[GTK_STATE_NORMAL],
|
||||||
@ -87,28 +87,28 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
menuitem = gtk_menu_item_new_with_label ("NEAREST");
|
menuitem = gtk_menu_item_new_with_label ("NEAREST");
|
||||||
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
|
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
|
||||||
GTK_SIGNAL_FUNC (set_filter_level),
|
GTK_SIGNAL_FUNC (set_interp_type),
|
||||||
GUINT_TO_POINTER (ART_FILTER_NEAREST));
|
GUINT_TO_POINTER (GDK_INTERP_NEAREST));
|
||||||
gtk_widget_show (menuitem);
|
gtk_widget_show (menuitem);
|
||||||
gtk_container_add (GTK_CONTAINER (menu), menuitem);
|
gtk_container_add (GTK_CONTAINER (menu), menuitem);
|
||||||
|
|
||||||
menuitem = gtk_menu_item_new_with_label ("BILINEAR");
|
menuitem = gtk_menu_item_new_with_label ("BILINEAR");
|
||||||
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
|
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
|
||||||
GTK_SIGNAL_FUNC (set_filter_level),
|
GTK_SIGNAL_FUNC (set_interp_type),
|
||||||
GUINT_TO_POINTER (ART_FILTER_BILINEAR));
|
GUINT_TO_POINTER (GDK_INTERP_BILINEAR));
|
||||||
gtk_widget_show (menuitem);
|
gtk_widget_show (menuitem);
|
||||||
gtk_container_add (GTK_CONTAINER (menu), menuitem);
|
gtk_container_add (GTK_CONTAINER (menu), menuitem);
|
||||||
|
|
||||||
menuitem = gtk_menu_item_new_with_label ("TILES");
|
menuitem = gtk_menu_item_new_with_label ("TILES");
|
||||||
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
|
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
|
||||||
GTK_SIGNAL_FUNC (set_filter_level),
|
GTK_SIGNAL_FUNC (set_interp_type),
|
||||||
GUINT_TO_POINTER (ART_FILTER_TILES));
|
GUINT_TO_POINTER (GDK_INTERP_TILES));
|
||||||
gtk_container_add (GTK_CONTAINER (menu), menuitem);
|
gtk_container_add (GTK_CONTAINER (menu), menuitem);
|
||||||
|
|
||||||
menuitem = gtk_menu_item_new_with_label ("HYPER");
|
menuitem = gtk_menu_item_new_with_label ("HYPER");
|
||||||
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
|
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
|
||||||
GTK_SIGNAL_FUNC (set_filter_level),
|
GTK_SIGNAL_FUNC (set_interp_type),
|
||||||
GUINT_TO_POINTER (ART_FILTER_HYPER));
|
GUINT_TO_POINTER (GDK_INTERP_HYPER));
|
||||||
gtk_container_add (GTK_CONTAINER (menu), menuitem);
|
gtk_container_add (GTK_CONTAINER (menu), menuitem);
|
||||||
|
|
||||||
optionmenu = gtk_option_menu_new ();
|
optionmenu = gtk_option_menu_new ();
|
||||||
@ -145,8 +145,8 @@ main(int argc, char **argv)
|
|||||||
GTK_SIGNAL_FUNC (expose_cb), NULL);
|
GTK_SIGNAL_FUNC (expose_cb), NULL);
|
||||||
|
|
||||||
gtk_window_set_default_size (GTK_WINDOW (window),
|
gtk_window_set_default_size (GTK_WINDOW (window),
|
||||||
pixbuf->art_pixbuf->width,
|
gdk_pixbuf_get_width (pixbuf),
|
||||||
scratch_requisition.height + pixbuf->art_pixbuf->height);
|
scratch_requisition.height + gdk_pixbuf_get_height (pixbuf));
|
||||||
|
|
||||||
gtk_widget_show_all (window);
|
gtk_widget_show_all (window);
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/* testpixbuf -- test program for gdk-pixbuf code
|
/* testpixbuf -- test program for gdk-pixbuf code
|
||||||
* Copyright (C) 1999 Mark Crichton, Larry Ewing
|
* Copyright (C) 1999 Mark Crichton, Larry Ewing
|
||||||
*
|
*
|
||||||
@ -19,12 +18,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include "gdk-pixbuf.h"
|
#include "gdk-pixbuf.h"
|
||||||
#include "gdk-pixbuf-io.h"
|
|
||||||
#include "gdk-pixbuf-loader.h"
|
#include "gdk-pixbuf-loader.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -34,7 +33,6 @@ typedef struct {
|
|||||||
guchar *buf;
|
guchar *buf;
|
||||||
guint timeout;
|
guint timeout;
|
||||||
guint readlen;
|
guint readlen;
|
||||||
|
|
||||||
} ProgressFileStatus;
|
} ProgressFileStatus;
|
||||||
|
|
||||||
|
|
||||||
@ -321,22 +319,17 @@ expose_func (GtkWidget *drawing_area, GdkEventExpose *event, gpointer data)
|
|||||||
|
|
||||||
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) {
|
if (gdk_pixbuf_get_has_alpha (pixbuf)) {
|
||||||
g_warning ("art_pixbuf is NULL in expose_func!!\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
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,
|
||||||
event->area.x, event->area.y,
|
event->area.x, event->area.y,
|
||||||
event->area.width,
|
event->area.width,
|
||||||
event->area.height,
|
event->area.height,
|
||||||
GDK_RGB_DITHER_MAX,
|
GDK_RGB_DITHER_MAX,
|
||||||
pixbuf->art_pixbuf->pixels
|
gdk_pixbuf_get_pixels (pixbuf)
|
||||||
+ (event->area.y * pixbuf->art_pixbuf->rowstride)
|
+ (event->area.y * gdk_pixbuf_get_rowstride (pixbuf))
|
||||||
+ (event->area.x * pixbuf->art_pixbuf->n_channels),
|
+ (event->area.x * gdk_pixbuf_get_n_channels (pixbuf)),
|
||||||
pixbuf->art_pixbuf->rowstride);
|
gdk_pixbuf_get_rowstride (pixbuf));
|
||||||
} else {
|
} else {
|
||||||
gdk_draw_rgb_image (drawing_area->window,
|
gdk_draw_rgb_image (drawing_area->window,
|
||||||
drawing_area->style->white_gc,
|
drawing_area->style->white_gc,
|
||||||
@ -344,10 +337,10 @@ expose_func (GtkWidget *drawing_area, GdkEventExpose *event, gpointer data)
|
|||||||
event->area.width,
|
event->area.width,
|
||||||
event->area.height,
|
event->area.height,
|
||||||
GDK_RGB_DITHER_NORMAL,
|
GDK_RGB_DITHER_NORMAL,
|
||||||
pixbuf->art_pixbuf->pixels
|
gdk_pixbuf_get_pixels (pixbuf)
|
||||||
+ (event->area.y * pixbuf->art_pixbuf->rowstride)
|
+ (event->area.y * gdk_pixbuf_get_rowstride (pixbuf))
|
||||||
+ (event->area.x * pixbuf->art_pixbuf->n_channels),
|
+ (event->area.x * gdk_pixbuf_get_n_channels (pixbuf)),
|
||||||
pixbuf->art_pixbuf->rowstride);
|
gdk_pixbuf_get_rowstride (pixbuf));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -361,8 +354,8 @@ 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 0
|
#if 0
|
||||||
if (((event->width) != (pixbuf->art_pixbuf->width)) ||
|
if (((event->width) != gdk_pixbuf_get_width (pixbuf)) ||
|
||||||
((event->height) != (pixbuf->art_pixbuf->height)))
|
((event->height) != gdk_pixbuf_get_height (pixbuf)))
|
||||||
gdk_pixbuf_scale(pixbuf, event->width, event->height);
|
gdk_pixbuf_scale(pixbuf, event->width, event->height);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -377,8 +370,8 @@ new_testrgb_window (GdkPixbuf *pixbuf, gchar *title)
|
|||||||
GtkWidget *drawing_area;
|
GtkWidget *drawing_area;
|
||||||
gint w, h;
|
gint w, h;
|
||||||
|
|
||||||
w = pixbuf->art_pixbuf->width;
|
w = gdk_pixbuf_get_width (pixbuf);
|
||||||
h = pixbuf->art_pixbuf->height;
|
h = gdk_pixbuf_get_height (pixbuf);
|
||||||
|
|
||||||
window = gtk_widget_new (gtk_window_get_type (),
|
window = gtk_widget_new (gtk_window_get_type (),
|
||||||
"GtkObject::user_data", NULL,
|
"GtkObject::user_data", NULL,
|
||||||
@ -529,7 +522,7 @@ main (int argc, char **argv)
|
|||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
const gchar*** xpmp;
|
const gchar*** xpmp;
|
||||||
|
|
||||||
pixbuf = gdk_pixbuf_new_from_data (default_image, ART_PIX_RGB, FALSE,
|
pixbuf = gdk_pixbuf_new_from_data (default_image, GDK_COLORSPACE_RGB, FALSE, 8,
|
||||||
DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_WIDTH * 3,
|
DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_WIDTH * 3,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
new_testrgb_window (pixbuf, NULL);
|
new_testrgb_window (pixbuf, NULL);
|
||||||
|
@ -1,3 +1,97 @@
|
|||||||
|
2000-04-11 Federico Mena Quintero <federico@helixcode.com>
|
||||||
|
|
||||||
|
Most of this patch is based on a patch by Havoc Pennington
|
||||||
|
(hp@redhat.com) to make GdkPixbuf's structures opaque and to
|
||||||
|
remove the libart dependency.
|
||||||
|
|
||||||
|
* gdk-pixbuf/gdk-pixbuf.h: Removed the public structures.
|
||||||
|
(GdkColorspace): New enum that for now only contains
|
||||||
|
GDK_COLORSPACE_RGB.
|
||||||
|
(GdkPixbufDestroyNotify): New type for the pixbuf's pixels destroy
|
||||||
|
notification function.
|
||||||
|
(GdkInterpType): New num with interpolation types.
|
||||||
|
|
||||||
|
* *.[ch]: Replace the libart stuff with our own stuff.
|
||||||
|
|
||||||
|
* pixops/*.[ch]: Likewise.
|
||||||
|
|
||||||
|
* gdk-pixbuf/gdk-pixbuf-private.h: New file with the private
|
||||||
|
declarations of the GdkPixbuf structures.
|
||||||
|
|
||||||
|
* gdk-pixbuf/gdk-pixbuf.c (gdk_pixbuf_new_from_art_pixbuf):
|
||||||
|
Removed function.
|
||||||
|
(gdk_pixbuf_get_format): Constify.
|
||||||
|
(gdk_pixbuf_get_n_channels): Constify.
|
||||||
|
(gdk_pixbuf_get_has_alpha): Constify.
|
||||||
|
(gdk_pixbuf_get_bits_per_sample): Constify.
|
||||||
|
(gdk_pixbuf_get_pixels): Constify.
|
||||||
|
(gdk_pixbuf_get_width): Constify.
|
||||||
|
(gdk_pixbuf_get_height): Constify.
|
||||||
|
(gdk_pixbuf_get_rowstride): Constify.
|
||||||
|
|
||||||
|
* gdk-pixbuf/gdk-pixbuf.c (gdk_pixbuf_copy): New function to copy
|
||||||
|
a pixbuf.
|
||||||
|
|
||||||
|
* gdk-pixbuf/gdk-pixbuf-data.c (gdk_pixbuf_new_from_data): Added a
|
||||||
|
bits_per_sample argument; currently only 8 bits per sample are
|
||||||
|
supported.
|
||||||
|
|
||||||
|
* gdk-pixbuf/gdk-pixbuf-animation.c (gdk_pixbuf_frame_get_pixbuf):
|
||||||
|
New accessor.
|
||||||
|
(gdk_pixbuf_frame_get_x_offset): New accessor.
|
||||||
|
(gdk_pixbuf_frame_get_y_offset): New accessor.
|
||||||
|
(gdk_pixbuf_frame_get_delay_time): New accessor.
|
||||||
|
(gdk_pixbuf_frame_get_action): New accessor.
|
||||||
|
|
||||||
|
* gdk-pixbuf/gdk-pixbuf-render.c
|
||||||
|
(gdk_pixbuf_render_pixmap_and_mask): Instead of returning a solid
|
||||||
|
mask rectangle for pixbufs without an alpha channel, set the
|
||||||
|
*mask_return to NULL.
|
||||||
|
|
||||||
|
* gdk-pixbuf/gdk-pixbuf-util.c (gdk_pixbuf_add_alpha): Constify.
|
||||||
|
|
||||||
|
* gdk-pixbuf/gdk-pixbuf-scale.c: Fix includes.
|
||||||
|
|
||||||
|
* gdk-pixbuf/gdk-pixbuf-scale.c (gdk_pixbuf_scale): Added some
|
||||||
|
preconditions. Maybe we should also check for the colorspace,
|
||||||
|
bits per pixel, and such.
|
||||||
|
(gdk_pixbuf_composite): Likewise.
|
||||||
|
(gdk_pixbuf_composite_color): Likewise.
|
||||||
|
(gdk_pixbuf_scale_simple): Likewise, and fail gracefully if we
|
||||||
|
cannot allocate the new pixbuf.
|
||||||
|
(gdk_pixbuf_composite_color_simple): Likewise.
|
||||||
|
|
||||||
|
* gdk-pixbuf/gnome-canvas-pixbuf.c (gnome_canvas_pixbuf_render):
|
||||||
|
Use art_rgb_rgba_affine() or art_rgb_affine() since we no longer
|
||||||
|
have an ArtPixBuf.
|
||||||
|
|
||||||
|
* gdk-pixbuf/io-bmp.c: Fix includes.
|
||||||
|
|
||||||
|
* gdk-pixbuf/pixops/pixops.c (pixops_scale_nearest): Fixed cast in
|
||||||
|
an lvalue.
|
||||||
|
|
||||||
|
* TODO: Populated.
|
||||||
|
|
||||||
|
* configure.in: Removed checks for libart.
|
||||||
|
|
||||||
|
* gdk-pixbuf/Makefile.am: Removed references to libart.
|
||||||
|
(noinst_HEADERS): Added gdk-pixbuf-private.h.
|
||||||
|
|
||||||
|
* gdk-pixbuf/Makefile.am (libgdk_pixbuf_la_LDFLAGS): Incremented
|
||||||
|
the version number of the libtool library to indicate that this
|
||||||
|
definitely is not compatible with the old usage. I know you love
|
||||||
|
me. I know you do.
|
||||||
|
|
||||||
|
* configure.in: Bumped version number to 0.7.0.
|
||||||
|
|
||||||
|
* README: Updated.
|
||||||
|
|
||||||
|
* gdk-pixbuf-config.in (--libs): We no longer require libart.
|
||||||
|
|
||||||
|
* DEPENDS.libgdk_pixbuf: We no longer depend on libart.
|
||||||
|
|
||||||
|
* gdk-pixbuf.spec.in: Updated, but I don't guarantee anything.
|
||||||
|
|
||||||
2000-04-06 Jonathan Blandford <jrb@redhat.com>
|
2000-04-06 Jonathan Blandford <jrb@redhat.com>
|
||||||
|
|
||||||
* gdk-pixbuf/testanimation.c (main): add more info to the
|
* gdk-pixbuf/testanimation.c (main): add more info to the
|
||||||
|
@ -144,25 +144,25 @@ DEPS = libgdk_pixbuf.la
|
|||||||
INCLUDES = -I$(top_srcdir) -I$(top_builddir) \
|
INCLUDES = -I$(top_srcdir) -I$(top_builddir) \
|
||||||
-I$(top_srcdir)/gdk-pixbuf \
|
-I$(top_srcdir)/gdk-pixbuf \
|
||||||
-I$(top_builddir)/gdk-pixbuf \
|
-I$(top_builddir)/gdk-pixbuf \
|
||||||
$(GLIB_CFLAGS) $(LIBART_CFLAGS) $(GTK_CFLAGS)
|
$(GLIB_CFLAGS) $(GTK_CFLAGS)
|
||||||
AM_CPPFLAGS = "-DPIXBUF_LIBDIR=\"$(libexecdir)\""
|
AM_CPPFLAGS = "-DPIXBUF_LIBDIR=\"$(libexecdir)\""
|
||||||
|
|
||||||
LDADDS = libgdk_pixbuf.la $(LIBART_LIBS) $(GLIB_LIBS) $(GTK_LIBS) $(STATIC_LIB_DEPS)
|
LDADDS = libgdk_pixbuf.la $(GLIB_LIBS) $(GTK_LIBS) $(STATIC_LIB_DEPS)
|
||||||
|
|
||||||
if INSIDE_GNOME_LIBS
|
if INSIDE_GNOME_LIBS
|
||||||
testpixbuf_LDADD = $(LDADDS) $(LIBART_LIBS) -lgmodule
|
testpixbuf_LDADD = $(LDADDS) -lgmodule
|
||||||
testpixbuf_drawable_LDADD = $(LDADDS)
|
testpixbuf_drawable_LDADD = $(LDADDS)
|
||||||
testpixbuf_scale_LDADD = $(LDADDS)
|
testpixbuf_scale_LDADD = $(LDADDS)
|
||||||
testanimation_LDADD = $(LDADDS) $(LIBART_LIBS) -lgmodule
|
testanimation_LDADD = $(LDADDS) -lgmodule
|
||||||
else
|
else
|
||||||
testpixbuf_LDADD = $(LDADDS) $(LIBART_LIBS) $(GNOME_LIBS) -lgmodule
|
testpixbuf_LDADD = $(LDADDS) $(GNOME_LIBS) -lgmodule
|
||||||
testpixbuf_drawable_LDADD = $(LDADDS) $(GNOME_LIBS)
|
testpixbuf_drawable_LDADD = $(LDADDS) $(GNOME_LIBS)
|
||||||
testpixbuf_scale_LDADD = $(LDADDS) $(GNOME_LIBS)
|
testpixbuf_scale_LDADD = $(LDADDS) $(GNOME_LIBS)
|
||||||
testanimation_LDADD = $(LDADDS) $(LIBART_LIBS) $(GNOME_LIBS) -lgmodule
|
testanimation_LDADD = $(LDADDS) $(GNOME_LIBS) -lgmodule
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
GDK_PIXBUF_LIBS = $(LIBART_LIBS) $(GLIB_LIBS) $(GTK_LIBS)
|
GDK_PIXBUF_LIBS = $(GLIB_LIBS) $(GTK_LIBS)
|
||||||
|
|
||||||
#
|
#
|
||||||
# The GdkPixBuf library
|
# The GdkPixBuf library
|
||||||
@ -182,7 +182,7 @@ libgdk_pixbuf_la_SOURCES = \
|
|||||||
gdk-pixbuf-util.c \
|
gdk-pixbuf-util.c \
|
||||||
$(extra_sources)
|
$(extra_sources)
|
||||||
|
|
||||||
libgdk_pixbuf_la_LDFLAGS = -version-info 1:0:0 $(LIBART_LIBS) $(GLIB_LIBS) $(GTK_LIBS)
|
libgdk_pixbuf_la_LDFLAGS = -version-info 2:0:0 $(GLIB_LIBS) $(GTK_LIBS)
|
||||||
libgdk_pixbuf_la_LIBADD = pixops/libpixops.la
|
libgdk_pixbuf_la_LIBADD = pixops/libpixops.la
|
||||||
|
|
||||||
libgdk_pixbufinclude_HEADERS = \
|
libgdk_pixbufinclude_HEADERS = \
|
||||||
@ -191,6 +191,6 @@ libgdk_pixbufinclude_HEADERS = \
|
|||||||
gdk-pixbuf-features.h \
|
gdk-pixbuf-features.h \
|
||||||
$(CANVAS_PIXBUF_HEADERFILES)
|
$(CANVAS_PIXBUF_HEADERFILES)
|
||||||
|
|
||||||
noinst_HEADERS = \
|
noinst_HEADERS = \
|
||||||
gdk-pixbuf-io.h
|
gdk-pixbuf-io.h \
|
||||||
|
gdk-pixbuf-private.h
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include "gdk-pixbuf-io.h"
|
#include "gdk-pixbuf-io.h"
|
||||||
|
#include "gdk-pixbuf-private.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -223,3 +224,85 @@ gdk_pixbuf_animation_get_frames (GdkPixbufAnimation *animation)
|
|||||||
|
|
||||||
return animation->frames;
|
return animation->frames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gdk_pixbuf_frame_get_pixbuf:
|
||||||
|
* @frame: A pixbuf animation frame.
|
||||||
|
*
|
||||||
|
* Queries the pixbuf of an animation frame.
|
||||||
|
*
|
||||||
|
* Return value: A pixbuf.
|
||||||
|
**/
|
||||||
|
GdkPixbuf *
|
||||||
|
gdk_pixbuf_frame_get_pixbuf (GdkPixbufFrame *frame)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (frame != NULL, NULL);
|
||||||
|
|
||||||
|
return frame->pixbuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gdk_pixbuf_frame_get_x_offset:
|
||||||
|
* @frame: A pixbuf animation frame.
|
||||||
|
*
|
||||||
|
* Queries the X offset of an animation frame.
|
||||||
|
*
|
||||||
|
* Return value: X offset from the top left corner of the animation.
|
||||||
|
**/
|
||||||
|
int
|
||||||
|
gdk_pixbuf_frame_get_x_offset (GdkPixbufFrame *frame)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (frame != NULL, -1);
|
||||||
|
|
||||||
|
return frame->x_offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gdk_pixbuf_frame_get_y_offset:
|
||||||
|
* @frame: A pixbuf animation frame.
|
||||||
|
*
|
||||||
|
* Queries the Y offset of an animation frame.
|
||||||
|
*
|
||||||
|
* Return value: Y offset from the top left corner of the animation.
|
||||||
|
**/
|
||||||
|
int
|
||||||
|
gdk_pixbuf_frame_get_y_offset (GdkPixbufFrame *frame)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (frame != NULL, -1);
|
||||||
|
|
||||||
|
return frame->y_offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gdk_pixbuf_frame_get_delay_time:
|
||||||
|
* @frame: A pixbuf animation frame.
|
||||||
|
*
|
||||||
|
* Queries the delay time in milliseconds of an animation frame.
|
||||||
|
*
|
||||||
|
* Return value: Delay time in milliseconds.
|
||||||
|
**/
|
||||||
|
int
|
||||||
|
gdk_pixbuf_frame_get_delay_time (GdkPixbufFrame *frame)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (frame != NULL, -1);
|
||||||
|
|
||||||
|
return frame->delay_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gdk_pixbuf_frame_get_action:
|
||||||
|
* @frame: A pixbuf animation frame.
|
||||||
|
*
|
||||||
|
* Queries the overlay action of an animation frame.
|
||||||
|
*
|
||||||
|
* Return value: Overlay action for this frame.
|
||||||
|
**/
|
||||||
|
GdkPixbufFrameAction
|
||||||
|
gdk_pixbuf_frame_get_action (GdkPixbufFrame *frame)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (frame != NULL, GDK_PIXBUF_FRAME_RETAIN);
|
||||||
|
|
||||||
|
return frame->action;
|
||||||
|
}
|
||||||
|
@ -22,48 +22,56 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include "gdk-pixbuf.h"
|
#include "gdk-pixbuf.h"
|
||||||
|
#include "gdk-pixbuf-private.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gdk_pixbuf_new_from_data:
|
* gdk_pixbuf_new_from_data:
|
||||||
* @data: Image data in 8-bit/sample packed format.
|
* @data: Image data in 8-bit/sample packed format.
|
||||||
* @format: Color format used for the data.
|
* @colorspace: Colorspace for the image data.
|
||||||
* @has_alpha: Whether the data has an opacity channel.
|
* @has_alpha: Whether the data has an opacity channel.
|
||||||
|
* @bits_per_sample: Number of bits per sample.
|
||||||
* @width: Width of the image in pixels.
|
* @width: Width of the image in pixels.
|
||||||
* @height: Height of the image in pixels.
|
* @height: Height of the image in pixels.
|
||||||
* @rowstride: Distance in bytes between rows.
|
* @rowstride: Distance in bytes between rows.
|
||||||
* @dfunc: Function used to free the data when the pixbuf's reference count
|
* @destroy_fn: Function used to free the data when the pixbuf's reference count
|
||||||
* drops to zero, or NULL if the data should not be freed.
|
* drops to zero, or NULL if the data should not be freed.
|
||||||
* @dfunc_data: Closure data to pass to the destroy notification function.
|
* @destroy_fn_data: Closure data to pass to the destroy notification function.
|
||||||
*
|
*
|
||||||
* Creates a new #GdkPixbuf out of in-memory RGB data.
|
* Creates a new #GdkPixbuf out of in-memory image data. Currently only RGB
|
||||||
|
* images with 8 bits per sample are supported.
|
||||||
*
|
*
|
||||||
* Return value: A newly-created #GdkPixbuf structure with a reference count of
|
* Return value: A newly-created #GdkPixbuf structure with a reference count of
|
||||||
* 1.
|
* 1.
|
||||||
**/
|
**/
|
||||||
GdkPixbuf *
|
GdkPixbuf *
|
||||||
gdk_pixbuf_new_from_data (const guchar *data, ArtPixFormat format, gboolean has_alpha,
|
gdk_pixbuf_new_from_data (const guchar *data, GdkColorspace colorspace, gboolean has_alpha,
|
||||||
int width, int height, int rowstride,
|
int bits_per_sample, int width, int height, int rowstride,
|
||||||
ArtDestroyNotify dfunc, gpointer dfunc_data)
|
GdkPixbufDestroyNotify destroy_fn, gpointer destroy_fn_data)
|
||||||
{
|
{
|
||||||
ArtPixBuf *art_pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
|
|
||||||
/* Only 8-bit/sample RGB buffers are supported for now */
|
/* Only 8-bit/sample RGB buffers are supported for now */
|
||||||
|
|
||||||
g_return_val_if_fail (data != NULL, NULL);
|
g_return_val_if_fail (data != NULL, NULL);
|
||||||
g_return_val_if_fail (format == ART_PIX_RGB, NULL);
|
g_return_val_if_fail (colorspace == GDK_COLORSPACE_RGB, NULL);
|
||||||
|
g_return_val_if_fail (bits_per_sample == 8, NULL);
|
||||||
g_return_val_if_fail (width > 0, NULL);
|
g_return_val_if_fail (width > 0, NULL);
|
||||||
g_return_val_if_fail (height > 0, NULL);
|
g_return_val_if_fail (height > 0, NULL);
|
||||||
|
|
||||||
if (has_alpha)
|
pixbuf = g_new (GdkPixbuf, 1);
|
||||||
art_pixbuf = art_pixbuf_new_rgba_dnotify ((art_u8 *)data, width, height, rowstride,
|
pixbuf->ref_count = 1;
|
||||||
dfunc_data, dfunc);
|
pixbuf->colorspace = colorspace;
|
||||||
else
|
pixbuf->n_channels = has_alpha ? 4 : 3;
|
||||||
art_pixbuf = art_pixbuf_new_rgb_dnotify ((art_u8 *)data, width, height, rowstride,
|
pixbuf->bits_per_sample = bits_per_sample;
|
||||||
dfunc_data, dfunc);
|
pixbuf->has_alpha = has_alpha ? TRUE : FALSE;
|
||||||
|
pixbuf->width = width;
|
||||||
|
pixbuf->height = height;
|
||||||
|
pixbuf->rowstride = rowstride;
|
||||||
|
pixbuf->pixels = (guchar *) data;
|
||||||
|
pixbuf->destroy_fn = destroy_fn;
|
||||||
|
pixbuf->destroy_fn_data = destroy_fn_data;
|
||||||
|
|
||||||
g_assert (art_pixbuf != NULL);
|
return pixbuf;
|
||||||
|
|
||||||
return gdk_pixbuf_new_from_art_pixbuf (art_pixbuf);
|
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
#include "gdk-pixbuf-private.h"
|
||||||
#include "gdk-pixbuf-io.h"
|
#include "gdk-pixbuf-io.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <gtk/gtksignal.h>
|
#include <gtk/gtksignal.h>
|
||||||
|
#include "gdk-pixbuf-private.h"
|
||||||
#include "gdk-pixbuf-loader.h"
|
#include "gdk-pixbuf-loader.h"
|
||||||
#include "gdk-pixbuf-io.h"
|
#include "gdk-pixbuf-io.h"
|
||||||
|
|
||||||
|
99
gdk-pixbuf/gdk-pixbuf-private.h
Normal file
99
gdk-pixbuf/gdk-pixbuf-private.h
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
/* GdkPixbuf library - Private declarations
|
||||||
|
*
|
||||||
|
* Copyright (C) 1999 The Free Software Foundation
|
||||||
|
*
|
||||||
|
* Authors: Mark Crichton <crichton@gimp.org>
|
||||||
|
* Miguel de Icaza <miguel@gnu.org>
|
||||||
|
* Federico Mena-Quintero <federico@gimp.org>
|
||||||
|
* Havoc Pennington <hp@redhat.com>
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GDK_PIXBUF_PRIVATE_H
|
||||||
|
#define GDK_PIXBUF_PRIVATE_H
|
||||||
|
|
||||||
|
#include "gdk-pixbuf.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Private part of the GdkPixbuf structure */
|
||||||
|
struct _GdkPixbuf {
|
||||||
|
/* Reference count */
|
||||||
|
int ref_count;
|
||||||
|
|
||||||
|
/* Color space */
|
||||||
|
GdkColorspace colorspace;
|
||||||
|
|
||||||
|
/* Number of channels, alpha included */
|
||||||
|
int n_channels;
|
||||||
|
|
||||||
|
/* Bits per channel */
|
||||||
|
int bits_per_sample;
|
||||||
|
|
||||||
|
/* Size */
|
||||||
|
int width, height;
|
||||||
|
|
||||||
|
/* Offset between rows */
|
||||||
|
int rowstride;
|
||||||
|
|
||||||
|
/* The pixel array */
|
||||||
|
guchar *pixels;
|
||||||
|
|
||||||
|
/* Destroy notification function; it is supposed to free the pixel array */
|
||||||
|
GdkPixbufDestroyNotify destroy_fn;
|
||||||
|
|
||||||
|
/* User data for the destroy notification function */
|
||||||
|
gpointer destroy_fn_data;
|
||||||
|
|
||||||
|
/* Do we have an alpha channel? */
|
||||||
|
guint has_alpha : 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Private part of the GdkPixbufFrame structure */
|
||||||
|
struct _GdkPixbufFrame {
|
||||||
|
/* The pixbuf with this frame's image data */
|
||||||
|
GdkPixbuf *pixbuf;
|
||||||
|
|
||||||
|
/* Offsets for overlaying onto the animation's area */
|
||||||
|
int x_offset;
|
||||||
|
int y_offset;
|
||||||
|
|
||||||
|
/* Frame duration in ms */
|
||||||
|
int delay_time;
|
||||||
|
|
||||||
|
/* Overlay mode */
|
||||||
|
GdkPixbufFrameAction action;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Private part of the GdkPixbufAnimation structure */
|
||||||
|
struct _GdkPixbufAnimation {
|
||||||
|
/* Reference count */
|
||||||
|
int ref_count;
|
||||||
|
|
||||||
|
/* Number of frames */
|
||||||
|
int n_frames;
|
||||||
|
|
||||||
|
/* List of GdkPixbufFrame structures */
|
||||||
|
GList *frames;
|
||||||
|
|
||||||
|
/* bounding box size */
|
||||||
|
int width, height;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
@ -1,6 +1,31 @@
|
|||||||
#include "gdk-pixbuf.h"
|
/* GdkPixbuf library - Scaling and compositing functions
|
||||||
|
*
|
||||||
|
* Copyright (C) 1999 The Free Software Foundation
|
||||||
|
*
|
||||||
|
* Author: Owen Taylor <otaylor@redhat.com>
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include "gdk-pixbuf-private.h"
|
||||||
#include "pixops/pixops.h"
|
#include "pixops/pixops.h"
|
||||||
#include "math.h"
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gdk_pixbuf_scale:
|
* gdk_pixbuf_scale:
|
||||||
@ -14,7 +39,7 @@
|
|||||||
* @offset_y: the offset in the Y direction (currently rounded to an integer)
|
* @offset_y: the offset in the Y direction (currently rounded to an integer)
|
||||||
* @scale_x: the scale factor in the X direction
|
* @scale_x: the scale factor in the X direction
|
||||||
* @scale_y: the scale factor in the Y direction
|
* @scale_y: the scale factor in the Y direction
|
||||||
* @filter_level: the filter quality for the transformation.
|
* @interp_type: the interpolation type for the transformation.
|
||||||
*
|
*
|
||||||
* Transforms the image by source image by scaling by @scale_x and @scale_y then
|
* Transforms the image by source image by scaling by @scale_x and @scale_y then
|
||||||
* translating by @offset_x and @offset_y, then renders the rectangle
|
* translating by @offset_x and @offset_y, then renders the rectangle
|
||||||
@ -32,17 +57,22 @@ gdk_pixbuf_scale (const GdkPixbuf *src,
|
|||||||
double offset_y,
|
double offset_y,
|
||||||
double scale_x,
|
double scale_x,
|
||||||
double scale_y,
|
double scale_y,
|
||||||
ArtFilterLevel filter_level)
|
GdkInterpType interp_type)
|
||||||
{
|
{
|
||||||
|
g_return_if_fail (src != NULL);
|
||||||
|
g_return_if_fail (dest != NULL);
|
||||||
|
g_return_if_fail (dest_x >= 0 && dest_x + dest_width <= dest->width);
|
||||||
|
g_return_if_fail (dest_y >= 0 && dest_y + dest_height <= dest->height);
|
||||||
|
|
||||||
offset_x = floor (offset_x + 0.5);
|
offset_x = floor (offset_x + 0.5);
|
||||||
offset_y = floor (offset_y + 0.5);
|
offset_y = floor (offset_y + 0.5);
|
||||||
|
|
||||||
pixops_scale (dest->art_pixbuf->pixels + dest_y * dest->art_pixbuf->rowstride + dest_x * dest->art_pixbuf->n_channels,
|
pixops_scale (dest->pixels + dest_y * dest->rowstride + dest_x * dest->n_channels,
|
||||||
-offset_x, -offset_y, dest_width - offset_x, dest_height - offset_y,
|
-offset_x, -offset_y, dest_width - offset_x, dest_height - offset_y,
|
||||||
dest->art_pixbuf->rowstride, dest->art_pixbuf->n_channels, dest->art_pixbuf->has_alpha,
|
dest->rowstride, dest->n_channels, dest->has_alpha,
|
||||||
src->art_pixbuf->pixels, src->art_pixbuf->width, src->art_pixbuf->height,
|
src->pixels, src->width, src->height,
|
||||||
src->art_pixbuf->rowstride, src->art_pixbuf->n_channels, src->art_pixbuf->has_alpha,
|
src->rowstride, src->n_channels, src->has_alpha,
|
||||||
scale_x, scale_y, filter_level);
|
scale_x, scale_y, interp_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -57,7 +87,7 @@ gdk_pixbuf_scale (const GdkPixbuf *src,
|
|||||||
* @offset_y: the offset in the Y direction (currently rounded to an integer)
|
* @offset_y: the offset in the Y direction (currently rounded to an integer)
|
||||||
* @scale_x: the scale factor in the X direction
|
* @scale_x: the scale factor in the X direction
|
||||||
* @scale_y: the scale factor in the Y direction
|
* @scale_y: the scale factor in the Y direction
|
||||||
* @filter_level: the filter quality for the transformation.
|
* @interp_type: the interpolation type for the transformation.
|
||||||
* @overall_alpha: overall alpha for source image (0..255)
|
* @overall_alpha: overall alpha for source image (0..255)
|
||||||
*
|
*
|
||||||
* Transforms the image by source image by scaling by @scale_x and @scale_y then
|
* Transforms the image by source image by scaling by @scale_x and @scale_y then
|
||||||
@ -76,17 +106,23 @@ gdk_pixbuf_composite (const GdkPixbuf *src,
|
|||||||
double offset_y,
|
double offset_y,
|
||||||
double scale_x,
|
double scale_x,
|
||||||
double scale_y,
|
double scale_y,
|
||||||
ArtFilterLevel filter_level,
|
GdkInterpType interp_type,
|
||||||
int overall_alpha)
|
int overall_alpha)
|
||||||
{
|
{
|
||||||
|
g_return_if_fail (src != NULL);
|
||||||
|
g_return_if_fail (dest != NULL);
|
||||||
|
g_return_if_fail (dest_x >= 0 && dest_x + dest_width <= dest->width);
|
||||||
|
g_return_if_fail (dest_y >= 0 && dest_y + dest_height <= dest->height);
|
||||||
|
g_return_if_fail (overall_alpha >= 0 && overall_alpha <= 255);
|
||||||
|
|
||||||
offset_x = floor (offset_x + 0.5);
|
offset_x = floor (offset_x + 0.5);
|
||||||
offset_y = floor (offset_y + 0.5);
|
offset_y = floor (offset_y + 0.5);
|
||||||
pixops_composite (dest->art_pixbuf->pixels + dest_y * dest->art_pixbuf->rowstride + dest_x * dest->art_pixbuf->n_channels,
|
pixops_composite (dest->pixels + dest_y * dest->rowstride + dest_x * dest->n_channels,
|
||||||
-offset_x, -offset_y, dest_width - offset_x, dest_height - offset_y,
|
-offset_x, -offset_y, dest_width - offset_x, dest_height - offset_y,
|
||||||
dest->art_pixbuf->rowstride, dest->art_pixbuf->n_channels, dest->art_pixbuf->has_alpha,
|
dest->rowstride, dest->n_channels, dest->has_alpha,
|
||||||
src->art_pixbuf->pixels, src->art_pixbuf->width, src->art_pixbuf->height,
|
src->pixels, src->width, src->height,
|
||||||
src->art_pixbuf->rowstride, src->art_pixbuf->n_channels, src->art_pixbuf->has_alpha,
|
src->rowstride, src->n_channels, src->has_alpha,
|
||||||
scale_x, scale_y, filter_level, overall_alpha);
|
scale_x, scale_y, interp_type, overall_alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -101,7 +137,7 @@ gdk_pixbuf_composite (const GdkPixbuf *src,
|
|||||||
* @offset_y: the offset in the Y direction (currently rounded to an integer)
|
* @offset_y: the offset in the Y direction (currently rounded to an integer)
|
||||||
* @scale_x: the scale factor in the X direction
|
* @scale_x: the scale factor in the X direction
|
||||||
* @scale_y: the scale factor in the Y direction
|
* @scale_y: the scale factor in the Y direction
|
||||||
* @filter_level: the filter quality for the transformation.
|
* @interp_type: the interpolation type for the transformation.
|
||||||
* @overall_alpha: overall alpha for source image (0..255)
|
* @overall_alpha: overall alpha for source image (0..255)
|
||||||
* @check_x: the X offset for the checkboard (origin of checkboard is at -@check_x, -@check_y)
|
* @check_x: the X offset for the checkboard (origin of checkboard is at -@check_x, -@check_y)
|
||||||
* @check_y: the Y offset for the checkboard
|
* @check_y: the Y offset for the checkboard
|
||||||
@ -126,23 +162,30 @@ gdk_pixbuf_composite_color (const GdkPixbuf *src,
|
|||||||
double offset_y,
|
double offset_y,
|
||||||
double scale_x,
|
double scale_x,
|
||||||
double scale_y,
|
double scale_y,
|
||||||
ArtFilterLevel filter_level,
|
GdkInterpType interp_type,
|
||||||
int overall_alpha,
|
int overall_alpha,
|
||||||
int check_x,
|
int check_x,
|
||||||
int check_y,
|
int check_y,
|
||||||
int check_size,
|
int check_size,
|
||||||
art_u32 color1,
|
guint32 color1,
|
||||||
art_u32 color2)
|
guint32 color2)
|
||||||
{
|
{
|
||||||
|
g_return_if_fail (src != NULL);
|
||||||
|
g_return_if_fail (dest != NULL);
|
||||||
|
g_return_if_fail (dest_x >= 0 && dest_x + dest_width <= dest->width);
|
||||||
|
g_return_if_fail (dest_y >= 0 && dest_y + dest_height <= dest->height);
|
||||||
|
g_return_if_fail (overall_alpha >= 0 && overall_alpha <= 255);
|
||||||
|
|
||||||
offset_x = floor (offset_x + 0.5);
|
offset_x = floor (offset_x + 0.5);
|
||||||
offset_y = floor (offset_y + 0.5);
|
offset_y = floor (offset_y + 0.5);
|
||||||
|
|
||||||
pixops_composite_color (dest->art_pixbuf->pixels + dest_y * dest->art_pixbuf->rowstride + dest_x * dest->art_pixbuf->n_channels,
|
pixops_composite_color (dest->pixels + dest_y * dest->rowstride + dest_x * dest->n_channels,
|
||||||
-offset_x, -offset_y, dest_width - offset_x, dest_height - offset_y,
|
-offset_x, -offset_y, dest_width - offset_x, dest_height - offset_y,
|
||||||
dest->art_pixbuf->rowstride, dest->art_pixbuf->n_channels, dest->art_pixbuf->has_alpha,
|
dest->rowstride, dest->n_channels, dest->has_alpha,
|
||||||
src->art_pixbuf->pixels, src->art_pixbuf->width, src->art_pixbuf->height,
|
src->pixels, src->width, src->height,
|
||||||
src->art_pixbuf->rowstride, src->art_pixbuf->n_channels, src->art_pixbuf->has_alpha,
|
src->rowstride, src->n_channels, src->has_alpha,
|
||||||
scale_x, scale_y, filter_level, overall_alpha, check_x, check_y, check_size, color1, color2);
|
scale_x, scale_y, interp_type, overall_alpha, check_x, check_y,
|
||||||
|
check_size, color1, color2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -150,25 +193,34 @@ gdk_pixbuf_composite_color (const GdkPixbuf *src,
|
|||||||
* @src: a #GdkPixbuf
|
* @src: a #GdkPixbuf
|
||||||
* @dest_width: the width of destination image
|
* @dest_width: the width of destination image
|
||||||
* @dest_height: the height of destination image
|
* @dest_height: the height of destination image
|
||||||
* @filter_level: the filter quality for the transformation.
|
* @interp_type: the interpolation type for the transformation.
|
||||||
*
|
*
|
||||||
* Scale the #GdkPixbuf @src to @dest_width x @dest_height and render the result into
|
* Scale the #GdkPixbuf @src to @dest_width x @dest_height and render the result into
|
||||||
* a new #GdkPixbuf.
|
* a new #GdkPixbuf.
|
||||||
*
|
*
|
||||||
* Return value: the new #GdkPixbuf
|
* Return value: the new #GdkPixbuf, or NULL if not enough memory could be
|
||||||
|
* allocated for it.
|
||||||
**/
|
**/
|
||||||
GdkPixbuf *
|
GdkPixbuf *
|
||||||
gdk_pixbuf_scale_simple (const GdkPixbuf *src,
|
gdk_pixbuf_scale_simple (const GdkPixbuf *src,
|
||||||
int dest_width,
|
int dest_width,
|
||||||
int dest_height,
|
int dest_height,
|
||||||
ArtFilterLevel filter_level)
|
GdkInterpType interp_type)
|
||||||
{
|
{
|
||||||
GdkPixbuf *dest = gdk_pixbuf_new (ART_PIX_RGB, src->art_pixbuf->has_alpha, 8, dest_width, dest_height);
|
GdkPixbuf *dest;
|
||||||
|
|
||||||
|
g_return_val_if_fail (src != NULL, NULL);
|
||||||
|
g_return_val_if_fail (dest_width > 0, NULL);
|
||||||
|
g_return_val_if_fail (dest_height > 0, NULL);
|
||||||
|
|
||||||
|
dest = gdk_pixbuf_new (GDK_COLORSPACE_RGB, src->has_alpha, 8, dest_width, dest_height);
|
||||||
|
if (!dest)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
gdk_pixbuf_scale (src, dest, 0, 0, dest_width, dest_height, 0, 0,
|
gdk_pixbuf_scale (src, dest, 0, 0, dest_width, dest_height, 0, 0,
|
||||||
(double)dest_width / src->art_pixbuf->width,
|
(double) dest_width / src->width,
|
||||||
(double)dest_height / src->art_pixbuf->height,
|
(double) dest_height / src->height,
|
||||||
filter_level);
|
interp_type);
|
||||||
|
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
@ -178,7 +230,7 @@ gdk_pixbuf_scale_simple (const GdkPixbuf *src,
|
|||||||
* @src: a #GdkPixbuf
|
* @src: a #GdkPixbuf
|
||||||
* @dest_width: the width of destination image
|
* @dest_width: the width of destination image
|
||||||
* @dest_height: the height of destination image
|
* @dest_height: the height of destination image
|
||||||
* @filter_level: the filter quality for the transformation.
|
* @interp_type: the interpolation type for the transformation.
|
||||||
* @overall_alpha: overall alpha for source image (0..255)
|
* @overall_alpha: overall alpha for source image (0..255)
|
||||||
* @check_size: the size of checks in the checkboard (must be a power of two)
|
* @check_size: the size of checks in the checkboard (must be a power of two)
|
||||||
* @color1: the color of check at upper left
|
* @color1: the color of check at upper left
|
||||||
@ -188,27 +240,34 @@ gdk_pixbuf_scale_simple (const GdkPixbuf *src,
|
|||||||
* a checkboard of colors @color1 and @color2 and render the result into
|
* a checkboard of colors @color1 and @color2 and render the result into
|
||||||
* a new #GdkPixbuf.
|
* a new #GdkPixbuf.
|
||||||
*
|
*
|
||||||
* Return value: the new #GdkPixbuf
|
* Return value: the new #GdkPixbuf, or NULL if not enough memory could be
|
||||||
|
* allocated for it.
|
||||||
**/
|
**/
|
||||||
GdkPixbuf *
|
GdkPixbuf *
|
||||||
gdk_pixbuf_composite_color_simple (const GdkPixbuf *src,
|
gdk_pixbuf_composite_color_simple (const GdkPixbuf *src,
|
||||||
int dest_width,
|
int dest_width,
|
||||||
int dest_height,
|
int dest_height,
|
||||||
ArtFilterLevel filter_level,
|
GdkInterpType interp_type,
|
||||||
int overall_alpha,
|
int overall_alpha,
|
||||||
int check_size,
|
int check_size,
|
||||||
art_u32 color1,
|
guint32 color1,
|
||||||
art_u32 color2)
|
guint32 color2)
|
||||||
{
|
{
|
||||||
GdkPixbuf *dest = gdk_pixbuf_new (ART_PIX_RGB, src->art_pixbuf->has_alpha, 8, dest_width, dest_height);
|
GdkPixbuf *dest;
|
||||||
|
|
||||||
|
g_return_val_if_fail (src != NULL, NULL);
|
||||||
|
g_return_val_if_fail (dest_width > 0, NULL);
|
||||||
|
g_return_val_if_fail (dest_height > 0, NULL);
|
||||||
|
g_return_val_if_fail (overall_alpha >= 0 && overall_alpha <= 255, NULL);
|
||||||
|
|
||||||
|
dest = gdk_pixbuf_new (GDK_COLORSPACE_RGB, src->has_alpha, 8, dest_width, dest_height);
|
||||||
|
if (!dest)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
gdk_pixbuf_composite_color (src, dest, 0, 0, dest_width, dest_height, 0, 0,
|
gdk_pixbuf_composite_color (src, dest, 0, 0, dest_width, dest_height, 0, 0,
|
||||||
(double)dest_width / src->art_pixbuf->width,
|
(double) dest_width / src->width,
|
||||||
(double)dest_height / src->art_pixbuf->height,
|
(double) dest_height / src->height,
|
||||||
filter_level, overall_alpha, 0, 0, check_size, color1, color2);
|
interp_type, overall_alpha, 0, 0, check_size, color1, color2);
|
||||||
|
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include "gdk-pixbuf.h"
|
#include "gdk-pixbuf-private.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -45,42 +45,37 @@
|
|||||||
* Return value: A newly-created pixbuf with a reference count of 1.
|
* Return value: A newly-created pixbuf with a reference count of 1.
|
||||||
**/
|
**/
|
||||||
GdkPixbuf *
|
GdkPixbuf *
|
||||||
gdk_pixbuf_add_alpha (GdkPixbuf *pixbuf, gboolean substitute_color, guchar r, guchar g, guchar b)
|
gdk_pixbuf_add_alpha (const GdkPixbuf *pixbuf,
|
||||||
|
gboolean substitute_color, guchar r, guchar g, guchar b)
|
||||||
{
|
{
|
||||||
ArtPixBuf *apb;
|
|
||||||
ArtPixBuf *new_apb;
|
|
||||||
GdkPixbuf *new_pixbuf;
|
GdkPixbuf *new_pixbuf;
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
g_return_val_if_fail (pixbuf != NULL, NULL);
|
g_return_val_if_fail (pixbuf != NULL, NULL);
|
||||||
|
g_return_val_if_fail (pixbuf->colorspace == GDK_COLORSPACE_RGB, NULL);
|
||||||
|
g_return_val_if_fail (pixbuf->n_channels == 3 || pixbuf->n_channels == 4, NULL);
|
||||||
|
g_return_val_if_fail (pixbuf->bits_per_sample == 8, NULL);
|
||||||
|
|
||||||
apb = pixbuf->art_pixbuf;
|
if (pixbuf->has_alpha) {
|
||||||
g_return_val_if_fail (apb->format == ART_PIX_RGB, NULL);
|
new_pixbuf = gdk_pixbuf_copy (pixbuf);
|
||||||
g_return_val_if_fail (apb->n_channels == 3 || apb->n_channels == 4, NULL);
|
if (!new_pixbuf)
|
||||||
g_return_val_if_fail (apb->bits_per_sample == 8, NULL);
|
|
||||||
|
|
||||||
if (apb->has_alpha) {
|
|
||||||
new_apb = art_pixbuf_duplicate (apb);
|
|
||||||
if (!new_apb)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return gdk_pixbuf_new_from_art_pixbuf (new_apb);
|
return new_pixbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
new_pixbuf = gdk_pixbuf_new (ART_PIX_RGB, TRUE, 8, apb->width, apb->height);
|
new_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, pixbuf->width, pixbuf->height);
|
||||||
if (!new_pixbuf)
|
if (!new_pixbuf)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
new_apb = new_pixbuf->art_pixbuf;
|
for (y = 0; y < pixbuf->height; y++) {
|
||||||
|
|
||||||
for (y = 0; y < apb->height; y++) {
|
|
||||||
guchar *src, *dest;
|
guchar *src, *dest;
|
||||||
guchar tr, tg, tb;
|
guchar tr, tg, tb;
|
||||||
|
|
||||||
src = apb->pixels + y * apb->rowstride;
|
src = pixbuf->pixels + y * pixbuf->rowstride;
|
||||||
dest = new_apb->pixels + y * new_apb->rowstride;
|
dest = new_pixbuf->pixels + y * new_pixbuf->rowstride;
|
||||||
|
|
||||||
for (x = 0; x < apb->width; x++) {
|
for (x = 0; x < pixbuf->width; x++) {
|
||||||
tr = *dest++ = *src++;
|
tr = *dest++ = *src++;
|
||||||
tg = *dest++ = *src++;
|
tg = *dest++ = *src++;
|
||||||
tb = *dest++ = *src++;
|
tb = *dest++ = *src++;
|
||||||
@ -116,20 +111,14 @@ gdk_pixbuf_copy_area (const GdkPixbuf *src_pixbuf,
|
|||||||
GdkPixbuf *dest_pixbuf,
|
GdkPixbuf *dest_pixbuf,
|
||||||
int dest_x, int dest_y)
|
int dest_x, int dest_y)
|
||||||
{
|
{
|
||||||
const ArtPixBuf *src_apb;
|
|
||||||
ArtPixBuf *dest_apb;
|
|
||||||
|
|
||||||
g_return_if_fail (src_pixbuf != NULL);
|
g_return_if_fail (src_pixbuf != NULL);
|
||||||
g_return_if_fail (dest_pixbuf != NULL);
|
g_return_if_fail (dest_pixbuf != NULL);
|
||||||
|
|
||||||
src_apb = src_pixbuf->art_pixbuf;
|
g_return_if_fail (src_x >= 0 && src_x + width <= src_pixbuf->width);
|
||||||
dest_apb = dest_pixbuf->art_pixbuf;
|
g_return_if_fail (src_y >= 0 && src_y + height <= src_pixbuf->height);
|
||||||
|
|
||||||
g_return_if_fail (src_x >= 0 && src_x + width <= src_apb->width);
|
g_return_if_fail (dest_x >= 0 && dest_x + width <= dest_pixbuf->width);
|
||||||
g_return_if_fail (src_y >= 0 && src_y + height <= src_apb->height);
|
g_return_if_fail (dest_y >= 0 && dest_y + height <= dest_pixbuf->height);
|
||||||
|
|
||||||
g_return_if_fail (dest_x >= 0 && dest_x + width <= dest_apb->width);
|
|
||||||
g_return_if_fail (dest_y >= 0 && dest_y + height <= dest_apb->height);
|
|
||||||
|
|
||||||
/* This will perform format conversions automatically */
|
/* This will perform format conversions automatically */
|
||||||
|
|
||||||
@ -140,5 +129,5 @@ gdk_pixbuf_copy_area (const GdkPixbuf *src_pixbuf,
|
|||||||
(double) (dest_x - src_x),
|
(double) (dest_x - src_x),
|
||||||
(double) (dest_y - src_y),
|
(double) (dest_y - src_y),
|
||||||
1.0, 1.0,
|
1.0, 1.0,
|
||||||
ART_FILTER_NEAREST);
|
GDK_INTERP_NEAREST);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,16 @@
|
|||||||
|
/* FIXME FIXME FIXME
|
||||||
|
*
|
||||||
|
* This file is not being used. The gdk_pixbuf_scale() here is not useful
|
||||||
|
* anymore, since we have the new functions in gdk-pixbuf-scale.c.
|
||||||
|
*
|
||||||
|
* The rotation function needs to be implemented without libart if it is
|
||||||
|
* to go inside the GdkPixbuf library.
|
||||||
|
*/
|
||||||
|
|
||||||
GdkPixbuf *
|
GdkPixbuf *
|
||||||
gdk_pixbuf_scale (const GdkPixbuf *pixbuf, gint w, gint h)
|
gdk_pixbuf_scale (const GdkPixbuf *pixbuf, gint w, gint h)
|
||||||
{
|
{
|
||||||
art_u8 *pixels;
|
guchar *pixels;
|
||||||
gint rowstride;
|
gint rowstride;
|
||||||
double affine[6];
|
double affine[6];
|
||||||
ArtAlphaGamma *alphagamma;
|
ArtAlphaGamma *alphagamma;
|
||||||
@ -12,10 +21,10 @@ gdk_pixbuf_scale (const GdkPixbuf *pixbuf, gint w, gint h)
|
|||||||
|
|
||||||
affine[1] = affine[2] = affine[4] = affine[5] = 0;
|
affine[1] = affine[2] = affine[4] = affine[5] = 0;
|
||||||
|
|
||||||
affine[0] = w / (double)(pixbuf->art_pixbuf->width);
|
affine[0] = w / (double)(pixbuf->width);
|
||||||
affine[3] = h / (double)(pixbuf->art_pixbuf->height);
|
affine[3] = h / (double)(pixbuf->height);
|
||||||
|
|
||||||
/* rowstride = w * pixbuf->art_pixbuf->n_channels; */
|
/* rowstride = w * pixbuf->n_channels; */
|
||||||
rowstride = w * 3;
|
rowstride = w * 3;
|
||||||
|
|
||||||
pixels = art_alloc (h * rowstride);
|
pixels = art_alloc (h * rowstride);
|
||||||
|
@ -24,12 +24,9 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <libart_lgpl/art_misc.h>
|
#include <stdlib.h>
|
||||||
#include <libart_lgpl/art_affine.h>
|
|
||||||
#include <libart_lgpl/art_pixbuf.h>
|
|
||||||
#include <libart_lgpl/art_rgb_pixbuf_affine.h>
|
|
||||||
#include <libart_lgpl/art_alphagamma.h>
|
|
||||||
#include "gdk-pixbuf.h"
|
#include "gdk-pixbuf.h"
|
||||||
|
#include "gdk-pixbuf-private.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -58,7 +55,7 @@ gdk_pixbuf_ref (GdkPixbuf *pixbuf)
|
|||||||
* gdk_pixbuf_unref:
|
* gdk_pixbuf_unref:
|
||||||
* @pixbuf: A pixbuf.
|
* @pixbuf: A pixbuf.
|
||||||
*
|
*
|
||||||
* Removes a reference from a pixbuf. It will be destroyed when the reference
|
* Removes a reference from a pixbuf, which will be destroyed when the reference
|
||||||
* count drops to zero.
|
* count drops to zero.
|
||||||
**/
|
**/
|
||||||
void
|
void
|
||||||
@ -70,53 +67,25 @@ gdk_pixbuf_unref (GdkPixbuf *pixbuf)
|
|||||||
pixbuf->ref_count--;
|
pixbuf->ref_count--;
|
||||||
|
|
||||||
if (pixbuf->ref_count == 0) {
|
if (pixbuf->ref_count == 0) {
|
||||||
art_pixbuf_free (pixbuf->art_pixbuf);
|
if (pixbuf->destroy_fn)
|
||||||
pixbuf->art_pixbuf = NULL;
|
(* pixbuf->destroy_fn) (pixbuf->pixels, pixbuf->destroy_fn_data);
|
||||||
|
|
||||||
g_free (pixbuf);
|
g_free (pixbuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Wrap a libart pixbuf */
|
/* Used as the destroy notification function for gdk_pixbuf_new() */
|
||||||
|
|
||||||
/**
|
|
||||||
* gdk_pixbuf_new_from_art_pixbuf:
|
|
||||||
* @art_pixbuf: A libart pixbuf.
|
|
||||||
*
|
|
||||||
* Creates a #GdkPixbuf by wrapping a libart pixbuf.
|
|
||||||
*
|
|
||||||
* Return value: A newly-created #GdkPixbuf structure with a reference count of
|
|
||||||
* 1.
|
|
||||||
**/
|
|
||||||
GdkPixbuf *
|
|
||||||
gdk_pixbuf_new_from_art_pixbuf (ArtPixBuf *art_pixbuf)
|
|
||||||
{
|
|
||||||
GdkPixbuf *pixbuf;
|
|
||||||
|
|
||||||
g_return_val_if_fail (art_pixbuf != NULL, NULL);
|
|
||||||
|
|
||||||
pixbuf = g_new (GdkPixbuf, 1);
|
|
||||||
pixbuf->ref_count = 1;
|
|
||||||
pixbuf->art_pixbuf = art_pixbuf;
|
|
||||||
|
|
||||||
return pixbuf;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Destroy notification function for gdk_pixbuf_new() */
|
|
||||||
static void
|
static void
|
||||||
free_buffer (gpointer user_data, gpointer data)
|
free_buffer (guchar *pixels, gpointer data)
|
||||||
{
|
{
|
||||||
free (data);
|
free (pixels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Create an empty pixbuf */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gdk_pixbuf_new:
|
* gdk_pixbuf_new:
|
||||||
* @format: Image format.
|
* @colorspace: Color space for image.
|
||||||
* @has_alpha: Whether the image should have transparency information.
|
* @has_alpha: Whether the image should have transparency information.
|
||||||
* @bits_per_sample: Number of bits per color sample.
|
* @bits_per_sample: Number of bits per color sample.
|
||||||
* @width: Width of image in pixels.
|
* @width: Width of image in pixels.
|
||||||
@ -124,20 +93,20 @@ free_buffer (gpointer user_data, gpointer data)
|
|||||||
*
|
*
|
||||||
* Creates a new #GdkPixbuf structure and allocates a buffer for it. The buffer
|
* Creates a new #GdkPixbuf structure and allocates a buffer for it. The buffer
|
||||||
* has an optimal rowstride. Note that the buffer is not cleared; you will have
|
* has an optimal rowstride. Note that the buffer is not cleared; you will have
|
||||||
* to fill it completely.
|
* to fill it completely yourself.
|
||||||
*
|
*
|
||||||
* Return value: A newly-created #GdkPixbuf with a reference count of 1, or NULL
|
* Return value: A newly-created #GdkPixbuf with a reference count of 1, or NULL
|
||||||
* if not enough memory could be allocated for the image buffer.
|
* if not enough memory could be allocated for the image buffer.
|
||||||
**/
|
**/
|
||||||
GdkPixbuf *
|
GdkPixbuf *
|
||||||
gdk_pixbuf_new (ArtPixFormat format, gboolean has_alpha, int bits_per_sample,
|
gdk_pixbuf_new (GdkColorspace colorspace, gboolean has_alpha, int bits_per_sample,
|
||||||
int width, int height)
|
int width, int height)
|
||||||
{
|
{
|
||||||
guchar *buf;
|
guchar *buf;
|
||||||
int channels;
|
int channels;
|
||||||
int rowstride;
|
int rowstride;
|
||||||
|
|
||||||
g_return_val_if_fail (format == ART_PIX_RGB, NULL);
|
g_return_val_if_fail (colorspace == GDK_COLORSPACE_RGB, NULL);
|
||||||
g_return_val_if_fail (bits_per_sample == 8, NULL);
|
g_return_val_if_fail (bits_per_sample == 8, NULL);
|
||||||
g_return_val_if_fail (width > 0, NULL);
|
g_return_val_if_fail (width > 0, NULL);
|
||||||
g_return_val_if_fail (height > 0, NULL);
|
g_return_val_if_fail (height > 0, NULL);
|
||||||
@ -151,29 +120,70 @@ gdk_pixbuf_new (ArtPixFormat format, gboolean has_alpha, int bits_per_sample,
|
|||||||
if (!buf)
|
if (!buf)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return gdk_pixbuf_new_from_data (buf, format, has_alpha, width, height, rowstride,
|
return gdk_pixbuf_new_from_data (buf, colorspace, has_alpha, bits_per_sample,
|
||||||
|
width, height, rowstride,
|
||||||
free_buffer, NULL);
|
free_buffer, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gdk_pixbuf_copy:
|
||||||
|
* @pixbuf: A pixbuf.
|
||||||
|
*
|
||||||
|
* Creates a new #GdkPixbuf with a copy of the information in the specified
|
||||||
|
* @pixbuf.
|
||||||
|
*
|
||||||
|
* Return value: A newly-created pixbuf with a reference count of 1, or NULL if
|
||||||
|
* not enough memory could be allocated.
|
||||||
|
**/
|
||||||
|
GdkPixbuf *
|
||||||
|
gdk_pixbuf_copy (const GdkPixbuf *pixbuf)
|
||||||
|
{
|
||||||
|
guchar *buf;
|
||||||
|
int size;
|
||||||
|
|
||||||
|
g_return_val_if_fail (pixbuf != NULL, NULL);
|
||||||
|
|
||||||
|
/* Calculate a semi-exact size. Here we copy with full rowstrides;
|
||||||
|
* maybe we should copy each row individually with the minimum
|
||||||
|
* rowstride?
|
||||||
|
*/
|
||||||
|
|
||||||
|
size = ((pixbuf->height - 1) * pixbuf->rowstride +
|
||||||
|
pixbuf->width * ((pixbuf->n_channels * pixbuf->bits_per_sample + 7) / 8));
|
||||||
|
|
||||||
|
buf = malloc (size * sizeof (guchar));
|
||||||
|
if (!buf)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
memcpy (buf, pixbuf->pixels, size);
|
||||||
|
|
||||||
|
return gdk_pixbuf_new_from_data (buf,
|
||||||
|
pixbuf->colorspace, pixbuf->has_alpha,
|
||||||
|
pixbuf->bits_per_sample,
|
||||||
|
pixbuf->width, pixbuf->height,
|
||||||
|
pixbuf->rowstride,
|
||||||
|
free_buffer,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Convenience functions */
|
/* Accessors */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gdk_pixbuf_get_format:
|
* gdk_pixbuf_get_colorspace:
|
||||||
* @pixbuf: A pixbuf.
|
* @pixbuf: A pixbuf.
|
||||||
*
|
*
|
||||||
* Queries the image format (color model) of a pixbuf.
|
* Queries the color space of a pixbuf.
|
||||||
*
|
*
|
||||||
* Return value: Image format.
|
* Return value: Color space.
|
||||||
**/
|
**/
|
||||||
ArtPixFormat
|
GdkColorspace
|
||||||
gdk_pixbuf_get_format (GdkPixbuf *pixbuf)
|
gdk_pixbuf_get_colorspace (const GdkPixbuf *pixbuf)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (pixbuf != NULL, ART_PIX_RGB);
|
g_return_val_if_fail (pixbuf != NULL, GDK_COLORSPACE_RGB);
|
||||||
g_assert (pixbuf->art_pixbuf != NULL);
|
|
||||||
|
|
||||||
return pixbuf->art_pixbuf->format;
|
return pixbuf->colorspace;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -185,12 +195,11 @@ gdk_pixbuf_get_format (GdkPixbuf *pixbuf)
|
|||||||
* Return value: Number of channels.
|
* Return value: Number of channels.
|
||||||
**/
|
**/
|
||||||
int
|
int
|
||||||
gdk_pixbuf_get_n_channels (GdkPixbuf *pixbuf)
|
gdk_pixbuf_get_n_channels (const GdkPixbuf *pixbuf)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (pixbuf != NULL, -1);
|
g_return_val_if_fail (pixbuf != NULL, -1);
|
||||||
g_assert (pixbuf->art_pixbuf != NULL);
|
|
||||||
|
|
||||||
return pixbuf->art_pixbuf->n_channels;
|
return pixbuf->n_channels;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -202,12 +211,11 @@ gdk_pixbuf_get_n_channels (GdkPixbuf *pixbuf)
|
|||||||
* Return value: TRUE if it has an alpha channel, FALSE otherwise.
|
* Return value: TRUE if it has an alpha channel, FALSE otherwise.
|
||||||
**/
|
**/
|
||||||
gboolean
|
gboolean
|
||||||
gdk_pixbuf_get_has_alpha (GdkPixbuf *pixbuf)
|
gdk_pixbuf_get_has_alpha (const GdkPixbuf *pixbuf)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (pixbuf != NULL, -1);
|
g_return_val_if_fail (pixbuf != NULL, -1);
|
||||||
g_assert (pixbuf->art_pixbuf != NULL);
|
|
||||||
|
|
||||||
return pixbuf->art_pixbuf->has_alpha;
|
return pixbuf->has_alpha ? TRUE : FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -219,12 +227,11 @@ gdk_pixbuf_get_has_alpha (GdkPixbuf *pixbuf)
|
|||||||
* Return value: Number of bits per color sample.
|
* Return value: Number of bits per color sample.
|
||||||
**/
|
**/
|
||||||
int
|
int
|
||||||
gdk_pixbuf_get_bits_per_sample (GdkPixbuf *pixbuf)
|
gdk_pixbuf_get_bits_per_sample (const GdkPixbuf *pixbuf)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (pixbuf != NULL, -1);
|
g_return_val_if_fail (pixbuf != NULL, -1);
|
||||||
g_assert (pixbuf->art_pixbuf != NULL);
|
|
||||||
|
|
||||||
return pixbuf->art_pixbuf->bits_per_sample;
|
return pixbuf->bits_per_sample;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -236,12 +243,11 @@ gdk_pixbuf_get_bits_per_sample (GdkPixbuf *pixbuf)
|
|||||||
* Return value: A pointer to the pixbuf's pixel data.
|
* Return value: A pointer to the pixbuf's pixel data.
|
||||||
**/
|
**/
|
||||||
guchar *
|
guchar *
|
||||||
gdk_pixbuf_get_pixels (GdkPixbuf *pixbuf)
|
gdk_pixbuf_get_pixels (const GdkPixbuf *pixbuf)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (pixbuf != NULL, NULL);
|
g_return_val_if_fail (pixbuf != NULL, NULL);
|
||||||
g_assert (pixbuf->art_pixbuf != NULL);
|
|
||||||
|
|
||||||
return pixbuf->art_pixbuf->pixels;
|
return pixbuf->pixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -253,12 +259,11 @@ gdk_pixbuf_get_pixels (GdkPixbuf *pixbuf)
|
|||||||
* Return value: Width in pixels.
|
* Return value: Width in pixels.
|
||||||
**/
|
**/
|
||||||
int
|
int
|
||||||
gdk_pixbuf_get_width (GdkPixbuf *pixbuf)
|
gdk_pixbuf_get_width (const GdkPixbuf *pixbuf)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (pixbuf != NULL, -1);
|
g_return_val_if_fail (pixbuf != NULL, -1);
|
||||||
g_assert (pixbuf->art_pixbuf != NULL);
|
|
||||||
|
|
||||||
return pixbuf->art_pixbuf->width;
|
return pixbuf->width;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -270,46 +275,44 @@ gdk_pixbuf_get_width (GdkPixbuf *pixbuf)
|
|||||||
* Return value: Height in pixels.
|
* Return value: Height in pixels.
|
||||||
**/
|
**/
|
||||||
int
|
int
|
||||||
gdk_pixbuf_get_height (GdkPixbuf *pixbuf)
|
gdk_pixbuf_get_height (const GdkPixbuf *pixbuf)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (pixbuf != NULL, -1);
|
g_return_val_if_fail (pixbuf != NULL, -1);
|
||||||
g_assert (pixbuf->art_pixbuf != NULL);
|
|
||||||
|
|
||||||
return pixbuf->art_pixbuf->height;
|
return pixbuf->height;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gdk_pixbuf_get_rowstride:
|
* gdk_pixbuf_get_rowstride:
|
||||||
* @pixbuf: A pixbuf.
|
* @pixbuf: A pixbuf.
|
||||||
*
|
*
|
||||||
* Queries the rowstride of a pixbuf, or the number of bytes between rows.
|
* Queries the rowstride of a pixbuf, which is the number of bytes between rows.
|
||||||
*
|
*
|
||||||
* Return value: Number of bytes between rows.
|
* Return value: Number of bytes between rows.
|
||||||
**/
|
**/
|
||||||
int
|
int
|
||||||
gdk_pixbuf_get_rowstride (GdkPixbuf *pixbuf)
|
gdk_pixbuf_get_rowstride (const GdkPixbuf *pixbuf)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (pixbuf != NULL, -1);
|
g_return_val_if_fail (pixbuf != NULL, -1);
|
||||||
g_assert (pixbuf->art_pixbuf != NULL);
|
|
||||||
|
|
||||||
return pixbuf->art_pixbuf->rowstride;
|
return pixbuf->rowstride;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* General initialization hooks */
|
/* General initialization hooks */
|
||||||
const guint gdk_pixbuf_major_version=GDK_PIXBUF_MAJOR,
|
const guint gdk_pixbuf_major_version = GDK_PIXBUF_MAJOR;
|
||||||
gdk_pixbuf_minor_version=GDK_PIXBUF_MINOR,
|
const guint gdk_pixbuf_minor_version = GDK_PIXBUF_MINOR;
|
||||||
gdk_pixbuf_micro_version=GDK_PIXBUF_MICRO;
|
const guint gdk_pixbuf_micro_version = GDK_PIXBUF_MICRO;
|
||||||
|
|
||||||
const char *gdk_pixbuf_version = GDK_PIXBUF_VERSION;
|
const char *gdk_pixbuf_version = GDK_PIXBUF_VERSION;
|
||||||
|
|
||||||
void
|
void
|
||||||
gdk_pixbuf_preinit(gpointer app, gpointer modinfo)
|
gdk_pixbuf_preinit (gpointer app, gpointer modinfo)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gdk_pixbuf_postinit(gpointer app, gpointer modinfo)
|
gdk_pixbuf_postinit (gpointer app, gpointer modinfo)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
* Authors: Mark Crichton <crichton@gimp.org>
|
* Authors: Mark Crichton <crichton@gimp.org>
|
||||||
* Miguel de Icaza <miguel@gnu.org>
|
* Miguel de Icaza <miguel@gnu.org>
|
||||||
* Federico Mena-Quintero <federico@gimp.org>
|
* Federico Mena-Quintero <federico@gimp.org>
|
||||||
|
* Havoc Pennington <hp@redhat.com>
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Library General Public
|
* modify it under the terms of the GNU Library General Public
|
||||||
@ -25,9 +26,6 @@
|
|||||||
#ifndef GDK_PIXBUF_H
|
#ifndef GDK_PIXBUF_H
|
||||||
#define GDK_PIXBUF_H
|
#define GDK_PIXBUF_H
|
||||||
|
|
||||||
#include <libart_lgpl/art_misc.h>
|
|
||||||
#include <libart_lgpl/art_pixbuf.h>
|
|
||||||
#include <libart_lgpl/art_filterlevel.h>
|
|
||||||
#include <gdk/gdk.h>
|
#include <gdk/gdk.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@ -36,98 +34,76 @@ extern "C" {
|
|||||||
|
|
||||||
#include <gdk-pixbuf/gdk-pixbuf-features.h>
|
#include <gdk-pixbuf/gdk-pixbuf-features.h>
|
||||||
|
|
||||||
/* GdkPixbuf structures */
|
|
||||||
|
|
||||||
|
/* Color spaces; right now only RGB is supported */
|
||||||
|
typedef enum {
|
||||||
|
GDK_COLORSPACE_RGB
|
||||||
|
} GdkColorspace;
|
||||||
|
|
||||||
|
/* All of these are opaque structures */
|
||||||
typedef struct _GdkPixbuf GdkPixbuf;
|
typedef struct _GdkPixbuf GdkPixbuf;
|
||||||
typedef struct _GdkPixbufFrame GdkPixbufFrame;
|
typedef struct _GdkPixbufFrame GdkPixbufFrame;
|
||||||
typedef struct _GdkPixbufAnimation GdkPixbufAnimation;
|
typedef struct _GdkPixbufAnimation GdkPixbufAnimation;
|
||||||
|
|
||||||
struct _GdkPixbuf {
|
typedef void (* GdkPixbufDestroyNotify) (guchar *pixels, gpointer data);
|
||||||
/* Reference count */
|
|
||||||
int ref_count;
|
|
||||||
|
|
||||||
/* Libart pixbuf */
|
|
||||||
ArtPixBuf *art_pixbuf;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* GIF-like animation overlay modes for frames */
|
|
||||||
typedef enum {
|
|
||||||
GDK_PIXBUF_FRAME_RETAIN,
|
|
||||||
GDK_PIXBUF_FRAME_DISPOSE,
|
|
||||||
GDK_PIXBUF_FRAME_REVERT
|
|
||||||
} GdkPixbufFrameAction;
|
|
||||||
|
|
||||||
struct _GdkPixbufFrame {
|
|
||||||
/* The pixbuf with this frame's image data */
|
|
||||||
GdkPixbuf *pixbuf;
|
|
||||||
|
|
||||||
/* Offsets for overlaying onto the animation's area */
|
|
||||||
int x_offset;
|
|
||||||
int y_offset;
|
|
||||||
|
|
||||||
/* Frame duration in ms */
|
|
||||||
int delay_time;
|
|
||||||
|
|
||||||
/* Overlay mode */
|
|
||||||
GdkPixbufFrameAction action;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _GdkPixbufAnimation {
|
|
||||||
/* Reference count */
|
|
||||||
int ref_count;
|
|
||||||
|
|
||||||
/* Number of frames */
|
|
||||||
int n_frames;
|
|
||||||
|
|
||||||
/* List of GdkPixbufFrame structures */
|
|
||||||
GList *frames;
|
|
||||||
|
|
||||||
/* bounding box size */
|
|
||||||
int width, height;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Convenience functions */
|
|
||||||
|
|
||||||
ArtPixFormat gdk_pixbuf_get_format (GdkPixbuf *pixbuf);
|
|
||||||
int gdk_pixbuf_get_n_channels (GdkPixbuf *pixbuf);
|
|
||||||
gboolean gdk_pixbuf_get_has_alpha (GdkPixbuf *pixbuf);
|
|
||||||
int gdk_pixbuf_get_bits_per_sample (GdkPixbuf *pixbuf);
|
|
||||||
guchar *gdk_pixbuf_get_pixels (GdkPixbuf *pixbuf);
|
|
||||||
int gdk_pixbuf_get_width (GdkPixbuf *pixbuf);
|
|
||||||
int gdk_pixbuf_get_height (GdkPixbuf *pixbuf);
|
|
||||||
int gdk_pixbuf_get_rowstride (GdkPixbuf *pixbuf);
|
|
||||||
|
|
||||||
/* Reference counting */
|
/* Reference counting */
|
||||||
|
|
||||||
GdkPixbuf *gdk_pixbuf_ref (GdkPixbuf *pixbuf);
|
GdkPixbuf *gdk_pixbuf_ref (GdkPixbuf *pixbuf);
|
||||||
void gdk_pixbuf_unref (GdkPixbuf *pixbuf);
|
void gdk_pixbuf_unref (GdkPixbuf *pixbuf);
|
||||||
|
|
||||||
/* Wrap a libart pixbuf */
|
/* GdkPixbuf accessors */
|
||||||
GdkPixbuf *gdk_pixbuf_new_from_art_pixbuf (ArtPixBuf *art_pixbuf);
|
|
||||||
|
GdkColorspace gdk_pixbuf_get_colorspace (const GdkPixbuf *pixbuf);
|
||||||
|
int gdk_pixbuf_get_n_channels (const GdkPixbuf *pixbuf);
|
||||||
|
gboolean gdk_pixbuf_get_has_alpha (const GdkPixbuf *pixbuf);
|
||||||
|
int gdk_pixbuf_get_bits_per_sample (const GdkPixbuf *pixbuf);
|
||||||
|
guchar *gdk_pixbuf_get_pixels (const GdkPixbuf *pixbuf);
|
||||||
|
int gdk_pixbuf_get_width (const GdkPixbuf *pixbuf);
|
||||||
|
int gdk_pixbuf_get_height (const GdkPixbuf *pixbuf);
|
||||||
|
int gdk_pixbuf_get_rowstride (const GdkPixbuf *pixbuf);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Create a blank pixbuf with an optimal rowstride and a new buffer */
|
/* Create a blank pixbuf with an optimal rowstride and a new buffer */
|
||||||
GdkPixbuf *gdk_pixbuf_new (ArtPixFormat format, gboolean has_alpha, int bits_per_sample,
|
GdkPixbuf *gdk_pixbuf_new (GdkColorspace colorspace, gboolean has_alpha, int bits_per_sample,
|
||||||
int width, int height);
|
int width, int height);
|
||||||
|
|
||||||
|
/* Copy a pixbuf */
|
||||||
|
|
||||||
|
GdkPixbuf *gdk_pixbuf_copy (const GdkPixbuf *pixbuf);
|
||||||
|
|
||||||
/* Simple loading */
|
/* Simple loading */
|
||||||
|
|
||||||
GdkPixbuf *gdk_pixbuf_new_from_file (const char *filename);
|
GdkPixbuf *gdk_pixbuf_new_from_file (const char *filename);
|
||||||
|
|
||||||
GdkPixbuf *gdk_pixbuf_new_from_data (const guchar *data,
|
GdkPixbuf *gdk_pixbuf_new_from_data (const guchar *data,
|
||||||
ArtPixFormat format,
|
GdkColorspace colorspace,
|
||||||
gboolean has_alpha,
|
gboolean has_alpha,
|
||||||
|
int bits_per_sample,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
int rowstride,
|
int rowstride,
|
||||||
ArtDestroyNotify dfunc,
|
GdkPixbufDestroyNotify destroy_fn,
|
||||||
gpointer dfunc_data);
|
gpointer destroy_fn_data);
|
||||||
|
|
||||||
GdkPixbuf *gdk_pixbuf_new_from_xpm_data (const char **data);
|
GdkPixbuf *gdk_pixbuf_new_from_xpm_data (const char **data);
|
||||||
|
|
||||||
/* Adding an alpha channel */
|
/* Adding an alpha channel */
|
||||||
GdkPixbuf *gdk_pixbuf_add_alpha (GdkPixbuf *pixbuf, gboolean substitute_color,
|
GdkPixbuf *gdk_pixbuf_add_alpha (const GdkPixbuf *pixbuf, gboolean substitute_color,
|
||||||
guchar r, guchar g, guchar b);
|
guchar r, guchar g, guchar b);
|
||||||
|
|
||||||
|
/* Copy an area of a pixbuf onto another one */
|
||||||
|
void gdk_pixbuf_copy_area (const GdkPixbuf *src_pixbuf,
|
||||||
|
int src_x, int src_y,
|
||||||
|
int width, int height,
|
||||||
|
GdkPixbuf *dest_pixbuf,
|
||||||
|
int dest_x, int dest_y);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Rendering to a drawable */
|
/* Rendering to a drawable */
|
||||||
|
|
||||||
/* Alpha compositing mode */
|
/* Alpha compositing mode */
|
||||||
@ -159,26 +135,29 @@ void gdk_pixbuf_render_to_drawable_alpha (GdkPixbuf *pixbuf, GdkDrawable *drawab
|
|||||||
GdkRgbDither dither,
|
GdkRgbDither dither,
|
||||||
int x_dither, int y_dither);
|
int x_dither, int y_dither);
|
||||||
|
|
||||||
void gdk_pixbuf_render_pixmap_and_mask (GdkPixbuf *pixbuf,
|
void gdk_pixbuf_render_pixmap_and_mask (GdkPixbuf *pixbuf,
|
||||||
GdkPixmap **pixmap_return, GdkBitmap **mask_return,
|
GdkPixmap **pixmap_return, GdkBitmap **mask_return,
|
||||||
int alpha_threshold);
|
int alpha_threshold);
|
||||||
|
|
||||||
/* Fetching a region from a drawable */
|
/* Fetching a region from a drawable */
|
||||||
GdkPixbuf *gdk_pixbuf_get_from_drawable (GdkPixbuf *dest,
|
GdkPixbuf *gdk_pixbuf_get_from_drawable (GdkPixbuf *dest,
|
||||||
GdkDrawable *src, GdkColormap *cmap,
|
GdkDrawable *src, GdkColormap *cmap,
|
||||||
int src_x, int src_y,
|
int src_x, int src_y,
|
||||||
int dest_x, int dest_y,
|
int dest_x, int dest_y,
|
||||||
int width, int height);
|
int width, int height);
|
||||||
|
|
||||||
/* Copy an area of a pixbuf onto another one */
|
|
||||||
void gdk_pixbuf_copy_area (const GdkPixbuf *src_pixbuf,
|
|
||||||
int src_x, int src_y,
|
|
||||||
int width, int height,
|
|
||||||
GdkPixbuf *dest_pixbuf,
|
|
||||||
int dest_x, int dest_y);
|
|
||||||
|
|
||||||
/* Scaling */
|
/* Scaling */
|
||||||
|
|
||||||
|
/* Interpolation modes */
|
||||||
|
typedef enum {
|
||||||
|
GDK_INTERP_NEAREST,
|
||||||
|
GDK_INTERP_TILES,
|
||||||
|
GDK_INTERP_BILINEAR,
|
||||||
|
GDK_INTERP_HYPER
|
||||||
|
} GdkInterpType;
|
||||||
|
|
||||||
void gdk_pixbuf_scale (const GdkPixbuf *src,
|
void gdk_pixbuf_scale (const GdkPixbuf *src,
|
||||||
GdkPixbuf *dest,
|
GdkPixbuf *dest,
|
||||||
int dest_x,
|
int dest_x,
|
||||||
@ -189,7 +168,7 @@ void gdk_pixbuf_scale (const GdkPixbuf *src,
|
|||||||
double offset_y,
|
double offset_y,
|
||||||
double scale_x,
|
double scale_x,
|
||||||
double scale_y,
|
double scale_y,
|
||||||
ArtFilterLevel filter_level);
|
GdkInterpType interp_type);
|
||||||
void gdk_pixbuf_composite (const GdkPixbuf *src,
|
void gdk_pixbuf_composite (const GdkPixbuf *src,
|
||||||
GdkPixbuf *dest,
|
GdkPixbuf *dest,
|
||||||
int dest_x,
|
int dest_x,
|
||||||
@ -200,7 +179,7 @@ void gdk_pixbuf_composite (const GdkPixbuf *src,
|
|||||||
double offset_y,
|
double offset_y,
|
||||||
double scale_x,
|
double scale_x,
|
||||||
double scale_y,
|
double scale_y,
|
||||||
ArtFilterLevel filter_level,
|
GdkInterpType interp_type,
|
||||||
int overall_alpha);
|
int overall_alpha);
|
||||||
void gdk_pixbuf_composite_color (const GdkPixbuf *src,
|
void gdk_pixbuf_composite_color (const GdkPixbuf *src,
|
||||||
GdkPixbuf *dest,
|
GdkPixbuf *dest,
|
||||||
@ -212,29 +191,39 @@ void gdk_pixbuf_composite_color (const GdkPixbuf *src,
|
|||||||
double offset_y,
|
double offset_y,
|
||||||
double scale_x,
|
double scale_x,
|
||||||
double scale_y,
|
double scale_y,
|
||||||
ArtFilterLevel filter_level,
|
GdkInterpType interp_type,
|
||||||
int overall_alpha,
|
int overall_alpha,
|
||||||
int check_x,
|
int check_x,
|
||||||
int check_y,
|
int check_y,
|
||||||
int check_size,
|
int check_size,
|
||||||
art_u32 color1,
|
guint32 color1,
|
||||||
art_u32 color2);
|
guint32 color2);
|
||||||
|
|
||||||
GdkPixbuf *gdk_pixbuf_scale_simple (const GdkPixbuf *src,
|
GdkPixbuf *gdk_pixbuf_scale_simple (const GdkPixbuf *src,
|
||||||
int dest_width,
|
int dest_width,
|
||||||
int dest_height,
|
int dest_height,
|
||||||
ArtFilterLevel filter_level);
|
GdkInterpType interp_type);
|
||||||
|
|
||||||
GdkPixbuf *gdk_pixbuf_composite_color_simple (const GdkPixbuf *src,
|
GdkPixbuf *gdk_pixbuf_composite_color_simple (const GdkPixbuf *src,
|
||||||
int dest_width,
|
int dest_width,
|
||||||
int dest_height,
|
int dest_height,
|
||||||
ArtFilterLevel filter_level,
|
GdkInterpType interp_type,
|
||||||
int overall_alpha,
|
int overall_alpha,
|
||||||
int check_size,
|
int check_size,
|
||||||
art_u32 color1,
|
guint32 color1,
|
||||||
art_u32 color2);
|
guint32 color2);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Animation support */
|
/* Animation support */
|
||||||
|
|
||||||
|
/* GIF-like animation overlay modes for frames */
|
||||||
|
typedef enum {
|
||||||
|
GDK_PIXBUF_FRAME_RETAIN,
|
||||||
|
GDK_PIXBUF_FRAME_DISPOSE,
|
||||||
|
GDK_PIXBUF_FRAME_REVERT
|
||||||
|
} GdkPixbufFrameAction;
|
||||||
|
|
||||||
GdkPixbufAnimation *gdk_pixbuf_animation_new_from_file (const char *filename);
|
GdkPixbufAnimation *gdk_pixbuf_animation_new_from_file (const char *filename);
|
||||||
|
|
||||||
GdkPixbufAnimation *gdk_pixbuf_animation_ref (GdkPixbufAnimation *animation);
|
GdkPixbufAnimation *gdk_pixbuf_animation_ref (GdkPixbufAnimation *animation);
|
||||||
@ -245,6 +234,15 @@ int gdk_pixbuf_animation_get_height (GdkPixbufAnimation *an
|
|||||||
GList *gdk_pixbuf_animation_get_frames (GdkPixbufAnimation *animation);
|
GList *gdk_pixbuf_animation_get_frames (GdkPixbufAnimation *animation);
|
||||||
int gdk_pixbuf_animation_get_num_frames (GdkPixbufAnimation *animation);
|
int gdk_pixbuf_animation_get_num_frames (GdkPixbufAnimation *animation);
|
||||||
|
|
||||||
|
/* Frame accessors */
|
||||||
|
|
||||||
|
GdkPixbuf *gdk_pixbuf_frame_get_pixbuf (GdkPixbufFrame *frame);
|
||||||
|
int gdk_pixbuf_frame_get_x_offset (GdkPixbufFrame *frame);
|
||||||
|
int gdk_pixbuf_frame_get_y_offset (GdkPixbufFrame *frame);
|
||||||
|
int gdk_pixbuf_frame_get_delay_time (GdkPixbufFrame *frame);
|
||||||
|
GdkPixbufFrameAction gdk_pixbuf_frame_get_action (GdkPixbufFrame *frame);
|
||||||
|
|
||||||
|
|
||||||
/* General (presently empty) initialization hooks, primarily for gnome-libs */
|
/* General (presently empty) initialization hooks, primarily for gnome-libs */
|
||||||
void gdk_pixbuf_preinit (gpointer app, gpointer modinfo);
|
void gdk_pixbuf_preinit (gpointer app, gpointer modinfo);
|
||||||
void gdk_pixbuf_postinit (gpointer app, gpointer modinfo);
|
void gdk_pixbuf_postinit (gpointer app, gpointer modinfo);
|
||||||
|
@ -24,8 +24,9 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <libgnomeui/gnome-canvas.h>
|
#include <libgnomeui/gnome-canvas.h>
|
||||||
#include <libgnomeui/gnome-canvas-util.h>
|
#include <libgnomeui/gnome-canvas-util.h>
|
||||||
#include "gdk-pixbuf.h"
|
#include <libart_lgpl/art_rgb_affine.h>
|
||||||
#include <libart_lgpl/art_rgb_pixbuf_affine.h>
|
#include <libart_lgpl/art_rgb_rgba_affine.h>
|
||||||
|
#include "gdk-pixbuf-private.h"
|
||||||
#include "gnome-canvas-pixbuf.h"
|
#include "gnome-canvas-pixbuf.h"
|
||||||
|
|
||||||
|
|
||||||
@ -242,10 +243,9 @@ gnome_canvas_pixbuf_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
|
|||||||
pixbuf = GTK_VALUE_POINTER (*arg);
|
pixbuf = GTK_VALUE_POINTER (*arg);
|
||||||
if (pixbuf != priv->pixbuf) {
|
if (pixbuf != priv->pixbuf) {
|
||||||
if (pixbuf) {
|
if (pixbuf) {
|
||||||
g_return_if_fail (pixbuf->art_pixbuf->format == ART_PIX_RGB);
|
g_return_if_fail (pixbuf->colorspace == GDK_COLORSPACE_RGB);
|
||||||
g_return_if_fail (pixbuf->art_pixbuf->n_channels == 3
|
g_return_if_fail (pixbuf->n_channels == 3 || pixbuf->n_channels == 4);
|
||||||
|| pixbuf->art_pixbuf->n_channels == 4);
|
g_return_if_fail (pixbuf->bits_per_sample == 8);
|
||||||
g_return_if_fail (pixbuf->art_pixbuf->bits_per_sample == 8);
|
|
||||||
|
|
||||||
gdk_pixbuf_ref (pixbuf);
|
gdk_pixbuf_ref (pixbuf);
|
||||||
}
|
}
|
||||||
@ -451,12 +451,12 @@ compute_viewport_affine (GnomeCanvasPixbuf *gcp, double *viewport_affine, double
|
|||||||
if (priv->width_set)
|
if (priv->width_set)
|
||||||
w = priv->width;
|
w = priv->width;
|
||||||
else
|
else
|
||||||
w = priv->pixbuf->art_pixbuf->width;
|
w = priv->pixbuf->width;
|
||||||
|
|
||||||
if (priv->height_set)
|
if (priv->height_set)
|
||||||
h = priv->height;
|
h = priv->height;
|
||||||
else
|
else
|
||||||
h = priv->pixbuf->art_pixbuf->height;
|
h = priv->pixbuf->height;
|
||||||
|
|
||||||
/* Convert i_len and j_len into scaling factors */
|
/* Convert i_len and j_len into scaling factors */
|
||||||
|
|
||||||
@ -468,7 +468,7 @@ compute_viewport_affine (GnomeCanvasPixbuf *gcp, double *viewport_affine, double
|
|||||||
} else
|
} else
|
||||||
si_len = 1.0;
|
si_len = 1.0;
|
||||||
|
|
||||||
si_len *= w / priv->pixbuf->art_pixbuf->width;
|
si_len *= w / priv->pixbuf->width;
|
||||||
|
|
||||||
if (priv->height_in_pixels) {
|
if (priv->height_in_pixels) {
|
||||||
if (j_len > GNOME_CANVAS_EPSILON)
|
if (j_len > GNOME_CANVAS_EPSILON)
|
||||||
@ -478,7 +478,7 @@ compute_viewport_affine (GnomeCanvasPixbuf *gcp, double *viewport_affine, double
|
|||||||
} else
|
} else
|
||||||
sj_len = 1.0;
|
sj_len = 1.0;
|
||||||
|
|
||||||
sj_len *= h / priv->pixbuf->art_pixbuf->height;
|
sj_len *= h / priv->pixbuf->height;
|
||||||
|
|
||||||
/* Calculate translation offsets */
|
/* Calculate translation offsets */
|
||||||
|
|
||||||
@ -544,10 +544,10 @@ recompute_bounding_box (GnomeCanvasPixbuf *gcp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
rect.x0 = 0.0;
|
rect.x0 = 0.0;
|
||||||
rect.x1 = priv->pixbuf->art_pixbuf->width;
|
rect.x1 = priv->pixbuf->width;
|
||||||
|
|
||||||
rect.y0 = 0.0;
|
rect.y0 = 0.0;
|
||||||
rect.y1 = priv->pixbuf->art_pixbuf->height;
|
rect.y1 = priv->pixbuf->height;
|
||||||
|
|
||||||
gnome_canvas_item_i2c_affine (item, i2c);
|
gnome_canvas_item_i2c_affine (item, i2c);
|
||||||
compute_render_affine (gcp, render_affine, i2c);
|
compute_render_affine (gcp, render_affine, i2c);
|
||||||
@ -611,7 +611,6 @@ static void
|
|||||||
transform_pixbuf (guchar *dest, int x, int y, int width, int height, int rowstride,
|
transform_pixbuf (guchar *dest, int x, int y, int width, int height, int rowstride,
|
||||||
GdkPixbuf *pixbuf, double *affine)
|
GdkPixbuf *pixbuf, double *affine)
|
||||||
{
|
{
|
||||||
ArtPixBuf *apb;
|
|
||||||
int xx, yy;
|
int xx, yy;
|
||||||
double inv[6];
|
double inv[6];
|
||||||
guchar *src, *d;
|
guchar *src, *d;
|
||||||
@ -620,8 +619,6 @@ transform_pixbuf (guchar *dest, int x, int y, int width, int height, int rowstri
|
|||||||
int src_x, src_y;
|
int src_x, src_y;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
apb = pixbuf->art_pixbuf;
|
|
||||||
|
|
||||||
art_affine_invert (inv, affine);
|
art_affine_invert (inv, affine);
|
||||||
|
|
||||||
for (yy = 0; yy < height; yy++) {
|
for (yy = 0; yy < height; yy++) {
|
||||||
@ -630,7 +627,7 @@ transform_pixbuf (guchar *dest, int x, int y, int width, int height, int rowstri
|
|||||||
run_x1 = x;
|
run_x1 = x;
|
||||||
run_x2 = x + width;
|
run_x2 = x + width;
|
||||||
art_rgb_affine_run (&run_x1, &run_x2, yy + y,
|
art_rgb_affine_run (&run_x1, &run_x2, yy + y,
|
||||||
apb->width, apb->height,
|
pixbuf->width, pixbuf->height,
|
||||||
inv);
|
inv);
|
||||||
|
|
||||||
d = dest + yy * rowstride + (run_x1 - x) * 4;
|
d = dest + yy * rowstride + (run_x1 - x) * 4;
|
||||||
@ -641,12 +638,12 @@ transform_pixbuf (guchar *dest, int x, int y, int width, int height, int rowstri
|
|||||||
src_x = floor (src_p.x);
|
src_x = floor (src_p.x);
|
||||||
src_y = floor (src_p.y);
|
src_y = floor (src_p.y);
|
||||||
|
|
||||||
src = apb->pixels + src_y * apb->rowstride + src_x * apb->n_channels;
|
src = pixbuf->pixels + src_y * pixbuf->rowstride + src_x * pixbuf->n_channels;
|
||||||
|
|
||||||
for (i = 0; i < apb->n_channels; i++)
|
for (i = 0; i < pixbuf->n_channels; i++)
|
||||||
*d++ = *src++;
|
*d++ = *src++;
|
||||||
|
|
||||||
if (!apb->has_alpha)
|
if (!pixbuf->has_alpha)
|
||||||
*d++ = 255; /* opaque */
|
*d++ = 255; /* opaque */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -702,7 +699,7 @@ gnome_canvas_pixbuf_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
|
|||||||
w * 4,
|
w * 4,
|
||||||
priv->pixbuf, render_affine);
|
priv->pixbuf, render_affine);
|
||||||
|
|
||||||
pixbuf = gdk_pixbuf_new_from_data (buf, ART_PIX_RGB, TRUE, w, h, w * 4, NULL, NULL);
|
pixbuf = gdk_pixbuf_new_from_data (buf, GDK_COLORSPACE_RGB, TRUE, 8, w, h, w * 4, NULL, NULL);
|
||||||
|
|
||||||
gdk_pixbuf_render_to_drawable_alpha (pixbuf, drawable,
|
gdk_pixbuf_render_to_drawable_alpha (pixbuf, drawable,
|
||||||
0, 0,
|
0, 0,
|
||||||
@ -735,14 +732,28 @@ gnome_canvas_pixbuf_render (GnomeCanvasItem *item, GnomeCanvasBuf *buf)
|
|||||||
compute_render_affine (gcp, render_affine, i2c);
|
compute_render_affine (gcp, render_affine, i2c);
|
||||||
gnome_canvas_buf_ensure_buf (buf);
|
gnome_canvas_buf_ensure_buf (buf);
|
||||||
|
|
||||||
art_rgb_pixbuf_affine (buf->buf,
|
if (priv->pixbuf->has_alpha)
|
||||||
buf->rect.x0, buf->rect.y0, buf->rect.x1, buf->rect.y1,
|
art_rgb_rgba_affine (buf->buf,
|
||||||
buf->buf_rowstride,
|
buf->rect.x0, buf->rect.y0, buf->rect.x1, buf->rect.y1,
|
||||||
priv->pixbuf->art_pixbuf,
|
buf->buf_rowstride,
|
||||||
render_affine,
|
priv->pixbuf->pixels,
|
||||||
ART_FILTER_NEAREST, NULL);
|
priv->pixbuf->width, priv->pixbuf->height,
|
||||||
|
priv->pixbuf->rowstride,
|
||||||
|
render_affine,
|
||||||
|
ART_FILTER_NEAREST,
|
||||||
|
NULL);
|
||||||
|
else
|
||||||
|
art_rgb_affine (buf->buf,
|
||||||
|
buf->rect.x0, buf->rect.y0, buf->rect.x1, buf->rect.y1,
|
||||||
|
buf->buf_rowstride,
|
||||||
|
priv->pixbuf->pixels,
|
||||||
|
priv->pixbuf->width, priv->pixbuf->height,
|
||||||
|
priv->pixbuf->rowstride,
|
||||||
|
render_affine,
|
||||||
|
ART_FILTER_NEAREST,
|
||||||
|
NULL);
|
||||||
|
|
||||||
buf->is_bg = 0;
|
buf->is_bg = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -758,7 +769,6 @@ gnome_canvas_pixbuf_point (GnomeCanvasItem *item, double x, double y, int cx, in
|
|||||||
ArtPoint c, p;
|
ArtPoint c, p;
|
||||||
int px, py;
|
int px, py;
|
||||||
double no_hit;
|
double no_hit;
|
||||||
ArtPixBuf *apb;
|
|
||||||
guchar *src;
|
guchar *src;
|
||||||
|
|
||||||
gcp = GNOME_CANVAS_PIXBUF (item);
|
gcp = GNOME_CANVAS_PIXBUF (item);
|
||||||
@ -771,8 +781,6 @@ gnome_canvas_pixbuf_point (GnomeCanvasItem *item, double x, double y, int cx, in
|
|||||||
if (!priv->pixbuf)
|
if (!priv->pixbuf)
|
||||||
return no_hit;
|
return no_hit;
|
||||||
|
|
||||||
apb = priv->pixbuf->art_pixbuf;
|
|
||||||
|
|
||||||
gnome_canvas_item_i2c_affine (item, i2c);
|
gnome_canvas_item_i2c_affine (item, i2c);
|
||||||
compute_render_affine (gcp, render_affine, i2c);
|
compute_render_affine (gcp, render_affine, i2c);
|
||||||
art_affine_invert (inv, render_affine);
|
art_affine_invert (inv, render_affine);
|
||||||
@ -783,13 +791,13 @@ gnome_canvas_pixbuf_point (GnomeCanvasItem *item, double x, double y, int cx, in
|
|||||||
px = p.x;
|
px = p.x;
|
||||||
py = p.y;
|
py = p.y;
|
||||||
|
|
||||||
if (px < 0 || px >= apb->width || py < 0 || py >= apb->height)
|
if (px < 0 || px >= priv->pixbuf->width || py < 0 || py >= priv->pixbuf->height)
|
||||||
return no_hit;
|
return no_hit;
|
||||||
|
|
||||||
if (!apb->has_alpha)
|
if (!priv->pixbuf->has_alpha)
|
||||||
return 0.0;
|
return 0.0;
|
||||||
|
|
||||||
src = apb->pixels + py * apb->rowstride + px * apb->n_channels;
|
src = priv->pixbuf->pixels + py * priv->pixbuf->rowstride + px * priv->pixbuf->n_channels;
|
||||||
|
|
||||||
if (src[3] < 128)
|
if (src[3] < 128)
|
||||||
return no_hit;
|
return no_hit;
|
||||||
@ -817,10 +825,10 @@ gnome_canvas_pixbuf_bounds (GnomeCanvasItem *item, double *x1, double *y1, doubl
|
|||||||
}
|
}
|
||||||
|
|
||||||
rect.x0 = 0.0;
|
rect.x0 = 0.0;
|
||||||
rect.x1 = priv->pixbuf->art_pixbuf->width;
|
rect.x1 = priv->pixbuf->width;
|
||||||
|
|
||||||
rect.y0 = 0.0;
|
rect.y0 = 0.0;
|
||||||
rect.y1 = priv->pixbuf->art_pixbuf->height;
|
rect.y1 = priv->pixbuf->height;
|
||||||
|
|
||||||
gnome_canvas_item_i2c_affine (item, i2c);
|
gnome_canvas_item_i2c_affine (item, i2c);
|
||||||
compute_viewport_affine (gcp, viewport_affine, i2c);
|
compute_viewport_affine (gcp, viewport_affine, i2c);
|
||||||
|
@ -35,13 +35,11 @@ Known bugs:
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
#include "gdk-pixbuf-private.h"
|
||||||
#include <gdk-pixbuf/gdk-pixbuf-io.h>
|
#include "gdk-pixbuf-io.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
These structures are actually dummies. These are according to
|
These structures are actually dummies. These are according to
|
||||||
@ -287,12 +285,12 @@ static void DecodeHeader(unsigned char *BFH, unsigned char *BIH,
|
|||||||
if (State->pixbuf == NULL) {
|
if (State->pixbuf == NULL) {
|
||||||
if (State->Type == 32)
|
if (State->Type == 32)
|
||||||
State->pixbuf =
|
State->pixbuf =
|
||||||
gdk_pixbuf_new(ART_PIX_RGB, TRUE, 8,
|
gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8,
|
||||||
(gint) State->Header.width,
|
(gint) State->Header.width,
|
||||||
(gint) State->Header.height);
|
(gint) State->Header.height);
|
||||||
else
|
else
|
||||||
State->pixbuf =
|
State->pixbuf =
|
||||||
gdk_pixbuf_new(ART_PIX_RGB, FALSE, 8,
|
gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8,
|
||||||
(gint) State->Header.width,
|
(gint) State->Header.width,
|
||||||
(gint) State->Header.height);
|
(gint) State->Header.height);
|
||||||
|
|
||||||
@ -387,14 +385,13 @@ static void OneLine32(struct bmp_progressive_state *context)
|
|||||||
|
|
||||||
X = 0;
|
X = 0;
|
||||||
if (context->Header.Negative == 0)
|
if (context->Header.Negative == 0)
|
||||||
Pixels = context->pixbuf->art_pixbuf->pixels +
|
Pixels = (context->pixbuf->pixels +
|
||||||
gdk_pixbuf_get_rowstride(context->pixbuf) *
|
context->pixbuf->rowstride *
|
||||||
(context->Header.height - context->Lines - 1);
|
(context->Header.height - context->Lines - 1));
|
||||||
else
|
else
|
||||||
Pixels =
|
Pixels = (context->pixbuf->pixels +
|
||||||
context->pixbuf->art_pixbuf->pixels +
|
context->pixbuf->rowstride *
|
||||||
gdk_pixbuf_get_rowstride(context->pixbuf) *
|
context->Lines);
|
||||||
context->Lines;
|
|
||||||
while (X < context->Header.width) {
|
while (X < context->Header.width) {
|
||||||
Pixels[X * 4 + 0] = context->LineBuf[X * 4 + 2];
|
Pixels[X * 4 + 0] = context->LineBuf[X * 4 + 2];
|
||||||
Pixels[X * 4 + 1] = context->LineBuf[X * 4 + 1];
|
Pixels[X * 4 + 1] = context->LineBuf[X * 4 + 1];
|
||||||
@ -412,14 +409,13 @@ static void OneLine24(struct bmp_progressive_state *context)
|
|||||||
|
|
||||||
X = 0;
|
X = 0;
|
||||||
if (context->Header.Negative == 0)
|
if (context->Header.Negative == 0)
|
||||||
Pixels = context->pixbuf->art_pixbuf->pixels +
|
Pixels = (context->pixbuf->pixels +
|
||||||
gdk_pixbuf_get_rowstride(context->pixbuf) *
|
context->pixbuf->rowstride *
|
||||||
(context->Header.height - context->Lines - 1);
|
(context->Header.height - context->Lines - 1));
|
||||||
else
|
else
|
||||||
Pixels =
|
Pixels = (context->pixbuf->pixels +
|
||||||
context->pixbuf->art_pixbuf->pixels +
|
context->pixbuf->rowstride *
|
||||||
gdk_pixbuf_get_rowstride(context->pixbuf) *
|
context->Lines);
|
||||||
context->Lines;
|
|
||||||
while (X < context->Header.width) {
|
while (X < context->Header.width) {
|
||||||
Pixels[X * 3 + 0] = context->LineBuf[X * 3 + 2];
|
Pixels[X * 3 + 0] = context->LineBuf[X * 3 + 2];
|
||||||
Pixels[X * 3 + 1] = context->LineBuf[X * 3 + 1];
|
Pixels[X * 3 + 1] = context->LineBuf[X * 3 + 1];
|
||||||
@ -436,14 +432,13 @@ static void OneLine8(struct bmp_progressive_state *context)
|
|||||||
|
|
||||||
X = 0;
|
X = 0;
|
||||||
if (context->Header.Negative == 0)
|
if (context->Header.Negative == 0)
|
||||||
Pixels = context->pixbuf->art_pixbuf->pixels +
|
Pixels = (context->pixbuf->pixels +
|
||||||
gdk_pixbuf_get_rowstride(context->pixbuf) *
|
context->pixbuf->rowstride *
|
||||||
(context->Header.height - context->Lines - 1);
|
(context->Header.height - context->Lines - 1));
|
||||||
else
|
else
|
||||||
Pixels =
|
Pixels = (context->pixbuf->pixels +
|
||||||
context->pixbuf->art_pixbuf->pixels +
|
context->pixbuf->rowstride *
|
||||||
gdk_pixbuf_get_rowstride(context->pixbuf) *
|
context->Lines);
|
||||||
context->Lines;
|
|
||||||
while (X < context->Header.width) {
|
while (X < context->Header.width) {
|
||||||
Pixels[X * 3 + 0] =
|
Pixels[X * 3 + 0] =
|
||||||
context->HeaderBuf[4 * context->LineBuf[X] + 56];
|
context->HeaderBuf[4 * context->LineBuf[X] + 56];
|
||||||
@ -462,14 +457,13 @@ static void OneLine4(struct bmp_progressive_state *context)
|
|||||||
|
|
||||||
X = 0;
|
X = 0;
|
||||||
if (context->Header.Negative == 0)
|
if (context->Header.Negative == 0)
|
||||||
Pixels = context->pixbuf->art_pixbuf->pixels +
|
Pixels = (context->pixbuf->pixels +
|
||||||
gdk_pixbuf_get_rowstride(context->pixbuf) *
|
context->pixbuf->rowstride *
|
||||||
(context->Header.height - context->Lines - 1);
|
(context->Header.height - context->Lines - 1));
|
||||||
else
|
else
|
||||||
Pixels =
|
Pixels = (context->pixbuf->pixels +
|
||||||
context->pixbuf->art_pixbuf->pixels +
|
context->pixbuf->rowstride *
|
||||||
gdk_pixbuf_get_rowstride(context->pixbuf) *
|
context->Lines);
|
||||||
context->Lines;
|
|
||||||
|
|
||||||
while (X < context->Header.width) {
|
while (X < context->Header.width) {
|
||||||
guchar Pix;
|
guchar Pix;
|
||||||
@ -504,14 +498,13 @@ static void OneLine1(struct bmp_progressive_state *context)
|
|||||||
|
|
||||||
X = 0;
|
X = 0;
|
||||||
if (context->Header.Negative == 0)
|
if (context->Header.Negative == 0)
|
||||||
Pixels = context->pixbuf->art_pixbuf->pixels +
|
Pixels = (context->pixbuf->pixels +
|
||||||
gdk_pixbuf_get_rowstride(context->pixbuf) *
|
context->pixbuf->rowstride *
|
||||||
(context->Header.height - context->Lines - 1);
|
(context->Header.height - context->Lines - 1));
|
||||||
else
|
else
|
||||||
Pixels =
|
Pixels = (context->pixbuf->pixels +
|
||||||
context->pixbuf->art_pixbuf->pixels +
|
context->pixbuf->rowstride *
|
||||||
gdk_pixbuf_get_rowstride(context->pixbuf) *
|
context->Lines);
|
||||||
context->Lines;
|
|
||||||
while (X < context->Header.width) {
|
while (X < context->Header.width) {
|
||||||
gint Bit;
|
gint Bit;
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "gdk-pixbuf.h"
|
#include "gdk-pixbuf-private.h"
|
||||||
#include "gdk-pixbuf-io.h"
|
#include "gdk-pixbuf-io.h"
|
||||||
|
|
||||||
|
|
||||||
@ -666,7 +666,7 @@ gif_get_lzw (GifContext *context)
|
|||||||
gint v;
|
gint v;
|
||||||
|
|
||||||
if (context->pixbuf == NULL) {
|
if (context->pixbuf == NULL) {
|
||||||
context->pixbuf = gdk_pixbuf_new (ART_PIX_RGB,
|
context->pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
|
||||||
context->gif89.transparent != -1,
|
context->gif89.transparent != -1,
|
||||||
8,
|
8,
|
||||||
context->frame_len,
|
context->frame_len,
|
||||||
|
@ -37,12 +37,11 @@ Known bugs:
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "gdk-pixbuf.h"
|
#include "gdk-pixbuf-private.h"
|
||||||
#include "gdk-pixbuf-io.h"
|
#include "gdk-pixbuf-io.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
These structures are actually dummies. These are according to
|
These structures are actually dummies. These are according to
|
||||||
@ -345,7 +344,7 @@ static void DecodeHeader(guchar *Data, gint Bytes,
|
|||||||
|
|
||||||
if (State->pixbuf == NULL) {
|
if (State->pixbuf == NULL) {
|
||||||
State->pixbuf =
|
State->pixbuf =
|
||||||
gdk_pixbuf_new(ART_PIX_RGB, TRUE, 8,
|
gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8,
|
||||||
(gint) State->Header.width,
|
(gint) State->Header.width,
|
||||||
(gint) State->Header.height);
|
(gint) State->Header.height);
|
||||||
|
|
||||||
@ -433,13 +432,13 @@ static void OneLine24(struct ico_progressive_state *context)
|
|||||||
|
|
||||||
X = 0;
|
X = 0;
|
||||||
if (context->Header.Negative == 0)
|
if (context->Header.Negative == 0)
|
||||||
Pixels = context->pixbuf->art_pixbuf->pixels +
|
Pixels = (context->pixbuf->pixels +
|
||||||
gdk_pixbuf_get_rowstride(context->pixbuf) *
|
context->pixbuf->rowstride *
|
||||||
(context->Header.height - context->Lines - 1);
|
(context->Header.height - context->Lines - 1));
|
||||||
else
|
else
|
||||||
Pixels = context->pixbuf->art_pixbuf->pixels +
|
Pixels = (context->pixbuf->pixels +
|
||||||
gdk_pixbuf_get_rowstride(context->pixbuf) *
|
context->pixbuf->rowstride *
|
||||||
context->Lines;
|
context->Lines);
|
||||||
while (X < context->Header.width) {
|
while (X < context->Header.width) {
|
||||||
Pixels[X * 4 + 0] = context->LineBuf[X * 3 + 2];
|
Pixels[X * 4 + 0] = context->LineBuf[X * 3 + 2];
|
||||||
Pixels[X * 4 + 1] = context->LineBuf[X * 3 + 1];
|
Pixels[X * 4 + 1] = context->LineBuf[X * 3 + 1];
|
||||||
@ -456,13 +455,13 @@ static void OneLine8(struct ico_progressive_state *context)
|
|||||||
|
|
||||||
X = 0;
|
X = 0;
|
||||||
if (context->Header.Negative == 0)
|
if (context->Header.Negative == 0)
|
||||||
Pixels = context->pixbuf->art_pixbuf->pixels +
|
Pixels = (context->pixbuf->pixels +
|
||||||
gdk_pixbuf_get_rowstride(context->pixbuf) *
|
context->pixbuf->rowstride *
|
||||||
(context->Header.height - context->Lines - 1);
|
(context->Header.height - context->Lines - 1));
|
||||||
else
|
else
|
||||||
Pixels = context->pixbuf->art_pixbuf->pixels +
|
Pixels = (context->pixbuf->pixels +
|
||||||
gdk_pixbuf_get_rowstride(context->pixbuf) *
|
context->pixbuf->rowstride *
|
||||||
context->Lines;
|
context->Lines);
|
||||||
while (X < context->Header.width) {
|
while (X < context->Header.width) {
|
||||||
/* The joys of having a BGR byteorder */
|
/* The joys of having a BGR byteorder */
|
||||||
Pixels[X * 4 + 0] =
|
Pixels[X * 4 + 0] =
|
||||||
@ -481,13 +480,13 @@ static void OneLine4(struct ico_progressive_state *context)
|
|||||||
|
|
||||||
X = 0;
|
X = 0;
|
||||||
if (context->Header.Negative == 0)
|
if (context->Header.Negative == 0)
|
||||||
Pixels = context->pixbuf->art_pixbuf->pixels +
|
Pixels = (context->pixbuf->pixels +
|
||||||
gdk_pixbuf_get_rowstride(context->pixbuf) *
|
context->pixbuf->rowstride *
|
||||||
(context->Header.height - context->Lines - 1);
|
(context->Header.height - context->Lines - 1));
|
||||||
else
|
else
|
||||||
Pixels = context->pixbuf->art_pixbuf->pixels +
|
Pixels = (context->pixbuf->pixels +
|
||||||
gdk_pixbuf_get_rowstride(context->pixbuf) *
|
context->pixbuf->rowstride *
|
||||||
context->Lines;
|
context->Lines);
|
||||||
|
|
||||||
while (X < context->Header.width) {
|
while (X < context->Header.width) {
|
||||||
guchar Pix;
|
guchar Pix;
|
||||||
@ -522,13 +521,13 @@ static void OneLine1(struct ico_progressive_state *context)
|
|||||||
|
|
||||||
X = 0;
|
X = 0;
|
||||||
if (context->Header.Negative == 0)
|
if (context->Header.Negative == 0)
|
||||||
Pixels = context->pixbuf->art_pixbuf->pixels +
|
Pixels = (context->pixbuf->pixels +
|
||||||
gdk_pixbuf_get_rowstride(context->pixbuf) *
|
context->pixbuf->rowstride *
|
||||||
(context->Header.height - context->Lines - 1);
|
(context->Header.height - context->Lines - 1));
|
||||||
else
|
else
|
||||||
Pixels = context->pixbuf->art_pixbuf->pixels +
|
Pixels = (context->pixbuf->pixels +
|
||||||
gdk_pixbuf_get_rowstride(context->pixbuf) *
|
context->pixbuf->rowstride *
|
||||||
context->Lines;
|
context->Lines);
|
||||||
while (X < context->Header.width) {
|
while (X < context->Header.width) {
|
||||||
int Bit;
|
int Bit;
|
||||||
|
|
||||||
@ -549,13 +548,13 @@ static void OneLineTransp(struct ico_progressive_state *context)
|
|||||||
|
|
||||||
X = 0;
|
X = 0;
|
||||||
if (context->Header.Negative == 0)
|
if (context->Header.Negative == 0)
|
||||||
Pixels = context->pixbuf->art_pixbuf->pixels +
|
Pixels = (context->pixbuf->pixels +
|
||||||
gdk_pixbuf_get_rowstride(context->pixbuf) *
|
context->pixbuf->rowstride *
|
||||||
(2*context->Header.height - context->Lines - 1);
|
(2*context->Header.height - context->Lines - 1));
|
||||||
else
|
else
|
||||||
Pixels = context->pixbuf->art_pixbuf->pixels +
|
Pixels = (context->pixbuf->pixels +
|
||||||
gdk_pixbuf_get_rowstride(context->pixbuf) *
|
context->pixbuf->rowstride *
|
||||||
(context->Lines-context->Header.height);
|
(context->Lines-context->Header.height));
|
||||||
while (X < context->Header.width) {
|
while (X < context->Header.width) {
|
||||||
int Bit;
|
int Bit;
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <jpeglib.h>
|
#include <jpeglib.h>
|
||||||
#include "gdk-pixbuf.h"
|
#include "gdk-pixbuf-private.h"
|
||||||
#include "gdk-pixbuf-io.h"
|
#include "gdk-pixbuf-io.h"
|
||||||
|
|
||||||
|
|
||||||
@ -111,11 +111,11 @@ fatal_error_handler (j_common_ptr cinfo)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Destroy notification function for the libart pixbuf */
|
/* Destroy notification function for the pixbuf */
|
||||||
static void
|
static void
|
||||||
free_buffer (gpointer user_data, gpointer data)
|
free_buffer (guchar *pixels, gpointer data)
|
||||||
{
|
{
|
||||||
free (data);
|
free (pixels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -215,7 +215,7 @@ gdk_pixbuf__jpeg_image_load (FILE *f)
|
|||||||
jpeg_finish_decompress (&cinfo);
|
jpeg_finish_decompress (&cinfo);
|
||||||
jpeg_destroy_decompress (&cinfo);
|
jpeg_destroy_decompress (&cinfo);
|
||||||
|
|
||||||
return gdk_pixbuf_new_from_data (pixels, ART_PIX_RGB, FALSE,
|
return gdk_pixbuf_new_from_data (pixels, GDK_COLORSPACE_RGB, FALSE, 8,
|
||||||
w, h, w * 3,
|
w, h, w * 3,
|
||||||
free_buffer, NULL);
|
free_buffer, NULL);
|
||||||
}
|
}
|
||||||
@ -451,8 +451,8 @@ gdk_pixbuf__jpeg_image_load_increment (gpointer data, guchar *buf, guint size)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
context->pixbuf = gdk_pixbuf_new(ART_PIX_RGB,
|
context->pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB,
|
||||||
/*have_alpha*/ FALSE,
|
FALSE,
|
||||||
8,
|
8,
|
||||||
cinfo->image_width,
|
cinfo->image_width,
|
||||||
cinfo->image_height);
|
cinfo->image_height);
|
||||||
@ -463,7 +463,7 @@ gdk_pixbuf__jpeg_image_load_increment (gpointer data, guchar *buf, guint size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Use pixbuf buffer to store decompressed data */
|
/* Use pixbuf buffer to store decompressed data */
|
||||||
context->dptr = context->pixbuf->art_pixbuf->pixels;
|
context->dptr = context->pixbuf->pixels;
|
||||||
|
|
||||||
/* Notify the client that we are ready to go */
|
/* Notify the client that we are ready to go */
|
||||||
(* context->prepared_func) (context->pixbuf,
|
(* context->prepared_func) (context->pixbuf,
|
||||||
@ -497,7 +497,7 @@ gdk_pixbuf__jpeg_image_load_increment (gpointer data, guchar *buf, guint size)
|
|||||||
rowptr = context->dptr;
|
rowptr = context->dptr;
|
||||||
for (i=0; i < cinfo->rec_outbuf_height; i++) {
|
for (i=0; i < cinfo->rec_outbuf_height; i++) {
|
||||||
*lptr++ = rowptr;
|
*lptr++ = rowptr;
|
||||||
rowptr += context->pixbuf->art_pixbuf->rowstride;
|
rowptr += context->pixbuf->rowstride;
|
||||||
}
|
}
|
||||||
|
|
||||||
nlines = jpeg_read_scanlines (cinfo, lines,
|
nlines = jpeg_read_scanlines (cinfo, lines,
|
||||||
@ -509,7 +509,7 @@ gdk_pixbuf__jpeg_image_load_increment (gpointer data, guchar *buf, guint size)
|
|||||||
if (cinfo->output_components == 1)
|
if (cinfo->output_components == 1)
|
||||||
explode_gray_into_buf (cinfo, lines);
|
explode_gray_into_buf (cinfo, lines);
|
||||||
|
|
||||||
context->dptr += nlines * context->pixbuf->art_pixbuf->rowstride;
|
context->dptr += nlines * context->pixbuf->rowstride;
|
||||||
|
|
||||||
/* send updated signal */
|
/* send updated signal */
|
||||||
(* context->updated_func) (context->pixbuf,
|
(* context->updated_func) (context->pixbuf,
|
||||||
|
@ -24,8 +24,9 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <png.h>
|
#include <png.h>
|
||||||
#include "gdk-pixbuf.h"
|
#include "gdk-pixbuf-private.h"
|
||||||
#include "gdk-pixbuf-io.h"
|
#include "gdk-pixbuf-io.h"
|
||||||
|
|
||||||
|
|
||||||
@ -139,11 +140,11 @@ setup_png_transformations(png_structp png_read_ptr, png_infop png_info_ptr,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Destroy notification function for the libart pixbuf */
|
/* Destroy notification function for the pixbuf */
|
||||||
static void
|
static void
|
||||||
free_buffer (gpointer user_data, gpointer data)
|
free_buffer (guchar *pixels, gpointer data)
|
||||||
{
|
{
|
||||||
free (data);
|
free (pixels);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Shared library entry point */
|
/* Shared library entry point */
|
||||||
@ -210,11 +211,11 @@ gdk_pixbuf__png_image_load (FILE *f)
|
|||||||
g_free (rows);
|
g_free (rows);
|
||||||
|
|
||||||
if (ctype & PNG_COLOR_MASK_ALPHA)
|
if (ctype & PNG_COLOR_MASK_ALPHA)
|
||||||
return gdk_pixbuf_new_from_data (pixels, ART_PIX_RGB, TRUE,
|
return gdk_pixbuf_new_from_data (pixels, GDK_COLORSPACE_RGB, TRUE, 8,
|
||||||
w, h, w * 4,
|
w, h, w * 4,
|
||||||
free_buffer, NULL);
|
free_buffer, NULL);
|
||||||
else
|
else
|
||||||
return gdk_pixbuf_new_from_data (pixels, ART_PIX_RGB, FALSE,
|
return gdk_pixbuf_new_from_data (pixels, GDK_COLORSPACE_RGB, FALSE, 8,
|
||||||
w, h, w * 3,
|
w, h, w * 3,
|
||||||
free_buffer, NULL);
|
free_buffer, NULL);
|
||||||
}
|
}
|
||||||
@ -371,7 +372,7 @@ gdk_pixbuf__png_image_load_increment(gpointer context, guchar *buf, guint size)
|
|||||||
/* start and end row were in the same pass */
|
/* start and end row were in the same pass */
|
||||||
(lc->update_func)(lc->pixbuf, 0,
|
(lc->update_func)(lc->pixbuf, 0,
|
||||||
lc->first_row_seen_in_chunk,
|
lc->first_row_seen_in_chunk,
|
||||||
lc->pixbuf->art_pixbuf->width,
|
lc->pixbuf->width,
|
||||||
(lc->last_row_seen_in_chunk -
|
(lc->last_row_seen_in_chunk -
|
||||||
lc->first_row_seen_in_chunk) + 1,
|
lc->first_row_seen_in_chunk) + 1,
|
||||||
lc->notify_user_data);
|
lc->notify_user_data);
|
||||||
@ -383,14 +384,14 @@ gdk_pixbuf__png_image_load_increment(gpointer context, guchar *buf, guint size)
|
|||||||
/* first row to end */
|
/* first row to end */
|
||||||
(lc->update_func)(lc->pixbuf, 0,
|
(lc->update_func)(lc->pixbuf, 0,
|
||||||
lc->first_row_seen_in_chunk,
|
lc->first_row_seen_in_chunk,
|
||||||
lc->pixbuf->art_pixbuf->width,
|
lc->pixbuf->width,
|
||||||
(lc->max_row_seen_in_chunk -
|
(lc->max_row_seen_in_chunk -
|
||||||
lc->first_row_seen_in_chunk) + 1,
|
lc->first_row_seen_in_chunk) + 1,
|
||||||
lc->notify_user_data);
|
lc->notify_user_data);
|
||||||
/* top to last row */
|
/* top to last row */
|
||||||
(lc->update_func)(lc->pixbuf,
|
(lc->update_func)(lc->pixbuf,
|
||||||
0, 0,
|
0, 0,
|
||||||
lc->pixbuf->art_pixbuf->width,
|
lc->pixbuf->width,
|
||||||
lc->last_row_seen_in_chunk + 1,
|
lc->last_row_seen_in_chunk + 1,
|
||||||
lc->notify_user_data);
|
lc->notify_user_data);
|
||||||
} else {
|
} else {
|
||||||
@ -398,7 +399,7 @@ gdk_pixbuf__png_image_load_increment(gpointer context, guchar *buf, guint size)
|
|||||||
whole image */
|
whole image */
|
||||||
(lc->update_func)(lc->pixbuf,
|
(lc->update_func)(lc->pixbuf,
|
||||||
0, 0,
|
0, 0,
|
||||||
lc->pixbuf->art_pixbuf->width,
|
lc->pixbuf->width,
|
||||||
lc->max_row_seen_in_chunk + 1,
|
lc->max_row_seen_in_chunk + 1,
|
||||||
lc->notify_user_data);
|
lc->notify_user_data);
|
||||||
}
|
}
|
||||||
@ -439,7 +440,7 @@ png_info_callback (png_structp png_read_ptr,
|
|||||||
if (color_type & PNG_COLOR_MASK_ALPHA)
|
if (color_type & PNG_COLOR_MASK_ALPHA)
|
||||||
have_alpha = TRUE;
|
have_alpha = TRUE;
|
||||||
|
|
||||||
lc->pixbuf = gdk_pixbuf_new(ART_PIX_RGB, have_alpha, 8, width, height);
|
lc->pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, have_alpha, 8, width, height);
|
||||||
|
|
||||||
if (lc->pixbuf == NULL) {
|
if (lc->pixbuf == NULL) {
|
||||||
/* Failed to allocate memory */
|
/* Failed to allocate memory */
|
||||||
@ -480,7 +481,7 @@ png_row_callback (png_structp png_read_ptr,
|
|||||||
lc->last_row_seen_in_chunk = row_num;
|
lc->last_row_seen_in_chunk = row_num;
|
||||||
lc->last_pass_seen_in_chunk = pass_num;
|
lc->last_pass_seen_in_chunk = pass_num;
|
||||||
|
|
||||||
old_row = lc->pixbuf->art_pixbuf->pixels + (row_num * lc->pixbuf->art_pixbuf->rowstride);
|
old_row = lc->pixbuf->pixels + (row_num * lc->pixbuf->rowstride);
|
||||||
|
|
||||||
png_progressive_combine_row(lc->png_read_ptr, old_row, new_row);
|
png_progressive_combine_row(lc->png_read_ptr, old_row, new_row);
|
||||||
}
|
}
|
||||||
@ -521,4 +522,3 @@ png_warning_callback(png_structp png_read_ptr,
|
|||||||
|
|
||||||
fprintf(stderr, "Warning loading PNG: %s\n", warning_msg);
|
fprintf(stderr, "Warning loading PNG: %s\n", warning_msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include "gdk-pixbuf.h"
|
#include "gdk-pixbuf-private.h"
|
||||||
#include "gdk-pixbuf-io.h"
|
#include "gdk-pixbuf-io.h"
|
||||||
|
|
||||||
|
|
||||||
@ -87,11 +87,11 @@ gboolean gdk_pixbuf__pnm_image_load_increment(gpointer context, guchar *buf, gui
|
|||||||
static void explode_bitmap_into_buf (PnmLoaderContext *context);
|
static void explode_bitmap_into_buf (PnmLoaderContext *context);
|
||||||
static void explode_gray_into_buf (PnmLoaderContext *context);
|
static void explode_gray_into_buf (PnmLoaderContext *context);
|
||||||
|
|
||||||
/* Destroy notification function for the libart pixbuf */
|
/* Destroy notification function for the pixbuf */
|
||||||
static void
|
static void
|
||||||
free_buffer (gpointer user_data, gpointer data)
|
free_buffer (guchar *pixels, gpointer data)
|
||||||
{
|
{
|
||||||
free (data);
|
free (pixels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -675,7 +675,7 @@ gdk_pixbuf__pnm_image_load (FILE *f)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return gdk_pixbuf_new_from_data (context.pixels, ART_PIX_RGB, FALSE,
|
return gdk_pixbuf_new_from_data (context.pixels, GDK_COLORSPACE_RGB, FALSE, 8,
|
||||||
context.width, context.height,
|
context.width, context.height,
|
||||||
context.width * 3, free_buffer, NULL);
|
context.width * 3, free_buffer, NULL);
|
||||||
|
|
||||||
@ -807,8 +807,8 @@ gdk_pixbuf__pnm_image_load_increment (gpointer data, guchar *buf, guint size)
|
|||||||
context->output_row = 0;
|
context->output_row = 0;
|
||||||
context->output_col = 0;
|
context->output_col = 0;
|
||||||
|
|
||||||
context->pixbuf = gdk_pixbuf_new(ART_PIX_RGB,
|
context->pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB,
|
||||||
/*have_alpha*/ FALSE,
|
FALSE,
|
||||||
8,
|
8,
|
||||||
context->width,
|
context->width,
|
||||||
context->height);
|
context->height);
|
||||||
@ -818,8 +818,8 @@ gdk_pixbuf__pnm_image_load_increment (gpointer data, guchar *buf, guint size)
|
|||||||
g_error ("Couldn't allocate gdkpixbuf");
|
g_error ("Couldn't allocate gdkpixbuf");
|
||||||
}
|
}
|
||||||
|
|
||||||
context->pixels = context->pixbuf->art_pixbuf->pixels;
|
context->pixels = context->pixbuf->pixels;
|
||||||
context->rowstride = context->pixbuf->art_pixbuf->rowstride;
|
context->rowstride = context->pixbuf->rowstride;
|
||||||
|
|
||||||
/* Notify the client that we are ready to go */
|
/* Notify the client that we are ready to go */
|
||||||
(* context->prepared_func) (context->pixbuf,
|
(* context->prepared_func) (context->pixbuf,
|
||||||
|
@ -34,12 +34,11 @@ Known bugs:
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "gdk-pixbuf.h"
|
#include "gdk-pixbuf-private.h"
|
||||||
#include "gdk-pixbuf-io.h"
|
#include "gdk-pixbuf-io.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Header structure for sunras files.
|
Header structure for sunras files.
|
||||||
All values are in big-endian order on disk
|
All values are in big-endian order on disk
|
||||||
@ -171,7 +170,7 @@ static void RAS2State(struct rasterfile *RAS,
|
|||||||
|
|
||||||
if (State->pixbuf == NULL) {
|
if (State->pixbuf == NULL) {
|
||||||
if (State->RasType == 32)
|
if (State->RasType == 32)
|
||||||
State->pixbuf = gdk_pixbuf_new(ART_PIX_RGB, TRUE,
|
State->pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE,
|
||||||
8,
|
8,
|
||||||
(gint)
|
(gint)
|
||||||
State->Header.width,
|
State->Header.width,
|
||||||
@ -180,7 +179,7 @@ static void RAS2State(struct rasterfile *RAS,
|
|||||||
height);
|
height);
|
||||||
else
|
else
|
||||||
State->pixbuf =
|
State->pixbuf =
|
||||||
gdk_pixbuf_new(ART_PIX_RGB, FALSE, 8,
|
gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8,
|
||||||
(gint) State->Header.width,
|
(gint) State->Header.width,
|
||||||
(gint) State->Header.height);
|
(gint) State->Header.height);
|
||||||
if (State->prepared_func != NULL)
|
if (State->prepared_func != NULL)
|
||||||
@ -278,8 +277,7 @@ static void OneLine32(struct ras_progressive_state *context)
|
|||||||
guchar *Pixels;
|
guchar *Pixels;
|
||||||
|
|
||||||
X = 0;
|
X = 0;
|
||||||
Pixels = context->pixbuf->art_pixbuf->pixels +
|
Pixels = context->pixbuf->pixels + context->pixbuf->rowstride * context->Lines;
|
||||||
context->pixbuf->art_pixbuf->rowstride * context->Lines;
|
|
||||||
while (X < context->Header.width) {
|
while (X < context->Header.width) {
|
||||||
/* The joys of having a BGR byteorder */
|
/* The joys of having a BGR byteorder */
|
||||||
Pixels[X * 4 + 0] = context->LineBuf[X * 4 + 2];
|
Pixels[X * 4 + 0] = context->LineBuf[X * 4 + 2];
|
||||||
@ -296,8 +294,7 @@ static void OneLine24(struct ras_progressive_state *context)
|
|||||||
guchar *Pixels;
|
guchar *Pixels;
|
||||||
|
|
||||||
X = 0;
|
X = 0;
|
||||||
Pixels = context->pixbuf->art_pixbuf->pixels +
|
Pixels = context->pixbuf->pixels + context->pixbuf->rowstride * context->Lines;
|
||||||
context->pixbuf->art_pixbuf->rowstride * context->Lines;
|
|
||||||
while (X < context->Header.width) {
|
while (X < context->Header.width) {
|
||||||
/* The joys of having a BGR byteorder */
|
/* The joys of having a BGR byteorder */
|
||||||
Pixels[X * 3 + 0] = context->LineBuf[X * 3 + 2];
|
Pixels[X * 3 + 0] = context->LineBuf[X * 3 + 2];
|
||||||
@ -314,8 +311,7 @@ static void OneLine8(struct ras_progressive_state *context)
|
|||||||
guchar *Pixels;
|
guchar *Pixels;
|
||||||
|
|
||||||
X = 0;
|
X = 0;
|
||||||
Pixels = context->pixbuf->art_pixbuf->pixels +
|
Pixels = context->pixbuf->pixels + context->pixbuf->rowstride * context->Lines;
|
||||||
context->pixbuf->art_pixbuf->rowstride * context->Lines;
|
|
||||||
while (X < context->Header.width) {
|
while (X < context->Header.width) {
|
||||||
/* The joys of having a BGR byteorder */
|
/* The joys of having a BGR byteorder */
|
||||||
Pixels[X * 3 + 0] =
|
Pixels[X * 3 + 0] =
|
||||||
@ -334,8 +330,7 @@ static void OneLine1(struct ras_progressive_state *context)
|
|||||||
guchar *Pixels;
|
guchar *Pixels;
|
||||||
|
|
||||||
X = 0;
|
X = 0;
|
||||||
Pixels = context->pixbuf->art_pixbuf->pixels +
|
Pixels = context->pixbuf->pixels + context->pixbuf->rowstride * context->Lines;
|
||||||
context->pixbuf->art_pixbuf->rowstride * context->Lines;
|
|
||||||
while (X < context->Header.width) {
|
while (X < context->Header.width) {
|
||||||
int Bit;
|
int Bit;
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <tiffio.h>
|
#include <tiffio.h>
|
||||||
#include "gdk-pixbuf.h"
|
#include "gdk-pixbuf-private.h"
|
||||||
#include "gdk-pixbuf-io.h"
|
#include "gdk-pixbuf-io.h"
|
||||||
|
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ gdk_pixbuf__tiff_image_load_real (FILE *f, TiffData *context)
|
|||||||
TIFFGetField (tiff, TIFFTAG_IMAGEWIDTH, &w);
|
TIFFGetField (tiff, TIFFTAG_IMAGEWIDTH, &w);
|
||||||
TIFFGetField (tiff, TIFFTAG_IMAGELENGTH, &h);
|
TIFFGetField (tiff, TIFFTAG_IMAGELENGTH, &h);
|
||||||
num_pixs = w * h;
|
num_pixs = w * h;
|
||||||
pixbuf = gdk_pixbuf_new (ART_PIX_RGB, TRUE, 8, w, h);
|
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, w, h);
|
||||||
|
|
||||||
if (context)
|
if (context)
|
||||||
(* context->prepare_func) (pixbuf, context->user_data);
|
(* context->prepare_func) (pixbuf, context->user_data);
|
||||||
|
@ -24,10 +24,11 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <gdk/gdk.h>
|
#include <gdk/gdk.h>
|
||||||
#include "gdk-pixbuf.h"
|
#include "gdk-pixbuf-private.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -309,11 +310,11 @@ mem_buffer (enum buf_op op, gpointer handle)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Destroy notification function for the libart pixbuf */
|
/* Destroy notification function for the pixbuf */
|
||||||
static void
|
static void
|
||||||
free_buffer (gpointer user_data, gpointer data)
|
free_buffer (guchar *pixels, gpointer data)
|
||||||
{
|
{
|
||||||
free (data);
|
free (pixels);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function does all the work. */
|
/* This function does all the work. */
|
||||||
@ -429,7 +430,7 @@ pixbuf_create_from_xpm (const gchar * (*get_buf) (enum buf_op op, gpointer handl
|
|||||||
g_free (colors);
|
g_free (colors);
|
||||||
g_free (name_buf);
|
g_free (name_buf);
|
||||||
|
|
||||||
return gdk_pixbuf_new_from_data (pixels, ART_PIX_RGB, is_trans,
|
return gdk_pixbuf_new_from_data (pixels, GDK_COLORSPACE_RGB, is_trans, 8,
|
||||||
w, h, is_trans ? (w * 4) : (w * 3),
|
w, h, is_trans ? (w * 4) : (w * 3),
|
||||||
free_buffer, NULL);
|
free_buffer, NULL);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
noinst_LTLIBRARIES = libpixops.la
|
noinst_LTLIBRARIES = libpixops.la
|
||||||
|
|
||||||
INCLUDES = $(GLIB_CFLAGS) $(LIBART_CFLAGS)
|
INCLUDES = $(GLIB_CFLAGS) $(LIBART_CFLAGS) -I$(top_srcdir)/gdk-pixbuf
|
||||||
|
|
||||||
noinst_PROGRAMS = timescale
|
noinst_PROGRAMS = timescale
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifdef USE_MMX
|
#ifdef USE_MMX
|
||||||
art_u8 *pixops_scale_line_22_33_mmx (art_u32 weights[16][8], art_u8 *p, art_u8 *q1, art_u8 *q2, int x_step, art_u8 *p_stop, int x_init);
|
guchar *pixops_scale_line_22_33_mmx (guint32 weights[16][8], guchar *p, guchar *q1, guchar *q2, int x_step, guchar *p_stop, int x_init);
|
||||||
art_u8 *pixops_composite_line_22_4a4_mmx (art_u32 weights[16][8], art_u8 *p, art_u8 *q1, art_u8 *q2, int x_step, art_u8 *p_stop, int x_init);
|
guchar *pixops_composite_line_22_4a4_mmx (guint32 weights[16][8], guchar *p, guchar *q1, guchar *q2, int x_step, guchar *p_stop, int x_init);
|
||||||
art_u8 *pixops_composite_line_color_22_4a4_mmx (art_u32 weights[16][8], art_u8 *p, art_u8 *q1, art_u8 *q2, int x_step, art_u8 *p_stop, int x_init, int dest_x, int check_shift, int *colors);
|
guchar *pixops_composite_line_color_22_4a4_mmx (guint32 weights[16][8], guchar *p, guchar *q1, guchar *q2, int x_step, guchar *p_stop, int x_init, int dest_x, int check_shift, int *colors);
|
||||||
int pixops_have_mmx (void);
|
int pixops_have_mmx (void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -21,15 +21,15 @@ struct _PixopsFilter
|
|||||||
double y_offset;
|
double y_offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef art_u8 *(*PixopsLineFunc) (int *weights, int n_x, int n_y,
|
typedef guchar *(*PixopsLineFunc) (int *weights, int n_x, int n_y,
|
||||||
art_u8 *dest, int dest_x, art_u8 *dest_end, int dest_channels, int dest_has_alpha,
|
guchar *dest, int dest_x, guchar *dest_end, int dest_channels, int dest_has_alpha,
|
||||||
art_u8 **src, int src_channels, art_boolean src_has_alpha,
|
guchar **src, int src_channels, gboolean src_has_alpha,
|
||||||
int x_init, int x_step, int src_width,
|
int x_init, int x_step, int src_width,
|
||||||
int check_size, art_u32 color1, art_u32 color2);
|
int check_size, guint32 color1, guint32 color2);
|
||||||
|
|
||||||
typedef void (*PixopsPixelFunc) (art_u8 *dest, int dest_x, int dest_channels, int dest_has_alpha,
|
typedef void (*PixopsPixelFunc) (guchar *dest, int dest_x, int dest_channels, int dest_has_alpha,
|
||||||
int src_has_alpha, int check_size, art_u32 color1,
|
int src_has_alpha, int check_size, guint32 color1,
|
||||||
art_u32 color2,
|
guint32 color2,
|
||||||
int r, int g, int b, int a);
|
int r, int g, int b, int a);
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -48,20 +48,20 @@ get_check_shift (int check_size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pixops_scale_nearest (art_u8 *dest_buf,
|
pixops_scale_nearest (guchar *dest_buf,
|
||||||
int render_x0,
|
int render_x0,
|
||||||
int render_y0,
|
int render_y0,
|
||||||
int render_x1,
|
int render_x1,
|
||||||
int render_y1,
|
int render_y1,
|
||||||
int dest_rowstride,
|
int dest_rowstride,
|
||||||
int dest_channels,
|
int dest_channels,
|
||||||
art_boolean dest_has_alpha,
|
gboolean dest_has_alpha,
|
||||||
const art_u8 *src_buf,
|
const guchar *src_buf,
|
||||||
int src_width,
|
int src_width,
|
||||||
int src_height,
|
int src_height,
|
||||||
int src_rowstride,
|
int src_rowstride,
|
||||||
int src_channels,
|
int src_channels,
|
||||||
art_boolean src_has_alpha,
|
gboolean src_has_alpha,
|
||||||
double scale_x,
|
double scale_x,
|
||||||
double scale_y)
|
double scale_y)
|
||||||
{
|
{
|
||||||
@ -73,7 +73,7 @@ pixops_scale_nearest (art_u8 *dest_buf,
|
|||||||
#define INNER_LOOP(SRC_CHANNELS,DEST_CHANNELS) \
|
#define INNER_LOOP(SRC_CHANNELS,DEST_CHANNELS) \
|
||||||
for (j=0; j < (render_x1 - render_x0); j++) \
|
for (j=0; j < (render_x1 - render_x0); j++) \
|
||||||
{ \
|
{ \
|
||||||
const art_u8 *p = src + (x >> SCALE_SHIFT) * SRC_CHANNELS; \
|
const guchar *p = src + (x >> SCALE_SHIFT) * SRC_CHANNELS; \
|
||||||
\
|
\
|
||||||
dest[0] = p[0]; \
|
dest[0] = p[0]; \
|
||||||
dest[1] = p[1]; \
|
dest[1] = p[1]; \
|
||||||
@ -93,8 +93,8 @@ pixops_scale_nearest (art_u8 *dest_buf,
|
|||||||
|
|
||||||
for (i = 0; i < (render_y1 - render_y0); i++)
|
for (i = 0; i < (render_y1 - render_y0); i++)
|
||||||
{
|
{
|
||||||
const art_u8 *src = src_buf + ((i * y_step + y_step / 2) >> SCALE_SHIFT) * src_rowstride;
|
const guchar *src = src_buf + ((i * y_step + y_step / 2) >> SCALE_SHIFT) * src_rowstride;
|
||||||
art_u8 *dest = dest_buf + i * dest_rowstride;
|
guchar *dest = dest_buf + i * dest_rowstride;
|
||||||
|
|
||||||
x = render_x0 * x_step + x_step / 2;
|
x = render_x0 * x_step + x_step / 2;
|
||||||
|
|
||||||
@ -119,9 +119,11 @@ pixops_scale_nearest (art_u8 *dest_buf,
|
|||||||
{
|
{
|
||||||
for (j=0; j < (render_x1 - render_x0); j++)
|
for (j=0; j < (render_x1 - render_x0); j++)
|
||||||
{
|
{
|
||||||
const art_u8 *p = src + (x >> SCALE_SHIFT) * 4;
|
const guchar *p = src + (x >> SCALE_SHIFT) * 4;
|
||||||
|
guint32 *p32;
|
||||||
|
|
||||||
*(art_u32 *)dest = *(art_u32 *)p;
|
p32 = (guint32 *) dest;
|
||||||
|
*p32 = *((guint32 *) p);
|
||||||
|
|
||||||
dest += 4;
|
dest += 4;
|
||||||
x += x_step;
|
x += x_step;
|
||||||
@ -133,20 +135,20 @@ pixops_scale_nearest (art_u8 *dest_buf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pixops_composite_nearest (art_u8 *dest_buf,
|
pixops_composite_nearest (guchar *dest_buf,
|
||||||
int render_x0,
|
int render_x0,
|
||||||
int render_y0,
|
int render_y0,
|
||||||
int render_x1,
|
int render_x1,
|
||||||
int render_y1,
|
int render_y1,
|
||||||
int dest_rowstride,
|
int dest_rowstride,
|
||||||
int dest_channels,
|
int dest_channels,
|
||||||
art_boolean dest_has_alpha,
|
gboolean dest_has_alpha,
|
||||||
const art_u8 *src_buf,
|
const guchar *src_buf,
|
||||||
int src_width,
|
int src_width,
|
||||||
int src_height,
|
int src_height,
|
||||||
int src_rowstride,
|
int src_rowstride,
|
||||||
int src_channels,
|
int src_channels,
|
||||||
art_boolean src_has_alpha,
|
gboolean src_has_alpha,
|
||||||
double scale_x,
|
double scale_x,
|
||||||
double scale_y,
|
double scale_y,
|
||||||
int overall_alpha)
|
int overall_alpha)
|
||||||
@ -158,14 +160,14 @@ pixops_composite_nearest (art_u8 *dest_buf,
|
|||||||
|
|
||||||
for (i = 0; i < (render_y1 - render_y0); i++)
|
for (i = 0; i < (render_y1 - render_y0); i++)
|
||||||
{
|
{
|
||||||
const art_u8 *src = src_buf + (((i + render_y0) * y_step + y_step / 2) >> SCALE_SHIFT) * src_rowstride;
|
const guchar *src = src_buf + (((i + render_y0) * y_step + y_step / 2) >> SCALE_SHIFT) * src_rowstride;
|
||||||
art_u8 *dest = dest_buf + i * dest_rowstride + render_x0 * dest_channels;
|
guchar *dest = dest_buf + i * dest_rowstride + render_x0 * dest_channels;
|
||||||
|
|
||||||
x = render_x0 * x_step + x_step / 2;
|
x = render_x0 * x_step + x_step / 2;
|
||||||
|
|
||||||
for (j=0; j < (render_x1 - render_x0); j++)
|
for (j=0; j < (render_x1 - render_x0); j++)
|
||||||
{
|
{
|
||||||
const art_u8 *p = src + (x >> SCALE_SHIFT) * src_channels;
|
const guchar *p = src + (x >> SCALE_SHIFT) * src_channels;
|
||||||
unsigned int a0;
|
unsigned int a0;
|
||||||
|
|
||||||
if (src_has_alpha)
|
if (src_has_alpha)
|
||||||
@ -210,28 +212,28 @@ pixops_composite_nearest (art_u8 *dest_buf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pixops_composite_color_nearest (art_u8 *dest_buf,
|
pixops_composite_color_nearest (guchar *dest_buf,
|
||||||
int render_x0,
|
int render_x0,
|
||||||
int render_y0,
|
int render_y0,
|
||||||
int render_x1,
|
int render_x1,
|
||||||
int render_y1,
|
int render_y1,
|
||||||
int dest_rowstride,
|
int dest_rowstride,
|
||||||
int dest_channels,
|
int dest_channels,
|
||||||
art_boolean dest_has_alpha,
|
gboolean dest_has_alpha,
|
||||||
const art_u8 *src_buf,
|
const guchar *src_buf,
|
||||||
int src_width,
|
int src_width,
|
||||||
int src_height,
|
int src_height,
|
||||||
int src_rowstride,
|
int src_rowstride,
|
||||||
int src_channels,
|
int src_channels,
|
||||||
art_boolean src_has_alpha,
|
gboolean src_has_alpha,
|
||||||
double scale_x,
|
double scale_x,
|
||||||
double scale_y,
|
double scale_y,
|
||||||
int overall_alpha,
|
int overall_alpha,
|
||||||
int check_x,
|
int check_x,
|
||||||
int check_y,
|
int check_y,
|
||||||
int check_size,
|
int check_size,
|
||||||
art_u32 color1,
|
guint32 color1,
|
||||||
art_u32 color2)
|
guint32 color2)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
int x;
|
int x;
|
||||||
@ -242,8 +244,8 @@ pixops_composite_color_nearest (art_u8 *dest_buf,
|
|||||||
|
|
||||||
for (i = 0; i < (render_y1 - render_y0); i++)
|
for (i = 0; i < (render_y1 - render_y0); i++)
|
||||||
{
|
{
|
||||||
const art_u8 *src = src_buf + (((i + render_y0) * y_step + y_step/2) >> SCALE_SHIFT) * src_rowstride;
|
const guchar *src = src_buf + (((i + render_y0) * y_step + y_step/2) >> SCALE_SHIFT) * src_rowstride;
|
||||||
art_u8 *dest = dest_buf + i * dest_rowstride;
|
guchar *dest = dest_buf + i * dest_rowstride;
|
||||||
|
|
||||||
x = render_x0 * x_step + x_step / 2;
|
x = render_x0 * x_step + x_step / 2;
|
||||||
|
|
||||||
@ -270,7 +272,7 @@ pixops_composite_color_nearest (art_u8 *dest_buf,
|
|||||||
|
|
||||||
for (j=0 ; j < (render_x1 - render_x0); j++)
|
for (j=0 ; j < (render_x1 - render_x0); j++)
|
||||||
{
|
{
|
||||||
const art_u8 *p = src + (x >> SCALE_SHIFT) * src_channels;
|
const guchar *p = src + (x >> SCALE_SHIFT) * src_channels;
|
||||||
unsigned int a0;
|
unsigned int a0;
|
||||||
|
|
||||||
if (src_has_alpha)
|
if (src_has_alpha)
|
||||||
@ -301,8 +303,8 @@ pixops_composite_color_nearest (art_u8 *dest_buf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
composite_pixel (art_u8 *dest, int dest_x, int dest_channels, int dest_has_alpha,
|
composite_pixel (guchar *dest, int dest_x, int dest_channels, int dest_has_alpha,
|
||||||
int src_has_alpha, int check_size, art_u32 color1, art_u32 color2,
|
int src_has_alpha, int check_size, guint32 color1, guint32 color2,
|
||||||
int r, int g, int b, int a)
|
int r, int g, int b, int a)
|
||||||
{
|
{
|
||||||
if (dest_has_alpha)
|
if (dest_has_alpha)
|
||||||
@ -333,12 +335,12 @@ composite_pixel (art_u8 *dest, int dest_x, int dest_channels, int dest_has_alpha
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static art_u8 *
|
static guchar *
|
||||||
composite_line (int *weights, int n_x, int n_y,
|
composite_line (int *weights, int n_x, int n_y,
|
||||||
art_u8 *dest, int dest_x, art_u8 *dest_end, int dest_channels, int dest_has_alpha,
|
guchar *dest, int dest_x, guchar *dest_end, int dest_channels, int dest_has_alpha,
|
||||||
art_u8 **src, int src_channels, art_boolean src_has_alpha,
|
guchar **src, int src_channels, gboolean src_has_alpha,
|
||||||
int x_init, int x_step, int src_width,
|
int x_init, int x_step, int src_width,
|
||||||
int check_size, art_u32 color1, art_u32 color2)
|
int check_size, guint32 color1, guint32 color2)
|
||||||
{
|
{
|
||||||
int x = x_init;
|
int x = x_init;
|
||||||
int i, j;
|
int i, j;
|
||||||
@ -353,7 +355,7 @@ composite_line (int *weights, int n_x, int n_y,
|
|||||||
|
|
||||||
for (i=0; i<n_y; i++)
|
for (i=0; i<n_y; i++)
|
||||||
{
|
{
|
||||||
art_u8 *q = src[i] + x_scaled * src_channels;
|
guchar *q = src[i] + x_scaled * src_channels;
|
||||||
int *line_weights = pixel_weights + n_x * i;
|
int *line_weights = pixel_weights + n_x * i;
|
||||||
|
|
||||||
for (j=0; j<n_x; j++)
|
for (j=0; j<n_x; j++)
|
||||||
@ -408,16 +410,16 @@ composite_line (int *weights, int n_x, int n_y,
|
|||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
static art_u8 *
|
static guchar *
|
||||||
composite_line_22_4a4 (int *weights, int n_x, int n_y,
|
composite_line_22_4a4 (int *weights, int n_x, int n_y,
|
||||||
art_u8 *dest, int dest_x, art_u8 *dest_end, int dest_channels, int dest_has_alpha,
|
guchar *dest, int dest_x, guchar *dest_end, int dest_channels, int dest_has_alpha,
|
||||||
art_u8 **src, int src_channels, art_boolean src_has_alpha,
|
guchar **src, int src_channels, gboolean src_has_alpha,
|
||||||
int x_init, int x_step, int src_width,
|
int x_init, int x_step, int src_width,
|
||||||
int check_size, art_u32 color1, art_u32 color2)
|
int check_size, guint32 color1, guint32 color2)
|
||||||
{
|
{
|
||||||
int x = x_init;
|
int x = x_init;
|
||||||
art_u8 *src0 = src[0];
|
guchar *src0 = src[0];
|
||||||
art_u8 *src1 = src[1];
|
guchar *src1 = src[1];
|
||||||
|
|
||||||
g_return_val_if_fail (src_channels != 3, dest);
|
g_return_val_if_fail (src_channels != 3, dest);
|
||||||
g_return_val_if_fail (src_has_alpha, dest);
|
g_return_val_if_fail (src_has_alpha, dest);
|
||||||
@ -427,7 +429,7 @@ composite_line_22_4a4 (int *weights, int n_x, int n_y,
|
|||||||
int x_scaled = x >> SCALE_SHIFT;
|
int x_scaled = x >> SCALE_SHIFT;
|
||||||
unsigned int r, g, b, a, ta;
|
unsigned int r, g, b, a, ta;
|
||||||
int *pixel_weights;
|
int *pixel_weights;
|
||||||
art_u8 *q0, *q1;
|
guchar *q0, *q1;
|
||||||
int w1, w2, w3, w4;
|
int w1, w2, w3, w4;
|
||||||
|
|
||||||
q0 = src0 + x_scaled * 4;
|
q0 = src0 + x_scaled * 4;
|
||||||
@ -476,14 +478,14 @@ composite_line_22_4a4 (int *weights, int n_x, int n_y,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_MMX
|
#ifdef USE_MMX
|
||||||
static art_u8 *
|
static guchar *
|
||||||
composite_line_22_4a4_mmx_stub (int *weights, int n_x, int n_y,
|
composite_line_22_4a4_mmx_stub (int *weights, int n_x, int n_y,
|
||||||
art_u8 *dest, int dest_x, art_u8 *dest_end, int dest_channels, int dest_has_alpha,
|
guchar *dest, int dest_x, guchar *dest_end, int dest_channels, int dest_has_alpha,
|
||||||
art_u8 **src, int src_channels, art_boolean src_has_alpha,
|
guchar **src, int src_channels, gboolean src_has_alpha,
|
||||||
int x_init, int x_step, int src_width,
|
int x_init, int x_step, int src_width,
|
||||||
int check_size, art_u32 color1, art_u32 color2)
|
int check_size, guint32 color1, guint32 color2)
|
||||||
{
|
{
|
||||||
art_u32 mmx_weights[16][8];
|
guint32 mmx_weights[16][8];
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
for (j=0; j<16; j++)
|
for (j=0; j<16; j++)
|
||||||
@ -503,8 +505,8 @@ composite_line_22_4a4_mmx_stub (int *weights, int n_x, int n_y,
|
|||||||
#endif /* USE_MMX */
|
#endif /* USE_MMX */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
composite_pixel_color (art_u8 *dest, int dest_x, int dest_channels, int dest_has_alpha,
|
composite_pixel_color (guchar *dest, int dest_x, int dest_channels, int dest_has_alpha,
|
||||||
int src_has_alpha, int check_size, art_u32 color1, art_u32 color2,
|
int src_has_alpha, int check_size, guint32 color1, guint32 color2,
|
||||||
int r, int g, int b, int a)
|
int r, int g, int b, int a)
|
||||||
{
|
{
|
||||||
int dest_r, dest_g, dest_b;
|
int dest_r, dest_g, dest_b;
|
||||||
@ -533,12 +535,12 @@ composite_pixel_color (art_u8 *dest, int dest_x, int dest_channels, int dest_has
|
|||||||
dest[3] = a >> 16;
|
dest[3] = a >> 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
static art_u8 *
|
static guchar *
|
||||||
composite_line_color (int *weights, int n_x, int n_y,
|
composite_line_color (int *weights, int n_x, int n_y,
|
||||||
art_u8 *dest, int dest_x, art_u8 *dest_end, int dest_channels, int dest_has_alpha,
|
guchar *dest, int dest_x, guchar *dest_end, int dest_channels, int dest_has_alpha,
|
||||||
art_u8 **src, int src_channels, art_boolean src_has_alpha,
|
guchar **src, int src_channels, gboolean src_has_alpha,
|
||||||
int x_init, int x_step, int src_width,
|
int x_init, int x_step, int src_width,
|
||||||
int check_size, art_u32 color1, art_u32 color2)
|
int check_size, guint32 color1, guint32 color2)
|
||||||
{
|
{
|
||||||
int x = x_init;
|
int x = x_init;
|
||||||
int i, j;
|
int i, j;
|
||||||
@ -566,7 +568,7 @@ composite_line_color (int *weights, int n_x, int n_y,
|
|||||||
|
|
||||||
for (i=0; i<n_y; i++)
|
for (i=0; i<n_y; i++)
|
||||||
{
|
{
|
||||||
art_u8 *q = src[i] + x_scaled * src_channels;
|
guchar *q = src[i] + x_scaled * src_channels;
|
||||||
int *line_weights = pixel_weights + n_x * i;
|
int *line_weights = pixel_weights + n_x * i;
|
||||||
|
|
||||||
for (j=0; j<n_x; j++)
|
for (j=0; j<n_x; j++)
|
||||||
@ -614,14 +616,14 @@ composite_line_color (int *weights, int n_x, int n_y,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_MMX
|
#ifdef USE_MMX
|
||||||
static art_u8 *
|
static guchar *
|
||||||
composite_line_color_22_4a4_mmx_stub (int *weights, int n_x, int n_y,
|
composite_line_color_22_4a4_mmx_stub (int *weights, int n_x, int n_y,
|
||||||
art_u8 *dest, int dest_x, art_u8 *dest_end, int dest_channels, int dest_has_alpha,
|
guchar *dest, int dest_x, guchar *dest_end, int dest_channels, int dest_has_alpha,
|
||||||
art_u8 **src, int src_channels, art_boolean src_has_alpha,
|
guchar **src, int src_channels, gboolean src_has_alpha,
|
||||||
int x_init, int x_step, int src_width,
|
int x_init, int x_step, int src_width,
|
||||||
int check_size, art_u32 color1, art_u32 color2)
|
int check_size, guint32 color1, guint32 color2)
|
||||||
{
|
{
|
||||||
art_u32 mmx_weights[16][8];
|
guint32 mmx_weights[16][8];
|
||||||
int check_shift = get_check_shift (check_size);
|
int check_shift = get_check_shift (check_size);
|
||||||
int colors[4];
|
int colors[4];
|
||||||
int j;
|
int j;
|
||||||
@ -649,8 +651,8 @@ composite_line_color_22_4a4_mmx_stub (int *weights, int n_x, int n_y,
|
|||||||
#endif /* USE_MMX */
|
#endif /* USE_MMX */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
scale_pixel (art_u8 *dest, int dest_x, int dest_channels, int dest_has_alpha,
|
scale_pixel (guchar *dest, int dest_x, int dest_channels, int dest_has_alpha,
|
||||||
int src_has_alpha, int check_size, art_u32 color1, art_u32 color2,
|
int src_has_alpha, int check_size, guint32 color1, guint32 color2,
|
||||||
int r, int g, int b, int a)
|
int r, int g, int b, int a)
|
||||||
{
|
{
|
||||||
if (src_has_alpha)
|
if (src_has_alpha)
|
||||||
@ -681,12 +683,12 @@ scale_pixel (art_u8 *dest, int dest_x, int dest_channels, int dest_has_alpha,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static art_u8 *
|
static guchar *
|
||||||
scale_line (int *weights, int n_x, int n_y,
|
scale_line (int *weights, int n_x, int n_y,
|
||||||
art_u8 *dest, int dest_x, art_u8 *dest_end, int dest_channels, int dest_has_alpha,
|
guchar *dest, int dest_x, guchar *dest_end, int dest_channels, int dest_has_alpha,
|
||||||
art_u8 **src, int src_channels, art_boolean src_has_alpha,
|
guchar **src, int src_channels, gboolean src_has_alpha,
|
||||||
int x_init, int x_step, int src_width,
|
int x_init, int x_step, int src_width,
|
||||||
int check_size, art_u32 color1, art_u32 color2)
|
int check_size, guint32 color1, guint32 color2)
|
||||||
{
|
{
|
||||||
int x = x_init;
|
int x = x_init;
|
||||||
int i, j;
|
int i, j;
|
||||||
@ -703,7 +705,7 @@ scale_line (int *weights, int n_x, int n_y,
|
|||||||
unsigned int r = 0, g = 0, b = 0, a = 0;
|
unsigned int r = 0, g = 0, b = 0, a = 0;
|
||||||
for (i=0; i<n_y; i++)
|
for (i=0; i<n_y; i++)
|
||||||
{
|
{
|
||||||
art_u8 *q = src[i] + x_scaled * src_channels;
|
guchar *q = src[i] + x_scaled * src_channels;
|
||||||
int *line_weights = pixel_weights + n_x * i;
|
int *line_weights = pixel_weights + n_x * i;
|
||||||
|
|
||||||
for (j=0; j<n_x; j++)
|
for (j=0; j<n_x; j++)
|
||||||
@ -740,7 +742,7 @@ scale_line (int *weights, int n_x, int n_y,
|
|||||||
unsigned int r = 0, g = 0, b = 0;
|
unsigned int r = 0, g = 0, b = 0;
|
||||||
for (i=0; i<n_y; i++)
|
for (i=0; i<n_y; i++)
|
||||||
{
|
{
|
||||||
art_u8 *q = src[i] + x_scaled * src_channels;
|
guchar *q = src[i] + x_scaled * src_channels;
|
||||||
int *line_weights = pixel_weights + n_x * i;
|
int *line_weights = pixel_weights + n_x * i;
|
||||||
|
|
||||||
for (j=0; j<n_x; j++)
|
for (j=0; j<n_x; j++)
|
||||||
@ -772,14 +774,14 @@ scale_line (int *weights, int n_x, int n_y,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_MMX
|
#ifdef USE_MMX
|
||||||
static art_u8 *
|
static guchar *
|
||||||
scale_line_22_33_mmx_stub (int *weights, int n_x, int n_y,
|
scale_line_22_33_mmx_stub (int *weights, int n_x, int n_y,
|
||||||
art_u8 *dest, int dest_x, art_u8 *dest_end, int dest_channels, int dest_has_alpha,
|
guchar *dest, int dest_x, guchar *dest_end, int dest_channels, int dest_has_alpha,
|
||||||
art_u8 **src, int src_channels, art_boolean src_has_alpha,
|
guchar **src, int src_channels, gboolean src_has_alpha,
|
||||||
int x_init, int x_step, int src_width,
|
int x_init, int x_step, int src_width,
|
||||||
int check_size, art_u32 color1, art_u32 color2)
|
int check_size, guint32 color1, guint32 color2)
|
||||||
{
|
{
|
||||||
art_u32 mmx_weights[16][8];
|
guint32 mmx_weights[16][8];
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
for (j=0; j<16; j++)
|
for (j=0; j<16; j++)
|
||||||
@ -798,23 +800,23 @@ scale_line_22_33_mmx_stub (int *weights, int n_x, int n_y,
|
|||||||
}
|
}
|
||||||
#endif /* USE_MMX */
|
#endif /* USE_MMX */
|
||||||
|
|
||||||
static art_u8 *
|
static guchar *
|
||||||
scale_line_22_33 (int *weights, int n_x, int n_y,
|
scale_line_22_33 (int *weights, int n_x, int n_y,
|
||||||
art_u8 *dest, art_u8 *dest_end, int dest_channels, int dest_has_alpha,
|
guchar *dest, guchar *dest_end, int dest_channels, int dest_has_alpha,
|
||||||
art_u8 **src, int src_channels, art_boolean src_has_alpha,
|
guchar **src, int src_channels, gboolean src_has_alpha,
|
||||||
int x_init, int x_step, int src_width,
|
int x_init, int x_step, int src_width,
|
||||||
int check_size, art_u32 color1, art_u32 color2)
|
int check_size, guint32 color1, guint32 color2)
|
||||||
{
|
{
|
||||||
int x = x_init;
|
int x = x_init;
|
||||||
art_u8 *src0 = src[0];
|
guchar *src0 = src[0];
|
||||||
art_u8 *src1 = src[1];
|
guchar *src1 = src[1];
|
||||||
|
|
||||||
while (dest < dest_end)
|
while (dest < dest_end)
|
||||||
{
|
{
|
||||||
unsigned int r, g, b;
|
unsigned int r, g, b;
|
||||||
int x_scaled = x >> SCALE_SHIFT;
|
int x_scaled = x >> SCALE_SHIFT;
|
||||||
int *pixel_weights;
|
int *pixel_weights;
|
||||||
art_u8 *q0, *q1;
|
guchar *q0, *q1;
|
||||||
int w1, w2, w3, w4;
|
int w1, w2, w3, w4;
|
||||||
|
|
||||||
q0 = src0 + x_scaled * 3;
|
q0 = src0 + x_scaled * 3;
|
||||||
@ -857,10 +859,10 @@ scale_line_22_33 (int *weights, int n_x, int n_y,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
process_pixel (int *weights, int n_x, int n_y,
|
process_pixel (int *weights, int n_x, int n_y,
|
||||||
art_u8 *dest, int dest_x, int dest_channels, int dest_has_alpha,
|
guchar *dest, int dest_x, int dest_channels, int dest_has_alpha,
|
||||||
art_u8 **src, int src_channels, art_boolean src_has_alpha,
|
guchar **src, int src_channels, gboolean src_has_alpha,
|
||||||
int x_start, int src_width,
|
int x_start, int src_width,
|
||||||
int check_size, art_u32 color1, art_u32 color2,
|
int check_size, guint32 color1, guint32 color2,
|
||||||
PixopsPixelFunc pixel_func)
|
PixopsPixelFunc pixel_func)
|
||||||
{
|
{
|
||||||
unsigned int r = 0, g = 0, b = 0, a = 0;
|
unsigned int r = 0, g = 0, b = 0, a = 0;
|
||||||
@ -873,7 +875,7 @@ process_pixel (int *weights, int n_x, int n_y,
|
|||||||
for (j=0; j<n_x; j++)
|
for (j=0; j<n_x; j++)
|
||||||
{
|
{
|
||||||
unsigned int ta;
|
unsigned int ta;
|
||||||
art_u8 *q;
|
guchar *q;
|
||||||
|
|
||||||
if (x_start + j < 0)
|
if (x_start + j < 0)
|
||||||
q = src[i];
|
q = src[i];
|
||||||
@ -898,34 +900,34 @@ process_pixel (int *weights, int n_x, int n_y,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pixops_process (art_u8 *dest_buf,
|
pixops_process (guchar *dest_buf,
|
||||||
int render_x0,
|
int render_x0,
|
||||||
int render_y0,
|
int render_y0,
|
||||||
int render_x1,
|
int render_x1,
|
||||||
int render_y1,
|
int render_y1,
|
||||||
int dest_rowstride,
|
int dest_rowstride,
|
||||||
int dest_channels,
|
int dest_channels,
|
||||||
art_boolean dest_has_alpha,
|
gboolean dest_has_alpha,
|
||||||
const art_u8 *src_buf,
|
const guchar *src_buf,
|
||||||
int src_width,
|
int src_width,
|
||||||
int src_height,
|
int src_height,
|
||||||
int src_rowstride,
|
int src_rowstride,
|
||||||
int src_channels,
|
int src_channels,
|
||||||
art_boolean src_has_alpha,
|
gboolean src_has_alpha,
|
||||||
double scale_x,
|
double scale_x,
|
||||||
double scale_y,
|
double scale_y,
|
||||||
int check_x,
|
int check_x,
|
||||||
int check_y,
|
int check_y,
|
||||||
int check_size,
|
int check_size,
|
||||||
art_u32 color1,
|
guint32 color1,
|
||||||
art_u32 color2,
|
guint32 color2,
|
||||||
PixopsFilter *filter,
|
PixopsFilter *filter,
|
||||||
PixopsLineFunc line_func,
|
PixopsLineFunc line_func,
|
||||||
PixopsPixelFunc pixel_func)
|
PixopsPixelFunc pixel_func)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
int x, y;
|
int x, y;
|
||||||
art_u8 **line_bufs = g_new (art_u8 *, filter->n_y);
|
guchar **line_bufs = g_new (guchar *, filter->n_y);
|
||||||
|
|
||||||
int x_step = (1 << SCALE_SHIFT) / scale_x;
|
int x_step = (1 << SCALE_SHIFT) / scale_x;
|
||||||
int y_step = (1 << SCALE_SHIFT) / scale_y;
|
int y_step = (1 << SCALE_SHIFT) / scale_y;
|
||||||
@ -942,11 +944,11 @@ pixops_process (art_u8 *dest_buf,
|
|||||||
int y_start = y >> SCALE_SHIFT;
|
int y_start = y >> SCALE_SHIFT;
|
||||||
int x_start;
|
int x_start;
|
||||||
int *run_weights = filter->weights + ((y >> (SCALE_SHIFT - SUBSAMPLE_BITS)) & SUBSAMPLE_MASK) * filter->n_x * filter->n_y * SUBSAMPLE;
|
int *run_weights = filter->weights + ((y >> (SCALE_SHIFT - SUBSAMPLE_BITS)) & SUBSAMPLE_MASK) * filter->n_x * filter->n_y * SUBSAMPLE;
|
||||||
art_u8 *new_outbuf;
|
guchar *new_outbuf;
|
||||||
art_u32 tcolor1, tcolor2;
|
guint32 tcolor1, tcolor2;
|
||||||
|
|
||||||
art_u8 *outbuf = dest_buf + dest_rowstride * i;
|
guchar *outbuf = dest_buf + dest_rowstride * i;
|
||||||
art_u8 *outbuf_end = outbuf + dest_channels * (render_x1 - render_x0);
|
guchar *outbuf_end = outbuf + dest_channels * (render_x1 - render_x0);
|
||||||
|
|
||||||
if (((i + check_y) >> check_shift) & 1)
|
if (((i + check_y) >> check_shift) & 1)
|
||||||
{
|
{
|
||||||
@ -962,11 +964,11 @@ pixops_process (art_u8 *dest_buf,
|
|||||||
for (j=0; j<filter->n_y; j++)
|
for (j=0; j<filter->n_y; j++)
|
||||||
{
|
{
|
||||||
if (y_start < 0)
|
if (y_start < 0)
|
||||||
line_bufs[j] = (art_u8 *)src_buf;
|
line_bufs[j] = (guchar *)src_buf;
|
||||||
else if (y_start < src_height)
|
else if (y_start < src_height)
|
||||||
line_bufs[j] = (art_u8 *)src_buf + src_rowstride * y_start;
|
line_bufs[j] = (guchar *)src_buf + src_rowstride * y_start;
|
||||||
else
|
else
|
||||||
line_bufs[j] = (art_u8 *)src_buf + src_rowstride * (src_height - 1);
|
line_bufs[j] = (guchar *)src_buf + src_rowstride * (src_height - 1);
|
||||||
|
|
||||||
y_start++;
|
y_start++;
|
||||||
}
|
}
|
||||||
@ -1288,35 +1290,35 @@ bilinear_make_weights (PixopsFilter *filter, double x_scale, double y_scale, dou
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pixops_composite_color (art_u8 *dest_buf,
|
pixops_composite_color (guchar *dest_buf,
|
||||||
int render_x0,
|
int render_x0,
|
||||||
int render_y0,
|
int render_y0,
|
||||||
int render_x1,
|
int render_x1,
|
||||||
int render_y1,
|
int render_y1,
|
||||||
int dest_rowstride,
|
int dest_rowstride,
|
||||||
int dest_channels,
|
int dest_channels,
|
||||||
art_boolean dest_has_alpha,
|
gboolean dest_has_alpha,
|
||||||
const art_u8 *src_buf,
|
const guchar *src_buf,
|
||||||
int src_width,
|
int src_width,
|
||||||
int src_height,
|
int src_height,
|
||||||
int src_rowstride,
|
int src_rowstride,
|
||||||
int src_channels,
|
int src_channels,
|
||||||
art_boolean src_has_alpha,
|
gboolean src_has_alpha,
|
||||||
double scale_x,
|
double scale_x,
|
||||||
double scale_y,
|
double scale_y,
|
||||||
ArtFilterLevel filter_level,
|
GdkInterpType interp_type,
|
||||||
int overall_alpha,
|
int overall_alpha,
|
||||||
int check_x,
|
int check_x,
|
||||||
int check_y,
|
int check_y,
|
||||||
int check_size,
|
int check_size,
|
||||||
art_u32 color1,
|
guint32 color1,
|
||||||
art_u32 color2)
|
guint32 color2)
|
||||||
{
|
{
|
||||||
PixopsFilter filter;
|
PixopsFilter filter;
|
||||||
PixopsLineFunc line_func;
|
PixopsLineFunc line_func;
|
||||||
|
|
||||||
#ifdef USE_MMX
|
#ifdef USE_MMX
|
||||||
art_boolean found_mmx = pixops_have_mmx();
|
gboolean found_mmx = pixops_have_mmx();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
g_return_if_fail (!(dest_channels == 3 && dest_has_alpha));
|
g_return_if_fail (!(dest_channels == 3 && dest_has_alpha));
|
||||||
@ -1329,11 +1331,11 @@ pixops_composite_color (art_u8 *dest_buf,
|
|||||||
pixops_scale (dest_buf, render_x0, render_y0, render_x1, render_y1,
|
pixops_scale (dest_buf, render_x0, render_y0, render_x1, render_y1,
|
||||||
dest_rowstride, dest_channels, dest_has_alpha,
|
dest_rowstride, dest_channels, dest_has_alpha,
|
||||||
src_buf, src_width, src_height, src_rowstride, src_channels,
|
src_buf, src_width, src_height, src_rowstride, src_channels,
|
||||||
src_has_alpha, scale_x, scale_y, filter_level);
|
src_has_alpha, scale_x, scale_y, interp_type);
|
||||||
|
|
||||||
switch (filter_level)
|
switch (interp_type)
|
||||||
{
|
{
|
||||||
case ART_FILTER_NEAREST:
|
case GDK_INTERP_NEAREST:
|
||||||
pixops_composite_color_nearest (dest_buf, render_x0, render_y0, render_x1, render_y1,
|
pixops_composite_color_nearest (dest_buf, render_x0, render_y0, render_x1, render_y1,
|
||||||
dest_rowstride, dest_channels, dest_has_alpha,
|
dest_rowstride, dest_channels, dest_has_alpha,
|
||||||
src_buf, src_width, src_height, src_rowstride, src_channels, src_has_alpha,
|
src_buf, src_width, src_height, src_rowstride, src_channels, src_has_alpha,
|
||||||
@ -1341,15 +1343,15 @@ pixops_composite_color (art_u8 *dest_buf,
|
|||||||
check_x, check_y, check_size, color1, color2);
|
check_x, check_y, check_size, color1, color2);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case ART_FILTER_TILES:
|
case GDK_INTERP_TILES:
|
||||||
tile_make_weights (&filter, scale_x, scale_y, overall_alpha / 255.);
|
tile_make_weights (&filter, scale_x, scale_y, overall_alpha / 255.);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ART_FILTER_BILINEAR:
|
case GDK_INTERP_BILINEAR:
|
||||||
bilinear_make_fast_weights (&filter, scale_x, scale_y, overall_alpha / 255.);
|
bilinear_make_fast_weights (&filter, scale_x, scale_y, overall_alpha / 255.);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ART_FILTER_HYPER:
|
case GDK_INTERP_HYPER:
|
||||||
bilinear_make_weights (&filter, scale_x, scale_y, overall_alpha / 255.);
|
bilinear_make_weights (&filter, scale_x, scale_y, overall_alpha / 255.);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1372,30 +1374,30 @@ pixops_composite_color (art_u8 *dest_buf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pixops_composite (art_u8 *dest_buf,
|
pixops_composite (guchar *dest_buf,
|
||||||
int render_x0,
|
int render_x0,
|
||||||
int render_y0,
|
int render_y0,
|
||||||
int render_x1,
|
int render_x1,
|
||||||
int render_y1,
|
int render_y1,
|
||||||
int dest_rowstride,
|
int dest_rowstride,
|
||||||
int dest_channels,
|
int dest_channels,
|
||||||
art_boolean dest_has_alpha,
|
gboolean dest_has_alpha,
|
||||||
const art_u8 *src_buf,
|
const guchar *src_buf,
|
||||||
int src_width,
|
int src_width,
|
||||||
int src_height,
|
int src_height,
|
||||||
int src_rowstride,
|
int src_rowstride,
|
||||||
int src_channels,
|
int src_channels,
|
||||||
art_boolean src_has_alpha,
|
gboolean src_has_alpha,
|
||||||
double scale_x,
|
double scale_x,
|
||||||
double scale_y,
|
double scale_y,
|
||||||
ArtFilterLevel filter_level,
|
GdkInterpType interp_type,
|
||||||
int overall_alpha)
|
int overall_alpha)
|
||||||
{
|
{
|
||||||
PixopsFilter filter;
|
PixopsFilter filter;
|
||||||
PixopsLineFunc line_func;
|
PixopsLineFunc line_func;
|
||||||
|
|
||||||
#ifdef USE_MMX
|
#ifdef USE_MMX
|
||||||
art_boolean found_mmx = pixops_have_mmx();
|
gboolean found_mmx = pixops_have_mmx();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
g_return_if_fail (!(dest_channels == 3 && dest_has_alpha));
|
g_return_if_fail (!(dest_channels == 3 && dest_has_alpha));
|
||||||
@ -1408,26 +1410,26 @@ pixops_composite (art_u8 *dest_buf,
|
|||||||
pixops_scale (dest_buf, render_x0, render_y0, render_x1, render_y1,
|
pixops_scale (dest_buf, render_x0, render_y0, render_x1, render_y1,
|
||||||
dest_rowstride, dest_channels, dest_has_alpha,
|
dest_rowstride, dest_channels, dest_has_alpha,
|
||||||
src_buf, src_width, src_height, src_rowstride, src_channels,
|
src_buf, src_width, src_height, src_rowstride, src_channels,
|
||||||
src_has_alpha, scale_x, scale_y, filter_level);
|
src_has_alpha, scale_x, scale_y, interp_type);
|
||||||
|
|
||||||
switch (filter_level)
|
switch (interp_type)
|
||||||
{
|
{
|
||||||
case ART_FILTER_NEAREST:
|
case GDK_INTERP_NEAREST:
|
||||||
pixops_composite_nearest (dest_buf, render_x0, render_y0, render_x1, render_y1,
|
pixops_composite_nearest (dest_buf, render_x0, render_y0, render_x1, render_y1,
|
||||||
dest_rowstride, dest_channels, dest_has_alpha,
|
dest_rowstride, dest_channels, dest_has_alpha,
|
||||||
src_buf, src_width, src_height, src_rowstride, src_channels,
|
src_buf, src_width, src_height, src_rowstride, src_channels,
|
||||||
src_has_alpha, scale_x, scale_y, overall_alpha);
|
src_has_alpha, scale_x, scale_y, overall_alpha);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case ART_FILTER_TILES:
|
case GDK_INTERP_TILES:
|
||||||
tile_make_weights (&filter, scale_x, scale_y, overall_alpha / 255.);
|
tile_make_weights (&filter, scale_x, scale_y, overall_alpha / 255.);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ART_FILTER_BILINEAR:
|
case GDK_INTERP_BILINEAR:
|
||||||
bilinear_make_fast_weights (&filter, scale_x, scale_y, overall_alpha / 255.);
|
bilinear_make_fast_weights (&filter, scale_x, scale_y, overall_alpha / 255.);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ART_FILTER_HYPER:
|
case GDK_INTERP_HYPER:
|
||||||
bilinear_make_weights (&filter, scale_x, scale_y, overall_alpha / 255.);
|
bilinear_make_weights (&filter, scale_x, scale_y, overall_alpha / 255.);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1455,29 +1457,29 @@ pixops_composite (art_u8 *dest_buf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pixops_scale (art_u8 *dest_buf,
|
pixops_scale (guchar *dest_buf,
|
||||||
int render_x0,
|
int render_x0,
|
||||||
int render_y0,
|
int render_y0,
|
||||||
int render_x1,
|
int render_x1,
|
||||||
int render_y1,
|
int render_y1,
|
||||||
int dest_rowstride,
|
int dest_rowstride,
|
||||||
int dest_channels,
|
int dest_channels,
|
||||||
art_boolean dest_has_alpha,
|
gboolean dest_has_alpha,
|
||||||
const art_u8 *src_buf,
|
const guchar *src_buf,
|
||||||
int src_width,
|
int src_width,
|
||||||
int src_height,
|
int src_height,
|
||||||
int src_rowstride,
|
int src_rowstride,
|
||||||
int src_channels,
|
int src_channels,
|
||||||
art_boolean src_has_alpha,
|
gboolean src_has_alpha,
|
||||||
double scale_x,
|
double scale_x,
|
||||||
double scale_y,
|
double scale_y,
|
||||||
ArtFilterLevel filter_level)
|
GdkInterpType interp_type)
|
||||||
{
|
{
|
||||||
PixopsFilter filter;
|
PixopsFilter filter;
|
||||||
PixopsLineFunc line_func;
|
PixopsLineFunc line_func;
|
||||||
|
|
||||||
#ifdef USE_MMX
|
#ifdef USE_MMX
|
||||||
art_boolean found_mmx = pixops_have_mmx();
|
gboolean found_mmx = pixops_have_mmx();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
g_return_if_fail (!(dest_channels == 3 && dest_has_alpha));
|
g_return_if_fail (!(dest_channels == 3 && dest_has_alpha));
|
||||||
@ -1487,24 +1489,24 @@ pixops_scale (art_u8 *dest_buf,
|
|||||||
if (scale_x == 0 || scale_y == 0)
|
if (scale_x == 0 || scale_y == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch (filter_level)
|
switch (interp_type)
|
||||||
{
|
{
|
||||||
case ART_FILTER_NEAREST:
|
case GDK_INTERP_NEAREST:
|
||||||
pixops_scale_nearest (dest_buf, render_x0, render_y0, render_x1, render_y1,
|
pixops_scale_nearest (dest_buf, render_x0, render_y0, render_x1, render_y1,
|
||||||
dest_rowstride, dest_channels, dest_has_alpha,
|
dest_rowstride, dest_channels, dest_has_alpha,
|
||||||
src_buf, src_width, src_height, src_rowstride, src_channels, src_has_alpha,
|
src_buf, src_width, src_height, src_rowstride, src_channels, src_has_alpha,
|
||||||
scale_x, scale_y);
|
scale_x, scale_y);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case ART_FILTER_TILES:
|
case GDK_INTERP_TILES:
|
||||||
tile_make_weights (&filter, scale_x, scale_y, 1.0);
|
tile_make_weights (&filter, scale_x, scale_y, 1.0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ART_FILTER_BILINEAR:
|
case GDK_INTERP_BILINEAR:
|
||||||
bilinear_make_fast_weights (&filter, scale_x, scale_y, 1.0);
|
bilinear_make_fast_weights (&filter, scale_x, scale_y, 1.0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ART_FILTER_HYPER:
|
case GDK_INTERP_HYPER:
|
||||||
bilinear_make_weights (&filter, scale_x, scale_y, 1.0);
|
bilinear_make_weights (&filter, scale_x, scale_y, 1.0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,17 @@
|
|||||||
#include <libart_lgpl/art_misc.h>
|
#ifndef PIXOPS_H
|
||||||
#include <libart_lgpl/art_filterlevel.h>
|
#define PIXOPS_H
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include "gdk-pixbuf.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Scale src_buf from src_width / src_height by factors scale_x, scale_y
|
/* Scale src_buf from src_width / src_height by factors scale_x, scale_y
|
||||||
* and composite the portion corresponding to
|
* and composite the portion corresponding to
|
||||||
* render_x, render_y, render_width, render_height in the new
|
* render_x, render_y, render_width, render_height in the new
|
||||||
* coordinate system into dest_buf starting at 0, 0
|
* coordinate system into dest_buf starting at 0, 0
|
||||||
*/
|
*/
|
||||||
void pixops_composite (art_u8 *dest_buf,
|
void pixops_composite (guchar *dest_buf,
|
||||||
int render_x0,
|
int render_x0,
|
||||||
int render_y0,
|
int render_y0,
|
||||||
int render_x1,
|
int render_x1,
|
||||||
@ -14,7 +19,7 @@ void pixops_composite (art_u8 *dest_buf,
|
|||||||
int dest_rowstride,
|
int dest_rowstride,
|
||||||
int dest_channels,
|
int dest_channels,
|
||||||
int dest_has_alpha,
|
int dest_has_alpha,
|
||||||
const art_u8 *src_buf,
|
const guchar *src_buf,
|
||||||
int src_width,
|
int src_width,
|
||||||
int src_height,
|
int src_height,
|
||||||
int src_rowstride,
|
int src_rowstride,
|
||||||
@ -22,7 +27,7 @@ void pixops_composite (art_u8 *dest_buf,
|
|||||||
int src_has_alpha,
|
int src_has_alpha,
|
||||||
double scale_x,
|
double scale_x,
|
||||||
double scale_y,
|
double scale_y,
|
||||||
ArtFilterLevel filter_level,
|
GdkInterpType interp_type,
|
||||||
int overall_alpha);
|
int overall_alpha);
|
||||||
|
|
||||||
/* Scale src_buf from src_width / src_height by factors scale_x, scale_y
|
/* Scale src_buf from src_width / src_height by factors scale_x, scale_y
|
||||||
@ -31,7 +36,7 @@ void pixops_composite (art_u8 *dest_buf,
|
|||||||
* coordinate system against a checkboard with checks of size check_size
|
* coordinate system against a checkboard with checks of size check_size
|
||||||
* of the colors color1 and color2 into dest_buf starting at 0, 0
|
* of the colors color1 and color2 into dest_buf starting at 0, 0
|
||||||
*/
|
*/
|
||||||
void pixops_composite_color (art_u8 *dest_buf,
|
void pixops_composite_color (guchar *dest_buf,
|
||||||
int render_x0,
|
int render_x0,
|
||||||
int render_y0,
|
int render_y0,
|
||||||
int render_x1,
|
int render_x1,
|
||||||
@ -39,7 +44,7 @@ void pixops_composite_color (art_u8 *dest_buf,
|
|||||||
int dest_rowstride,
|
int dest_rowstride,
|
||||||
int dest_channels,
|
int dest_channels,
|
||||||
int dest_has_alpha,
|
int dest_has_alpha,
|
||||||
const art_u8 *src_buf,
|
const guchar *src_buf,
|
||||||
int src_width,
|
int src_width,
|
||||||
int src_height,
|
int src_height,
|
||||||
int src_rowstride,
|
int src_rowstride,
|
||||||
@ -47,20 +52,20 @@ void pixops_composite_color (art_u8 *dest_buf,
|
|||||||
int src_has_alpha,
|
int src_has_alpha,
|
||||||
double scale_x,
|
double scale_x,
|
||||||
double scale_y,
|
double scale_y,
|
||||||
ArtFilterLevel filter_level,
|
GdkInterpType interp_type,
|
||||||
int overall_alpha,
|
int overall_alpha,
|
||||||
int check_x,
|
int check_x,
|
||||||
int check_y,
|
int check_y,
|
||||||
int check_size,
|
int check_size,
|
||||||
art_u32 color1,
|
guint32 color1,
|
||||||
art_u32 color2);
|
guint32 color2);
|
||||||
|
|
||||||
/* Scale src_buf from src_width / src_height by factors scale_x, scale_y
|
/* Scale src_buf from src_width / src_height by factors scale_x, scale_y
|
||||||
* and composite the portion corresponding to
|
* and composite the portion corresponding to
|
||||||
* render_x, render_y, render_width, render_height in the new
|
* render_x, render_y, render_width, render_height in the new
|
||||||
* coordinate system into dest_buf starting at 0, 0
|
* coordinate system into dest_buf starting at 0, 0
|
||||||
*/
|
*/
|
||||||
void pixops_scale (art_u8 *dest_buf,
|
void pixops_scale (guchar *dest_buf,
|
||||||
int render_x0,
|
int render_x0,
|
||||||
int render_y0,
|
int render_y0,
|
||||||
int render_x1,
|
int render_x1,
|
||||||
@ -68,7 +73,7 @@ void pixops_scale (art_u8 *dest_buf,
|
|||||||
int dest_rowstride,
|
int dest_rowstride,
|
||||||
int dest_channels,
|
int dest_channels,
|
||||||
int dest_has_alpha,
|
int dest_has_alpha,
|
||||||
const art_u8 *src_buf,
|
const guchar *src_buf,
|
||||||
int src_width,
|
int src_width,
|
||||||
int src_height,
|
int src_height,
|
||||||
int src_rowstride,
|
int src_rowstride,
|
||||||
@ -76,5 +81,8 @@ void pixops_scale (art_u8 *dest_buf,
|
|||||||
int src_has_alpha,
|
int src_has_alpha,
|
||||||
double scale_x,
|
double scale_x,
|
||||||
double scale_y,
|
double scale_y,
|
||||||
ArtFilterLevel filter_level);
|
GdkInterpType interp_type);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@ -76,16 +76,16 @@ dump_array (double times[3][3][4])
|
|||||||
|
|
||||||
switch (j)
|
switch (j)
|
||||||
{
|
{
|
||||||
case ART_FILTER_NEAREST:
|
case GDK_INTERP_NEAREST:
|
||||||
printf (" NEAREST\n");
|
printf (" NEAREST\n");
|
||||||
break;
|
break;
|
||||||
case ART_FILTER_TILES:
|
case GDK_INTERP_TILES:
|
||||||
printf (" TILES\n");
|
printf (" TILES\n");
|
||||||
break;
|
break;
|
||||||
case ART_FILTER_BILINEAR:
|
case GDK_INTERP_BILINEAR:
|
||||||
printf (" BILINEAR\n");
|
printf (" BILINEAR\n");
|
||||||
break;
|
break;
|
||||||
case ART_FILTER_HYPER:
|
case GDK_INTERP_HYPER:
|
||||||
printf (" HYPER\n");
|
printf (" HYPER\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -152,24 +152,24 @@ int main (int argc, char **argv)
|
|||||||
dest_buf = malloc(dest_rowstride * dest_height);
|
dest_buf = malloc(dest_rowstride * dest_height);
|
||||||
memset (dest_buf, 0x80, dest_rowstride * dest_height);
|
memset (dest_buf, 0x80, dest_rowstride * dest_height);
|
||||||
|
|
||||||
for (filter_level = ART_FILTER_NEAREST ; filter_level <= ART_FILTER_HYPER; filter_level++)
|
for (filter_level = GDK_INTERP_NEAREST ; filter_level <= GDK_INTERP_HYPER; filter_level++)
|
||||||
{
|
{
|
||||||
printf ("src_channels = %d (%s); dest_channels = %d (%s); filter_level=",
|
printf ("src_channels = %d (%s); dest_channels = %d (%s); filter_level=",
|
||||||
src_channels, src_has_alpha ? "alpha" : "no alpha",
|
src_channels, src_has_alpha ? "alpha" : "no alpha",
|
||||||
dest_channels, dest_has_alpha ? "alpha" : "no alpha");
|
dest_channels, dest_has_alpha ? "alpha" : "no alpha");
|
||||||
switch (filter_level)
|
switch (filter_level)
|
||||||
{
|
{
|
||||||
case ART_FILTER_NEAREST:
|
case GDK_INTERP_NEAREST:
|
||||||
printf ("ART_FILTER_NEAREST\n");
|
printf ("GDK_INTERP_NEAREST\n");
|
||||||
break;
|
break;
|
||||||
case ART_FILTER_TILES:
|
case GDK_INTERP_TILES:
|
||||||
printf ("ART_FILTER_TILES\n");
|
printf ("GDK_INTERP_TILES\n");
|
||||||
break;
|
break;
|
||||||
case ART_FILTER_BILINEAR:
|
case GDK_INTERP_BILINEAR:
|
||||||
printf ("ART_FILTER_BILINEAR\n");
|
printf ("GDK_INTERP_BILINEAR\n");
|
||||||
break;
|
break;
|
||||||
case ART_FILTER_HYPER:
|
case GDK_INTERP_HYPER:
|
||||||
printf ("ART_FILTER_HYPER\n");
|
printf ("GDK_INTERP_HYPER\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "gdk-pixbuf.h"
|
#include "gdk-pixbuf-private.h"
|
||||||
|
|
||||||
#if (G_BYTE_ORDER == G_LITTLE_ENDIAN)
|
#if (G_BYTE_ORDER == G_LITTLE_ENDIAN)
|
||||||
#define LITTLE
|
#define LITTLE
|
||||||
@ -54,7 +54,7 @@ static guint32 mask_table[] = {
|
|||||||
no alpha
|
no alpha
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
rgb1 (GdkImage *image, art_u8 *pixels, int rowstride, GdkColormap *colormap)
|
rgb1 (GdkImage *image, guchar *pixels, int rowstride, GdkColormap *colormap)
|
||||||
{
|
{
|
||||||
int xx, yy;
|
int xx, yy;
|
||||||
int width, height;
|
int width, height;
|
||||||
@ -93,7 +93,7 @@ rgb1 (GdkImage *image, art_u8 *pixels, int rowstride, GdkColormap *colormap)
|
|||||||
with alpha
|
with alpha
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
rgb1a (GdkImage *image, art_u8 *pixels, int rowstride, GdkColormap *colormap)
|
rgb1a (GdkImage *image, guchar *pixels, int rowstride, GdkColormap *colormap)
|
||||||
{
|
{
|
||||||
int xx, yy;
|
int xx, yy;
|
||||||
int width, height;
|
int width, height;
|
||||||
@ -145,7 +145,7 @@ rgb1a (GdkImage *image, art_u8 *pixels, int rowstride, GdkColormap *colormap)
|
|||||||
no alpha
|
no alpha
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
rgb8 (GdkImage *image, art_u8 *pixels, int rowstride, GdkColormap *colormap)
|
rgb8 (GdkImage *image, guchar *pixels, int rowstride, GdkColormap *colormap)
|
||||||
{
|
{
|
||||||
int xx, yy;
|
int xx, yy;
|
||||||
int width, height;
|
int width, height;
|
||||||
@ -183,7 +183,7 @@ rgb8 (GdkImage *image, art_u8 *pixels, int rowstride, GdkColormap *colormap)
|
|||||||
with alpha
|
with alpha
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
rgb8a (GdkImage *image, art_u8 *pixels, int rowstride, GdkColormap *colormap)
|
rgb8a (GdkImage *image, guchar *pixels, int rowstride, GdkColormap *colormap)
|
||||||
{
|
{
|
||||||
int xx, yy;
|
int xx, yy;
|
||||||
int width, height;
|
int width, height;
|
||||||
@ -235,7 +235,7 @@ rgb8a (GdkImage *image, art_u8 *pixels, int rowstride, GdkColormap *colormap)
|
|||||||
data in lsb format
|
data in lsb format
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
rgb565lsb (GdkImage *image, art_u8 *pixels, int rowstride, GdkColormap *colormap)
|
rgb565lsb (GdkImage *image, guchar *pixels, int rowstride, GdkColormap *colormap)
|
||||||
{
|
{
|
||||||
int xx, yy;
|
int xx, yy;
|
||||||
int width, height;
|
int width, height;
|
||||||
@ -300,7 +300,7 @@ rgb565lsb (GdkImage *image, art_u8 *pixels, int rowstride, GdkColormap *colormap
|
|||||||
data in msb format
|
data in msb format
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
rgb565msb (GdkImage *image, art_u8 *pixels, int rowstride, GdkColormap *colormap)
|
rgb565msb (GdkImage *image, guchar *pixels, int rowstride, GdkColormap *colormap)
|
||||||
{
|
{
|
||||||
int xx, yy;
|
int xx, yy;
|
||||||
int width, height;
|
int width, height;
|
||||||
@ -365,7 +365,7 @@ rgb565msb (GdkImage *image, art_u8 *pixels, int rowstride, GdkColormap *colormap
|
|||||||
data in lsb format
|
data in lsb format
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
rgb565alsb (GdkImage *image, art_u8 *pixels, int rowstride, GdkColormap *colormap)
|
rgb565alsb (GdkImage *image, guchar *pixels, int rowstride, GdkColormap *colormap)
|
||||||
{
|
{
|
||||||
int xx, yy;
|
int xx, yy;
|
||||||
int width, height;
|
int width, height;
|
||||||
@ -418,7 +418,7 @@ rgb565alsb (GdkImage *image, art_u8 *pixels, int rowstride, GdkColormap *colorma
|
|||||||
data in msb format
|
data in msb format
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
rgb565amsb (GdkImage *image, art_u8 *pixels, int rowstride, GdkColormap *colormap)
|
rgb565amsb (GdkImage *image, guchar *pixels, int rowstride, GdkColormap *colormap)
|
||||||
{
|
{
|
||||||
int xx, yy;
|
int xx, yy;
|
||||||
int width, height;
|
int width, height;
|
||||||
@ -467,7 +467,7 @@ rgb565amsb (GdkImage *image, art_u8 *pixels, int rowstride, GdkColormap *colorma
|
|||||||
data in lsb format
|
data in lsb format
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
rgb555lsb (GdkImage *image, art_u8 *pixels, int rowstride, GdkColormap *colormap)
|
rgb555lsb (GdkImage *image, guchar *pixels, int rowstride, GdkColormap *colormap)
|
||||||
{
|
{
|
||||||
int xx, yy;
|
int xx, yy;
|
||||||
int width, height;
|
int width, height;
|
||||||
@ -532,7 +532,7 @@ rgb555lsb (GdkImage *image, art_u8 *pixels, int rowstride, GdkColormap *colormap
|
|||||||
data in msb format
|
data in msb format
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
rgb555msb (GdkImage *image, art_u8 *pixels, int rowstride, GdkColormap *colormap)
|
rgb555msb (GdkImage *image, guchar *pixels, int rowstride, GdkColormap *colormap)
|
||||||
{
|
{
|
||||||
int xx, yy;
|
int xx, yy;
|
||||||
int width, height;
|
int width, height;
|
||||||
@ -593,7 +593,7 @@ rgb555msb (GdkImage *image, art_u8 *pixels, int rowstride, GdkColormap *colormap
|
|||||||
data in lsb format
|
data in lsb format
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
rgb555alsb (GdkImage *image, art_u8 *pixels, int rowstride, GdkColormap *colormap)
|
rgb555alsb (GdkImage *image, guchar *pixels, int rowstride, GdkColormap *colormap)
|
||||||
{
|
{
|
||||||
int xx, yy;
|
int xx, yy;
|
||||||
int width, height;
|
int width, height;
|
||||||
@ -646,7 +646,7 @@ rgb555alsb (GdkImage *image, art_u8 *pixels, int rowstride, GdkColormap *colorma
|
|||||||
data in msb format
|
data in msb format
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
rgb555amsb (GdkImage *image, art_u8 *pixels, int rowstride, GdkColormap *colormap)
|
rgb555amsb (GdkImage *image, guchar *pixels, int rowstride, GdkColormap *colormap)
|
||||||
{
|
{
|
||||||
int xx, yy;
|
int xx, yy;
|
||||||
int width, height;
|
int width, height;
|
||||||
@ -695,7 +695,7 @@ rgb555amsb (GdkImage *image, art_u8 *pixels, int rowstride, GdkColormap *colorma
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rgb888alsb (GdkImage *image, art_u8 *pixels, int rowstride, GdkColormap *colormap)
|
rgb888alsb (GdkImage *image, guchar *pixels, int rowstride, GdkColormap *colormap)
|
||||||
{
|
{
|
||||||
int xx, yy;
|
int xx, yy;
|
||||||
int width, height;
|
int width, height;
|
||||||
@ -728,7 +728,7 @@ rgb888alsb (GdkImage *image, art_u8 *pixels, int rowstride, GdkColormap *colorma
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rgb888lsb (GdkImage *image, art_u8 *pixels, int rowstride, GdkColormap *colormap)
|
rgb888lsb (GdkImage *image, guchar *pixels, int rowstride, GdkColormap *colormap)
|
||||||
{
|
{
|
||||||
int xx, yy;
|
int xx, yy;
|
||||||
int width, height;
|
int width, height;
|
||||||
@ -758,7 +758,7 @@ rgb888lsb (GdkImage *image, art_u8 *pixels, int rowstride, GdkColormap *colormap
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rgb888amsb (GdkImage *image, art_u8 *pixels, int rowstride, GdkColormap *colormap)
|
rgb888amsb (GdkImage *image, guchar *pixels, int rowstride, GdkColormap *colormap)
|
||||||
{
|
{
|
||||||
int xx, yy;
|
int xx, yy;
|
||||||
int width, height;
|
int width, height;
|
||||||
@ -806,7 +806,7 @@ rgb888amsb (GdkImage *image, art_u8 *pixels, int rowstride, GdkColormap *colorma
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rgb888msb (GdkImage *image, art_u8 *pixels, int rowstride, GdkColormap *colormap)
|
rgb888msb (GdkImage *image, guchar *pixels, int rowstride, GdkColormap *colormap)
|
||||||
{
|
{
|
||||||
int xx, yy;
|
int xx, yy;
|
||||||
int width, height;
|
int width, height;
|
||||||
@ -841,7 +841,7 @@ rgb888msb (GdkImage *image, art_u8 *pixels, int rowstride, GdkColormap *colormap
|
|||||||
run quite slow
|
run quite slow
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
convert_real_slow (GdkImage *image, art_u8 *pixels, int rowstride, GdkColormap *cmap, int alpha)
|
convert_real_slow (GdkImage *image, guchar *pixels, int rowstride, GdkColormap *cmap, int alpha)
|
||||||
{
|
{
|
||||||
int xx, yy;
|
int xx, yy;
|
||||||
int width, height;
|
int width, height;
|
||||||
@ -899,7 +899,7 @@ convert_real_slow (GdkImage *image, art_u8 *pixels, int rowstride, GdkColormap *
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef void (* cfunc) (GdkImage *image, art_u8 *pixels, int rowstride, GdkColormap *cmap);
|
typedef void (* cfunc) (GdkImage *image, guchar *pixels, int rowstride, GdkColormap *cmap);
|
||||||
|
|
||||||
static cfunc convert_map[] = {
|
static cfunc convert_map[] = {
|
||||||
rgb1,rgb1,rgb1a,rgb1a,
|
rgb1,rgb1,rgb1a,rgb1a,
|
||||||
@ -917,7 +917,7 @@ static cfunc convert_map[] = {
|
|||||||
conversion function.
|
conversion function.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
rgbconvert (GdkImage *image, art_u8 *pixels, int rowstride, int alpha, GdkColormap *cmap)
|
rgbconvert (GdkImage *image, guchar *pixels, int rowstride, int alpha, GdkColormap *cmap)
|
||||||
{
|
{
|
||||||
int index = (image->byte_order == GDK_MSB_FIRST) | (alpha != 0) << 1;
|
int index = (image->byte_order == GDK_MSB_FIRST) | (alpha != 0) << 1;
|
||||||
int bank=5; /* default fallback converter */
|
int bank=5; /* default fallback converter */
|
||||||
@ -1020,7 +1020,9 @@ rgbconvert (GdkImage *image, art_u8 *pixels, int rowstride, int alpha, GdkColorm
|
|||||||
* be undefined.
|
* be undefined.
|
||||||
*
|
*
|
||||||
* Return value: The same pixbuf as @dest if it was non-NULL, or a newly-created
|
* Return value: The same pixbuf as @dest if it was non-NULL, or a newly-created
|
||||||
* pixbuf with a reference count of 1 if no destination pixbuf was specified.
|
* pixbuf with a reference count of 1 if no destination pixbuf was specified; in
|
||||||
|
* the latter case, NULL will be returned if not enough memory could be
|
||||||
|
* allocated for the pixbuf to be created.
|
||||||
**/
|
**/
|
||||||
GdkPixbuf *
|
GdkPixbuf *
|
||||||
gdk_pixbuf_get_from_drawable (GdkPixbuf *dest,
|
gdk_pixbuf_get_from_drawable (GdkPixbuf *dest,
|
||||||
@ -1031,7 +1033,6 @@ gdk_pixbuf_get_from_drawable (GdkPixbuf *dest,
|
|||||||
{
|
{
|
||||||
GdkWindowType window_type;
|
GdkWindowType window_type;
|
||||||
int src_width, src_height;
|
int src_width, src_height;
|
||||||
ArtPixBuf *apb = NULL;
|
|
||||||
GdkImage *image;
|
GdkImage *image;
|
||||||
int rowstride, bpp, alpha;
|
int rowstride, bpp, alpha;
|
||||||
|
|
||||||
@ -1054,11 +1055,9 @@ gdk_pixbuf_get_from_drawable (GdkPixbuf *dest,
|
|||||||
if (!dest)
|
if (!dest)
|
||||||
g_return_val_if_fail (dest_x == 0 && dest_y == 0, NULL);
|
g_return_val_if_fail (dest_x == 0 && dest_y == 0, NULL);
|
||||||
else {
|
else {
|
||||||
apb = dest->art_pixbuf;
|
g_return_val_if_fail (dest->colorspace == GDK_COLORSPACE_RGB, NULL);
|
||||||
|
g_return_val_if_fail (dest->n_channels == 3 || dest->n_channels == 4, NULL);
|
||||||
g_return_val_if_fail (apb->format == ART_PIX_RGB, NULL);
|
g_return_val_if_fail (dest->bits_per_sample == 8, NULL);
|
||||||
g_return_val_if_fail (apb->n_channels == 3 || apb->n_channels == 4, NULL);
|
|
||||||
g_return_val_if_fail (apb->bits_per_sample == 8, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Coordinate sanity checks */
|
/* Coordinate sanity checks */
|
||||||
@ -1070,8 +1069,8 @@ gdk_pixbuf_get_from_drawable (GdkPixbuf *dest,
|
|||||||
|
|
||||||
if (dest) {
|
if (dest) {
|
||||||
g_return_val_if_fail (dest_x >= 0 && dest_y >= 0, NULL);
|
g_return_val_if_fail (dest_x >= 0 && dest_y >= 0, NULL);
|
||||||
g_return_val_if_fail (dest_x + width <= apb->width, NULL);
|
g_return_val_if_fail (dest_x + width <= dest->width, NULL);
|
||||||
g_return_val_if_fail (dest_y + height <= apb->height, NULL);
|
g_return_val_if_fail (dest_y + height <= dest->height, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window_type != GDK_WINDOW_PIXMAP) {
|
if (window_type != GDK_WINDOW_PIXMAP) {
|
||||||
@ -1096,33 +1095,31 @@ gdk_pixbuf_get_from_drawable (GdkPixbuf *dest,
|
|||||||
|
|
||||||
/* Get Image in ZPixmap format (packed bits). */
|
/* Get Image in ZPixmap format (packed bits). */
|
||||||
image = gdk_image_get (src, src_x, src_y, width, height);
|
image = gdk_image_get (src, src_x, src_y, width, height);
|
||||||
g_return_val_if_fail( image != NULL, NULL);
|
g_return_val_if_fail (image != NULL, NULL);
|
||||||
|
|
||||||
/* Create the pixbuf if needed */
|
/* Create the pixbuf if needed */
|
||||||
if (!dest) {
|
if (!dest) {
|
||||||
dest = gdk_pixbuf_new (ART_PIX_RGB, FALSE, 8, width, height);
|
dest = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, width, height);
|
||||||
if (!dest) {
|
if (!dest) {
|
||||||
gdk_image_destroy(image);
|
gdk_image_destroy(image);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
apb = dest->art_pixbuf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the colormap if needed */
|
/* Get the colormap if needed */
|
||||||
if (window_type != GDK_WINDOW_PIXMAP)
|
if (window_type != GDK_WINDOW_PIXMAP)
|
||||||
cmap = gdk_window_get_colormap (src);
|
cmap = gdk_window_get_colormap (src);
|
||||||
|
|
||||||
alpha = gdk_pixbuf_get_has_alpha(dest);
|
alpha = dest->has_alpha;
|
||||||
rowstride = gdk_pixbuf_get_rowstride(dest);
|
rowstride = dest->rowstride;
|
||||||
bpp = alpha?4:3;
|
bpp = alpha ? 4 : 3;
|
||||||
|
|
||||||
/* we offset into the image data based on the position we are retrieving from */
|
/* we offset into the image data based on the position we are retrieving from */
|
||||||
rgbconvert(image, gdk_pixbuf_get_pixels(dest) +
|
rgbconvert (image, dest->pixels +
|
||||||
(dest_y * rowstride) + (dest_x * bpp),
|
(dest_y * rowstride) + (dest_x * bpp),
|
||||||
rowstride,
|
rowstride,
|
||||||
alpha,
|
alpha,
|
||||||
cmap);
|
cmap);
|
||||||
|
|
||||||
gdk_image_destroy(image);
|
gdk_image_destroy(image);
|
||||||
|
|
||||||
|
@ -22,8 +22,7 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <gdk/gdk.h>
|
#include <gdk/gdk.h>
|
||||||
#include <libart_lgpl/art_rect.h>
|
#include "gdk-pixbuf-private.h"
|
||||||
#include "gdk-pixbuf.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -52,7 +51,6 @@ gdk_pixbuf_render_threshold_alpha (GdkPixbuf *pixbuf, GdkBitmap *bitmap,
|
|||||||
int width, int height,
|
int width, int height,
|
||||||
int alpha_threshold)
|
int alpha_threshold)
|
||||||
{
|
{
|
||||||
ArtPixBuf *apb;
|
|
||||||
GdkGC *gc;
|
GdkGC *gc;
|
||||||
GdkColor color;
|
GdkColor color;
|
||||||
int x, y;
|
int x, y;
|
||||||
@ -61,16 +59,14 @@ gdk_pixbuf_render_threshold_alpha (GdkPixbuf *pixbuf, GdkBitmap *bitmap,
|
|||||||
int status;
|
int status;
|
||||||
|
|
||||||
g_return_if_fail (pixbuf != NULL);
|
g_return_if_fail (pixbuf != NULL);
|
||||||
apb = pixbuf->art_pixbuf;
|
g_return_if_fail (pixbuf->colorspace == GDK_COLORSPACE_RGB);
|
||||||
|
g_return_if_fail (pixbuf->n_channels == 3 || pixbuf->n_channels == 4);
|
||||||
g_return_if_fail (apb->format == ART_PIX_RGB);
|
g_return_if_fail (pixbuf->bits_per_sample == 8);
|
||||||
g_return_if_fail (apb->n_channels == 3 || apb->n_channels == 4);
|
|
||||||
g_return_if_fail (apb->bits_per_sample == 8);
|
|
||||||
|
|
||||||
g_return_if_fail (bitmap != NULL);
|
g_return_if_fail (bitmap != NULL);
|
||||||
g_return_if_fail (width >= 0 && height >= 0);
|
g_return_if_fail (width >= 0 && height >= 0);
|
||||||
g_return_if_fail (src_x >= 0 && src_x + width <= apb->width);
|
g_return_if_fail (src_x >= 0 && src_x + width <= pixbuf->width);
|
||||||
g_return_if_fail (src_y >= 0 && src_y + height <= apb->height);
|
g_return_if_fail (src_y >= 0 && src_y + height <= pixbuf->height);
|
||||||
|
|
||||||
g_return_if_fail (alpha_threshold >= 0 && alpha_threshold <= 255);
|
g_return_if_fail (alpha_threshold >= 0 && alpha_threshold <= 255);
|
||||||
|
|
||||||
@ -79,7 +75,7 @@ gdk_pixbuf_render_threshold_alpha (GdkPixbuf *pixbuf, GdkBitmap *bitmap,
|
|||||||
|
|
||||||
gc = gdk_gc_new (bitmap);
|
gc = gdk_gc_new (bitmap);
|
||||||
|
|
||||||
if (!apb->has_alpha) {
|
if (!pixbuf->has_alpha) {
|
||||||
color.pixel = (alpha_threshold == 255) ? 0 : 1;
|
color.pixel = (alpha_threshold == 255) ? 0 : 1;
|
||||||
gdk_gc_set_foreground (gc, &color);
|
gdk_gc_set_foreground (gc, &color);
|
||||||
gdk_draw_rectangle (bitmap, gc, TRUE, dest_x, dest_y, width, height);
|
gdk_draw_rectangle (bitmap, gc, TRUE, dest_x, dest_y, width, height);
|
||||||
@ -95,8 +91,8 @@ gdk_pixbuf_render_threshold_alpha (GdkPixbuf *pixbuf, GdkBitmap *bitmap,
|
|||||||
gdk_gc_set_foreground (gc, &color);
|
gdk_gc_set_foreground (gc, &color);
|
||||||
|
|
||||||
for (y = 0; y < height; y++) {
|
for (y = 0; y < height; y++) {
|
||||||
p = (apb->pixels + (y + src_y) * apb->rowstride + src_x * apb->n_channels
|
p = (pixbuf->pixels + (y + src_y) * pixbuf->rowstride + src_x * pixbuf->n_channels
|
||||||
+ apb->n_channels - 1);
|
+ pixbuf->n_channels - 1);
|
||||||
|
|
||||||
start = 0;
|
start = 0;
|
||||||
start_status = *p < alpha_threshold;
|
start_status = *p < alpha_threshold;
|
||||||
@ -114,7 +110,7 @@ gdk_pixbuf_render_threshold_alpha (GdkPixbuf *pixbuf, GdkBitmap *bitmap,
|
|||||||
start_status = status;
|
start_status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
p += apb->n_channels;
|
p += pixbuf->n_channels;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!start_status)
|
if (!start_status)
|
||||||
@ -130,24 +126,24 @@ gdk_pixbuf_render_threshold_alpha (GdkPixbuf *pixbuf, GdkBitmap *bitmap,
|
|||||||
|
|
||||||
/* Creates a buffer by stripping the alpha channel of a pixbuf */
|
/* Creates a buffer by stripping the alpha channel of a pixbuf */
|
||||||
static guchar *
|
static guchar *
|
||||||
remove_alpha (ArtPixBuf *apb, int x, int y, int width, int height, int *rowstride)
|
remove_alpha (GdkPixbuf *pixbuf, int x, int y, int width, int height, int *rowstride)
|
||||||
{
|
{
|
||||||
guchar *buf;
|
guchar *buf;
|
||||||
int xx, yy;
|
int xx, yy;
|
||||||
guchar *src, *dest;
|
guchar *src, *dest;
|
||||||
|
|
||||||
g_assert (apb->n_channels == 4);
|
g_assert (pixbuf->n_channels == 4);
|
||||||
g_assert (apb->has_alpha);
|
g_assert (pixbuf->has_alpha);
|
||||||
g_assert (width > 0 && height > 0);
|
g_assert (width > 0 && height > 0);
|
||||||
g_assert (x >= 0 && x + width <= apb->width);
|
g_assert (x >= 0 && x + width <= pixbuf->width);
|
||||||
g_assert (y >= 0 && y + height <= apb->height);
|
g_assert (y >= 0 && y + height <= pixbuf->height);
|
||||||
|
|
||||||
*rowstride = 4 * ((width * 3 + 3) / 4);
|
*rowstride = 4 * ((width * 3 + 3) / 4);
|
||||||
|
|
||||||
buf = g_new (guchar, *rowstride * height);
|
buf = g_new (guchar, *rowstride * height);
|
||||||
|
|
||||||
for (yy = 0; yy < height; yy++) {
|
for (yy = 0; yy < height; yy++) {
|
||||||
src = apb->pixels + apb->rowstride * (yy + y) + x * apb->n_channels;
|
src = pixbuf->pixels + pixbuf->rowstride * (yy + y) + x * pixbuf->n_channels;
|
||||||
dest = buf + *rowstride * yy;
|
dest = buf + *rowstride * yy;
|
||||||
|
|
||||||
for (xx = 0; xx < width; xx++) {
|
for (xx = 0; xx < width; xx++) {
|
||||||
@ -198,37 +194,34 @@ gdk_pixbuf_render_to_drawable (GdkPixbuf *pixbuf,
|
|||||||
GdkRgbDither dither,
|
GdkRgbDither dither,
|
||||||
int x_dither, int y_dither)
|
int x_dither, int y_dither)
|
||||||
{
|
{
|
||||||
ArtPixBuf *apb;
|
|
||||||
guchar *buf;
|
guchar *buf;
|
||||||
int rowstride;
|
int rowstride;
|
||||||
|
|
||||||
g_return_if_fail (pixbuf != NULL);
|
g_return_if_fail (pixbuf != NULL);
|
||||||
apb = pixbuf->art_pixbuf;
|
g_return_if_fail (pixbuf->colorspace == GDK_COLORSPACE_RGB);
|
||||||
|
g_return_if_fail (pixbuf->n_channels == 3 || pixbuf->n_channels == 4);
|
||||||
g_return_if_fail (apb->format == ART_PIX_RGB);
|
g_return_if_fail (pixbuf->bits_per_sample == 8);
|
||||||
g_return_if_fail (apb->n_channels == 3 || apb->n_channels == 4);
|
|
||||||
g_return_if_fail (apb->bits_per_sample == 8);
|
|
||||||
|
|
||||||
g_return_if_fail (drawable != NULL);
|
g_return_if_fail (drawable != NULL);
|
||||||
g_return_if_fail (gc != NULL);
|
g_return_if_fail (gc != NULL);
|
||||||
|
|
||||||
g_return_if_fail (width >= 0 && height >= 0);
|
g_return_if_fail (width >= 0 && height >= 0);
|
||||||
g_return_if_fail (src_x >= 0 && src_x + width <= apb->width);
|
g_return_if_fail (src_x >= 0 && src_x + width <= pixbuf->width);
|
||||||
g_return_if_fail (src_y >= 0 && src_y + height <= apb->height);
|
g_return_if_fail (src_y >= 0 && src_y + height <= pixbuf->height);
|
||||||
|
|
||||||
if (width == 0 || height == 0)
|
if (width == 0 || height == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* This will have to be modified once libart supports other image types.
|
/* This will have to be modified once we support other image types.
|
||||||
* Also, GdkRGB does not have gdk_draw_rgb_32_image_dithalign(), so we
|
* Also, GdkRGB does not have gdk_draw_rgb_32_image_dithalign(), so we
|
||||||
* have to pack the buffer first.
|
* have to pack the buffer first. Sigh.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (apb->has_alpha)
|
if (pixbuf->has_alpha)
|
||||||
buf = remove_alpha (apb, src_x, src_y, width, height, &rowstride);
|
buf = remove_alpha (pixbuf, src_x, src_y, width, height, &rowstride);
|
||||||
else {
|
else {
|
||||||
buf = apb->pixels + src_y * apb->rowstride + src_x * 3;
|
buf = pixbuf->pixels + src_y * pixbuf->rowstride + src_x * 3;
|
||||||
rowstride = apb->rowstride;
|
rowstride = pixbuf->rowstride;
|
||||||
}
|
}
|
||||||
|
|
||||||
gdk_draw_rgb_image_dithalign (drawable, gc,
|
gdk_draw_rgb_image_dithalign (drawable, gc,
|
||||||
@ -238,7 +231,7 @@ gdk_pixbuf_render_to_drawable (GdkPixbuf *pixbuf,
|
|||||||
buf, rowstride,
|
buf, rowstride,
|
||||||
x_dither, y_dither);
|
x_dither, y_dither);
|
||||||
|
|
||||||
if (apb->has_alpha)
|
if (pixbuf->has_alpha)
|
||||||
g_free (buf);
|
g_free (buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,28 +277,25 @@ gdk_pixbuf_render_to_drawable_alpha (GdkPixbuf *pixbuf, GdkDrawable *drawable,
|
|||||||
GdkRgbDither dither,
|
GdkRgbDither dither,
|
||||||
int x_dither, int y_dither)
|
int x_dither, int y_dither)
|
||||||
{
|
{
|
||||||
ArtPixBuf *apb;
|
|
||||||
GdkBitmap *bitmap = NULL;
|
GdkBitmap *bitmap = NULL;
|
||||||
GdkGC *gc;
|
GdkGC *gc;
|
||||||
|
|
||||||
g_return_if_fail (pixbuf != NULL);
|
g_return_if_fail (pixbuf != NULL);
|
||||||
apb = pixbuf->art_pixbuf;
|
g_return_if_fail (pixbuf->colorspace == GDK_COLORSPACE_RGB);
|
||||||
|
g_return_if_fail (pixbuf->n_channels == 3 || pixbuf->n_channels == 4);
|
||||||
g_return_if_fail (apb->format == ART_PIX_RGB);
|
g_return_if_fail (pixbuf->bits_per_sample == 8);
|
||||||
g_return_if_fail (apb->n_channels == 3 || apb->n_channels == 4);
|
|
||||||
g_return_if_fail (apb->bits_per_sample == 8);
|
|
||||||
|
|
||||||
g_return_if_fail (drawable != NULL);
|
g_return_if_fail (drawable != NULL);
|
||||||
g_return_if_fail (width >= 0 && height >= 0);
|
g_return_if_fail (width >= 0 && height >= 0);
|
||||||
g_return_if_fail (src_x >= 0 && src_x + width <= apb->width);
|
g_return_if_fail (src_x >= 0 && src_x + width <= pixbuf->width);
|
||||||
g_return_if_fail (src_y >= 0 && src_y + height <= apb->height);
|
g_return_if_fail (src_y >= 0 && src_y + height <= pixbuf->height);
|
||||||
|
|
||||||
if (width == 0 || height == 0)
|
if (width == 0 || height == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gc = gdk_gc_new (drawable);
|
gc = gdk_gc_new (drawable);
|
||||||
|
|
||||||
if (apb->has_alpha) {
|
if (pixbuf->has_alpha) {
|
||||||
/* Right now we only support GDK_PIXBUF_ALPHA_BILEVEL, so we
|
/* Right now we only support GDK_PIXBUF_ALPHA_BILEVEL, so we
|
||||||
* unconditionally create the clipping mask.
|
* unconditionally create the clipping mask.
|
||||||
*/
|
*/
|
||||||
@ -330,12 +320,13 @@ gdk_pixbuf_render_to_drawable_alpha (GdkPixbuf *pixbuf, GdkDrawable *drawable,
|
|||||||
|
|
||||||
if (bitmap)
|
if (bitmap)
|
||||||
gdk_bitmap_unref (bitmap);
|
gdk_bitmap_unref (bitmap);
|
||||||
|
|
||||||
gdk_gc_unref (gc);
|
gdk_gc_unref (gc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gdk_pixbuf_render_pixmap_and_mask:
|
* gdk_pixbuf_render_pixmap_and_mask:
|
||||||
* @pixbuf: A pixbuf
|
* @pixbuf: A pixbuf.
|
||||||
* @pixmap_return: Return value for the created pixmap.
|
* @pixmap_return: Return value for the created pixmap.
|
||||||
* @mask_return: Return value for the created mask.
|
* @mask_return: Return value for the created mask.
|
||||||
* @alpha_threshold: Threshold value for opacity values.
|
* @alpha_threshold: Threshold value for opacity values.
|
||||||
@ -346,37 +337,39 @@ gdk_pixbuf_render_to_drawable_alpha (GdkPixbuf *pixbuf, GdkDrawable *drawable,
|
|||||||
* function; applications that need to render pixbufs with dither offsets or to
|
* function; applications that need to render pixbufs with dither offsets or to
|
||||||
* given drawables should use gdk_pixbuf_render_to_drawable_alpha() or
|
* given drawables should use gdk_pixbuf_render_to_drawable_alpha() or
|
||||||
* gdk_pixbuf_render_to_drawable(), and gdk_pixbuf_render_threshold_alpha().
|
* gdk_pixbuf_render_to_drawable(), and gdk_pixbuf_render_threshold_alpha().
|
||||||
|
*
|
||||||
|
* If the pixbuf does not have an alpha channel, then *@mask_return will be set
|
||||||
|
* to NULL.
|
||||||
**/
|
**/
|
||||||
void
|
void
|
||||||
gdk_pixbuf_render_pixmap_and_mask (GdkPixbuf *pixbuf,
|
gdk_pixbuf_render_pixmap_and_mask (GdkPixbuf *pixbuf,
|
||||||
GdkPixmap **pixmap_return, GdkBitmap **mask_return,
|
GdkPixmap **pixmap_return, GdkBitmap **mask_return,
|
||||||
int alpha_threshold)
|
int alpha_threshold)
|
||||||
{
|
{
|
||||||
ArtPixBuf *apb;
|
|
||||||
|
|
||||||
g_return_if_fail (pixbuf != NULL);
|
g_return_if_fail (pixbuf != NULL);
|
||||||
|
|
||||||
apb = pixbuf->art_pixbuf;
|
|
||||||
|
|
||||||
if (pixmap_return) {
|
if (pixmap_return) {
|
||||||
GdkGC *gc;
|
GdkGC *gc;
|
||||||
|
|
||||||
*pixmap_return = gdk_pixmap_new (NULL, apb->width, apb->height,
|
*pixmap_return = gdk_pixmap_new (NULL, pixbuf->width, pixbuf->height,
|
||||||
gdk_rgb_get_visual ()->depth);
|
gdk_rgb_get_visual ()->depth);
|
||||||
gc = gdk_gc_new (*pixmap_return);
|
gc = gdk_gc_new (*pixmap_return);
|
||||||
gdk_pixbuf_render_to_drawable (pixbuf, *pixmap_return, gc,
|
gdk_pixbuf_render_to_drawable (pixbuf, *pixmap_return, gc,
|
||||||
0, 0, 0, 0,
|
0, 0, 0, 0,
|
||||||
apb->width, apb->height,
|
pixbuf->width, pixbuf->height,
|
||||||
GDK_RGB_DITHER_NORMAL,
|
GDK_RGB_DITHER_NORMAL,
|
||||||
0, 0);
|
0, 0);
|
||||||
gdk_gc_unref (gc);
|
gdk_gc_unref (gc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mask_return) {
|
if (mask_return) {
|
||||||
*mask_return = gdk_pixmap_new (NULL, apb->width, apb->height, 1);
|
if (pixbuf->has_alpha) {
|
||||||
gdk_pixbuf_render_threshold_alpha (pixbuf, *mask_return,
|
*mask_return = gdk_pixmap_new (NULL, pixbuf->width, pixbuf->height, 1);
|
||||||
0, 0, 0, 0,
|
gdk_pixbuf_render_threshold_alpha (pixbuf, *mask_return,
|
||||||
apb->width, apb->height,
|
0, 0, 0, 0,
|
||||||
alpha_threshold);
|
pixbuf->width, pixbuf->height,
|
||||||
|
alpha_threshold);
|
||||||
|
} else
|
||||||
|
*mask_return = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <gtk/gtksignal.h>
|
#include <gtk/gtksignal.h>
|
||||||
|
#include "gdk-pixbuf-private.h"
|
||||||
#include "gdk-pixbuf-loader.h"
|
#include "gdk-pixbuf-loader.h"
|
||||||
#include "gdk-pixbuf-io.h"
|
#include "gdk-pixbuf-io.h"
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user