gdip-pixbuf-loader r16 - in trunk: . src
- From: doml svn gnome org
- To: svn-commits-list gnome org
- Subject: gdip-pixbuf-loader r16 - in trunk: . src
- Date: Mon, 18 Feb 2008 23:38:16 +0000 (GMT)
Author: doml
Date: Mon Feb 18 23:38:16 2008
New Revision: 16
URL: http://svn.gnome.org/viewvc/gdip-pixbuf-loader?rev=16&view=rev
Log:
2008-02-18 Dominic Lachowicz <domlachowicz gmail com>
* src/*.[ch]: If the source image doesn't have alpha, don't create an opaque alpha channel in
the pixbuf
Modified:
trunk/ChangeLog
trunk/src/io-gdip-native.h
trunk/src/io-gdip-utils.c
trunk/src/io-gdip-utils.h
trunk/src/io-gdip.c
Modified: trunk/src/io-gdip-native.h
==============================================================================
--- trunk/src/io-gdip-native.h (original)
+++ trunk/src/io-gdip-native.h Mon Feb 18 23:38:16 2008
@@ -88,6 +88,23 @@
typedef enum _Status Status;
typedef enum _Status GpStatus;
+typedef enum {
+ ImageFlagsNone = 0,
+ ImageFlagsScalable = 0x0001,
+ ImageFlagsHasAlpha = 0x0002,
+ ImageFlagsHasTranslucent = 0x0004,
+ ImageFlagsPartiallyScalable = 0x0008,
+ ImageFlagsColorSpaceRGB = 0x0010,
+ ImageFlagsColorSpaceCMYK = 0x0020,
+ ImageFlagsColorSpaceGRAY = 0x0040,
+ ImageFlagsColorSpaceYCBCR = 0x0080,
+ ImageFlagsColorSpaceYCCK = 0x0100,
+ ImageFlagsHasRealDPI = 0x1000,
+ ImageFlagsHasRealPixelSize = 0x2000,
+ ImageFlagsReadOnly = 0x00010000,
+ ImageFlagsCaching = 0x00020000
+} ImageFlags;
+
enum _ImageLockMode
{
ImageLockModeRead = 1,
@@ -116,14 +133,15 @@
};
typedef struct _GdiplusStartupInput GdiplusStartupInput;
-typedef Status (CALLBACK* GdiplusStartupFunc) (gpointer, const gpointer, gpointer);
+typedef GpStatus (CALLBACK* GdiplusStartupFunc) (gpointer, const gpointer, gpointer);
-typedef Status (CALLBACK* GdipCreateBitmapFromStreamFunc) (gpointer, GpBitmap**);
+typedef GpStatus (CALLBACK* GdipCreateBitmapFromStreamFunc) (gpointer, GpBitmap**);
-typedef Status (CALLBACK* GdipBitmapGetPixelFunc) (GpBitmap*, gint x, gint y, ARGB*);
+typedef GpStatus (CALLBACK* GdipBitmapGetPixelFunc) (GpBitmap*, gint x, gint y, ARGB*);
-typedef Status (CALLBACK* GdipGetImageWidthFunc) (GpImage*, guint*);
-typedef Status (CALLBACK* GdipGetImageHeightFunc) (GpImage*, guint*);
-typedef Status (CALLBACK* GdipDisposeImageFunc) (GpImage*);
+typedef GpStatus (CALLBACK* GdipGetImageWidthFunc) (GpImage*, guint*);
+typedef GpStatus (CALLBACK* GdipGetImageHeightFunc) (GpImage*, guint*);
+typedef GpStatus (CALLBACK* GdipDisposeImageFunc) (GpImage*);
+typedef GpStatus (CALLBACK* GdipGetImageFlagsFunc) (GpImage *, guint*);
#endif
Modified: trunk/src/io-gdip-utils.c
==============================================================================
--- trunk/src/io-gdip-utils.c (original)
+++ trunk/src/io-gdip-utils.c Mon Feb 18 23:38:16 2008
@@ -99,6 +99,20 @@
}
GpStatus WINGDIPAPI
+GdipGetImageFlags (GpImage *image, guint *flags)
+{
+ static GdipGetImageFlagsFunc proc = NULL;
+
+ if (gdipluslib && !proc)
+ proc = (GdipGetImageFlagsFunc) GetProcAddress(gdipluslib, "GdipGetImageFlags");
+
+ if (!proc)
+ return GenericError;
+
+ return (*proc) (image, flags);
+}
+
+GpStatus WINGDIPAPI
GdipGetImageWidth (GpImage* image, guint* width)
{
static GdipGetImageWidthFunc proc = NULL;
@@ -199,6 +213,19 @@
return TRUE;
}
+gboolean
+io_gdip_bitmap_get_has_alpha (GpBitmap * bitmap, gboolean * has_alpha)
+{
+ guint flags = 0;
+
+ if (bitmap == NULL || has_alpha == NULL)
+ return FALSE;
+
+ GdipGetImageFlags ((GpImage*) bitmap, &flags);
+ *has_alpha = (flags & ImageFlagsHasAlpha);
+ return TRUE;
+}
+
ARGB
io_gdip_bitmap_get_pixel (GpBitmap *bitmap, guint x, guint y)
{
Modified: trunk/src/io-gdip-utils.h
==============================================================================
--- trunk/src/io-gdip-utils.h (original)
+++ trunk/src/io-gdip-utils.h Mon Feb 18 23:38:16 2008
@@ -36,6 +36,9 @@
gboolean
io_gdip_bitmap_get_size (GpBitmap *, guint *, guint *);
+gboolean
+io_gdip_bitmap_get_has_alpha (GpBitmap *, gboolean *);
+
ARGB
io_gdip_bitmap_get_pixel (GpBitmap *bitmap, guint x, guint y);
Modified: trunk/src/io-gdip.c
==============================================================================
--- trunk/src/io-gdip.c (original)
+++ trunk/src/io-gdip.c Mon Feb 18 23:38:16 2008
@@ -140,6 +140,8 @@
GdkPixbuf *pixbuf = NULL;
guchar *cursor = NULL;
gint rowstride;
+ gboolean has_alpha = FALSE;
+ gint n_channels = 0;
guint width = 0, height = 0, x, y;
@@ -159,8 +161,9 @@
}
io_gdip_bitmap_get_size (bitmap, &width, &height);
+ io_gdip_bitmap_get_has_alpha (bitmap, &has_alpha);
- pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, width, height);
+ pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, has_alpha, 8, width, height);
if (!pixbuf)
{
@@ -171,6 +174,7 @@
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
cursor = gdk_pixbuf_get_pixels (pixbuf);
+ n_channels = gdk_pixbuf_get_n_channels (pixbuf);
for (y = 0; y < height; y++)
{
@@ -178,7 +182,7 @@
{
ARGB pixel;
guint8 alpha;
- guchar *b = cursor + (y * rowstride + (x * 4));
+ guchar *b = cursor + (y * rowstride + (x * n_channels));
pixel = io_gdip_bitmap_get_pixel (bitmap, x, y);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]