mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-06 00:30:08 +00:00
Ok minor changes.
Ok minor changes. No longer make a version.h, and cleaned up some code here and there, and added a quickie dirty-hack rotation function. However, it rotates at the origin. Is this what we want? Or do we want a rotate w.r.t. the center of the pixbuf? Anyone. Mark
This commit is contained in:
parent
e9ed2c18a7
commit
6423183a63
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
/* GTK - The GIMP Toolkit
|
/* testpixbuf -- test program for gdk-pixbuf code
|
||||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
* Copyright (C) 1999 Mark Crichton, Larry Ewing
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@ -18,18 +18,6 @@
|
|||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
* Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
|
|
||||||
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
||||||
* files for a list of changes. These files are distributed with
|
|
||||||
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/* Note: these #includes differ slightly from the testrgb.c file included
|
|
||||||
in the GdkRgb release. */
|
|
||||||
|
|
||||||
/* For gettimeofday */
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -161,6 +149,7 @@ main (int argc, char **argv)
|
|||||||
for (i = 1; i < argc; i++)
|
for (i = 1; i < argc; i++)
|
||||||
{
|
{
|
||||||
pixbuf = gdk_pixbuf_load_image (argv[i]);
|
pixbuf = gdk_pixbuf_load_image (argv[i]);
|
||||||
|
pixbuf = gdk_pixbuf_rotate(pixbuf, 42.0);
|
||||||
|
|
||||||
if (pixbuf)
|
if (pixbuf)
|
||||||
{
|
{
|
||||||
|
@ -1,3 +1,19 @@
|
|||||||
|
1999-07-18 Mark Crichton <crichton@gimp.org>
|
||||||
|
|
||||||
|
* configure.in: removed version.h.
|
||||||
|
|
||||||
|
* src/gdk-pixbuf-io.c (pixbuf_check_tiff): Minor readability
|
||||||
|
improvements.
|
||||||
|
|
||||||
|
1999-07-17 Mark Crichton <crichton@gimp.org>
|
||||||
|
|
||||||
|
* src/gdk-pixbuf.c: Removed gdk_pixbuf_free, redundant code.
|
||||||
|
(gdk_pixbuf_rotate): Added pixbuf rotation code.
|
||||||
|
(gdk_pixbuf_scale): Changed // comments to /* */
|
||||||
|
|
||||||
|
* src/gdk-pixbuf.h (gdk_pixbuf_destroy): Added gdk_pixbuf_destroy
|
||||||
|
function to header.
|
||||||
|
|
||||||
1999-07-16 Larry Ewing <lewing@gimp.org>
|
1999-07-16 Larry Ewing <lewing@gimp.org>
|
||||||
|
|
||||||
* src/testpixbuf.c (expose_func): reverted the expose everything
|
* src/testpixbuf.c (expose_func): reverted the expose everything
|
||||||
|
@ -47,10 +47,16 @@ pixbuf_check_tiff (unsigned char *buffer, int size)
|
|||||||
if (size < 10)
|
if (size < 10)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (buffer [0] == 'M' && buffer [1] == 'M' && buffer [2] == 0 && buffer [3] == 0x2a)
|
if (buffer [0] == 'M' &&
|
||||||
|
buffer [1] == 'M' &&
|
||||||
|
buffer [2] == 0 &&
|
||||||
|
buffer [3] == 0x2a)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
if (buffer [0] == 'I' && buffer [1] == 'I' && buffer [2] == 0x2a && buffer [3] == 0)
|
if (buffer [0] == 'I' &&
|
||||||
|
buffer [1] == 'I' &&
|
||||||
|
buffer [2] == 0x2a &&
|
||||||
|
buffer [3] == 0)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -139,11 +145,13 @@ image_file_format (const char *file)
|
|||||||
static void
|
static void
|
||||||
image_handler_load (int idx)
|
image_handler_load (int idx)
|
||||||
{
|
{
|
||||||
char *module_name = g_strconcat ("pixbuf-", file_formats [idx].module_name, NULL);
|
char *module_name;
|
||||||
char *path;
|
char *path;
|
||||||
GModule *module;
|
GModule *module;
|
||||||
void *load_sym, *save_sym;
|
void *load_sym, *save_sym;
|
||||||
|
|
||||||
|
module_name = g_strconcat ("pixbuf-",
|
||||||
|
file_formats [idx].module_name, NULL);
|
||||||
path = g_module_build_path (PIXBUF_LIBDIR, module_name);
|
path = g_module_build_path (PIXBUF_LIBDIR, module_name);
|
||||||
g_free (module_name);
|
g_free (module_name);
|
||||||
|
|
||||||
|
@ -6,25 +6,26 @@
|
|||||||
*/
|
*/
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
#include <math.h>
|
||||||
#include <libart_lgpl/art_misc.h>
|
#include <libart_lgpl/art_misc.h>
|
||||||
#include <libart_lgpl/art_rgb_affine.h>
|
#include <libart_lgpl/art_rgb_affine.h>
|
||||||
#include <libart_lgpl/art_alphagamma.h>
|
#include <libart_lgpl/art_alphagamma.h>
|
||||||
#include "gdk-pixbuf.h"
|
#include "gdk-pixbuf.h"
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
gdk_pixbuf_destroy (GdkPixBuf *pixbuf)
|
gdk_pixbuf_destroy (GdkPixBuf *pixbuf)
|
||||||
{
|
{
|
||||||
art_pixbuf_free (pixbuf->art_pixbuf);
|
art_pixbuf_free (pixbuf->art_pixbuf);
|
||||||
g_free (pixbuf);
|
g_free (pixbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gdk_pixbuf_ref (GdkPixBuf *pixbuf)
|
gdk_pixbuf_ref (GdkPixBuf *pixbuf)
|
||||||
{
|
{
|
||||||
g_return_if_fail (pixbuf != NULL);
|
g_return_if_fail (pixbuf != NULL);
|
||||||
|
|
||||||
pixbuf->ref_count++;
|
pixbuf->ref_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -38,14 +39,6 @@ gdk_pixbuf_unref (GdkPixBuf *pixbuf)
|
|||||||
gdk_pixbuf_destroy (pixbuf);
|
gdk_pixbuf_destroy (pixbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
gdk_pixbuf_free (GdkPixBuf *pixbuf)
|
|
||||||
{
|
|
||||||
art_free(pixbuf->art_pixbuf->pixels);
|
|
||||||
art_pixbuf_free_shallow(pixbuf->art_pixbuf);
|
|
||||||
g_free(pixbuf);
|
|
||||||
}
|
|
||||||
|
|
||||||
GdkPixBuf *
|
GdkPixBuf *
|
||||||
gdk_pixbuf_scale (GdkPixBuf *pixbuf, gint w, gint h)
|
gdk_pixbuf_scale (GdkPixBuf *pixbuf, gint w, gint h)
|
||||||
{
|
{
|
||||||
@ -64,7 +57,7 @@ gdk_pixbuf_scale (GdkPixBuf *pixbuf, gint w, gint h)
|
|||||||
affine[0] = w / (double)(pixbuf->art_pixbuf->width);
|
affine[0] = w / (double)(pixbuf->art_pixbuf->width);
|
||||||
affine[3] = h / (double)(pixbuf->art_pixbuf->height);
|
affine[3] = h / (double)(pixbuf->art_pixbuf->height);
|
||||||
|
|
||||||
// rowstride = w * pixbuf->art_pixbuf->n_channels;
|
/* rowstride = w * pixbuf->art_pixbuf->n_channels; */
|
||||||
rowstride = w * 3;
|
rowstride = w * 3;
|
||||||
|
|
||||||
pixels = art_alloc (h * rowstride);
|
pixels = art_alloc (h * rowstride);
|
||||||
@ -73,7 +66,7 @@ gdk_pixbuf_scale (GdkPixBuf *pixbuf, gint w, gint h)
|
|||||||
affine, ART_FILTER_NEAREST, alphagamma);
|
affine, ART_FILTER_NEAREST, alphagamma);
|
||||||
|
|
||||||
if (pixbuf->art_pixbuf->has_alpha)
|
if (pixbuf->art_pixbuf->has_alpha)
|
||||||
// should be rgba
|
/* should be rgba */
|
||||||
art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride);
|
art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride);
|
||||||
else
|
else
|
||||||
art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride);
|
art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride);
|
||||||
@ -84,5 +77,43 @@ gdk_pixbuf_scale (GdkPixBuf *pixbuf, gint w, gint h)
|
|||||||
return pixbuf;
|
return pixbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GdkPixBuf *
|
||||||
|
gdk_pixbuf_rotate (GdkPixBuf *pixbuf, gdouble angle)
|
||||||
|
{
|
||||||
|
GdkPixBuf *rotate;
|
||||||
|
art_u8 *pixels;
|
||||||
|
gint rowstride, w, h;
|
||||||
|
gdouble rad;
|
||||||
|
double affine[6];
|
||||||
|
ArtAlphaGamma *alphagamma = NULL;
|
||||||
|
ArtPixBuf *art_pixbuf = NULL;
|
||||||
|
|
||||||
|
w = pixbuf->art_pixbuf->width;
|
||||||
|
h = pixbuf->art_pixbuf->height;
|
||||||
|
|
||||||
|
rad = M_PI * angle / 180.0;
|
||||||
|
|
||||||
|
affine[0] = cos(rad);
|
||||||
|
affine[1] = sin(rad);
|
||||||
|
affine[2] = -sin(rad);
|
||||||
|
affine[3] = cos(rad);
|
||||||
|
affine[4] = affine[5] = 0;
|
||||||
|
|
||||||
|
/* rowstride = w * pixbuf->art_pixbuf->n_channels; */
|
||||||
|
rowstride = w * 3;
|
||||||
|
|
||||||
|
pixels = art_alloc (h * rowstride);
|
||||||
|
art_rgb_pixbuf_affine (pixels, 0, 0, w, h, rowstride,
|
||||||
|
pixbuf->art_pixbuf,
|
||||||
|
affine, ART_FILTER_NEAREST, alphagamma);
|
||||||
|
if (pixbuf->art_pixbuf->has_alpha)
|
||||||
|
/* should be rgba */
|
||||||
|
art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride);
|
||||||
|
else
|
||||||
|
art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride);
|
||||||
|
|
||||||
|
art_pixbuf_free (pixbuf->art_pixbuf);
|
||||||
|
pixbuf->art_pixbuf = art_pixbuf;
|
||||||
|
|
||||||
|
return pixbuf;
|
||||||
|
}
|
||||||
|
@ -16,7 +16,8 @@ void gdk_pixbuf_ref (GdkPixBuf *pixbuf);
|
|||||||
void gdk_pixbuf_unref (GdkPixBuf *pixbuf);
|
void gdk_pixbuf_unref (GdkPixBuf *pixbuf);
|
||||||
GdkPixBuf *gdk_pixbuf_duplicate (GdkPixBuf *pixbuf);
|
GdkPixBuf *gdk_pixbuf_duplicate (GdkPixBuf *pixbuf);
|
||||||
GdkPixBuf *gdk_pixbuf_scale (GdkPixBuf *pixbuf, gint w, gint h);
|
GdkPixBuf *gdk_pixbuf_scale (GdkPixBuf *pixbuf, gint w, gint h);
|
||||||
|
GdkPixBuf *gdk_pixbuf_rotate (GdkPixBuf *pixbuf, gdouble angle);
|
||||||
|
|
||||||
void gdk_pixbuf_free (GdkPixBuf *pixbuf);
|
void gdk_pixbuf_destroy (GdkPixBuf *pixbuf);
|
||||||
|
|
||||||
#endif /* _GDK_PIXBUF_H_ */
|
#endif /* _GDK_PIXBUF_H_ */
|
||||||
|
@ -25,8 +25,9 @@
|
|||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include "gdk-pixbuf.h"
|
#include "gdk-pixbuf.h"
|
||||||
#include "gdk-pixbuf-io.h"
|
#include "gdk-pixbuf-io.h"
|
||||||
|
#include "io-bmp.h"
|
||||||
|
|
||||||
/* Loosely based off the BMP loader from The GIMP */
|
/* Loosely based off the BMP loader from The GIMP, hence it's complexity */
|
||||||
|
|
||||||
/* Shared library entry point */
|
/* Shared library entry point */
|
||||||
GdkPixBuf *image_load(FILE * f)
|
GdkPixBuf *image_load(FILE * f)
|
||||||
|
Loading…
Reference in New Issue
Block a user