diff options
author | Owen Taylor <otaylor@redhat.com> | 2001-02-02 22:19:31 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2001-02-02 22:19:31 +0000 |
commit | a2d1299475cb8f34f99e420ef752bf9366275bf7 (patch) | |
tree | 1a7dd40f663b198d7e525ea07a6a84a63f6e783e /gdk | |
parent | a1a252ce46b50ff199e5ee084036267455b9ec5b (diff) | |
download | gdk-pixbuf-a2d1299475cb8f34f99e420ef752bf9366275bf7.tar.gz |
Make gdk_colormap_sync private since it was never exported in a header
Fri Feb 2 17:16:09 2001 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkcolor-x11.c (gdk_colormap_sync): Make
gdk_colormap_sync private since it was never exported
in a header file.
* gdk/x11/gdkcolor-x11.c (gdk_colormap_new): Fill in
colormap->colors[] for StaticGray, StaticColor colormaps.
* gdk/gdkpixbuf-drawable.c: Fix problems where image->bpp
was being used as if it was image->bits_per_pixel.
* gdk/gdkimage.h, gdk/x11/gdkimage-x11.c: Save the bits-per-pixel
for the image in the GdkImage structure since it isn't
reconstructable, and we need it to handle packed types
* gdk/win32/gdkimage-win32.c: Set image->bits_per_pixel. (I'm making
the assumption that on Win32 image->bits_per_pixel == image->depth,
always.
* gdk/linux-fb/gdkimage-fb.c: Set image->bits_per_pixel.
* gdk/gdkrgb.c (gdk_rgb_select_conv): Exit with an informative
warning message if no converter can be found.
Diffstat (limited to 'gdk')
-rw-r--r-- | gdk/gdkimage.h | 5 | ||||
-rw-r--r-- | gdk/gdkpixbuf-drawable.c | 13 | ||||
-rw-r--r-- | gdk/gdkrgb.c | 18 | ||||
-rw-r--r-- | gdk/linux-fb/gdkimage-fb.c | 13 | ||||
-rw-r--r-- | gdk/win32/gdkimage-win32.c | 3 | ||||
-rw-r--r-- | gdk/x11/gdkcolor-x11.c | 28 | ||||
-rw-r--r-- | gdk/x11/gdkimage-x11.c | 12 |
7 files changed, 57 insertions, 35 deletions
diff --git a/gdk/gdkimage.h b/gdk/gdkimage.h index 16bf59d60..2c631b356 100644 --- a/gdk/gdkimage.h +++ b/gdk/gdkimage.h @@ -44,8 +44,9 @@ struct _GdkImage gint width; gint height; guint16 depth; - guint16 bpp; /* bytes per pixel */ - guint16 bpl; /* bytes per line */ + guint16 bpp; /* bytes per pixel */ + guint16 bpl; /* bytes per line */ + guint16 bits_per_pixel; /* bits per pixel */ gpointer mem; gpointer windowing_data; diff --git a/gdk/gdkpixbuf-drawable.c b/gdk/gdkpixbuf-drawable.c index 776ebe606..97539a0e5 100644 --- a/gdk/gdkpixbuf-drawable.c +++ b/gdk/gdkpixbuf-drawable.c @@ -1078,7 +1078,7 @@ rgbconvert (GdkImage *image, GdkVisual *v = gdk_colormap_get_visual(cmap); d(printf("masks = %x:%x:%x\n", v->red_mask, v->green_mask, v->blue_mask)); - d(printf("image depth = %d, bpp = %d\n", image->depth, image->bpp)); + d(printf("image depth = %d, bits per pixel = %d\n", image->depth, image->bits_per_pixel)); switch (v->type) { @@ -1087,13 +1087,14 @@ rgbconvert (GdkImage *image, case GDK_VISUAL_GRAYSCALE: case GDK_VISUAL_STATIC_COLOR: case GDK_VISUAL_PSEUDO_COLOR: - switch (image->bpp) + switch (image->bits_per_pixel) { case 1: bank = 0; break; case 8: - bank = 1; + if (image->depth == 8) + bank = 1; break; } break; @@ -1102,18 +1103,18 @@ rgbconvert (GdkImage *image, { case 15: if (v->red_mask == 0x7c00 && v->green_mask == 0x3e0 && v->blue_mask == 0x1f - && image->bpp == 16) + && image->bits_per_pixel == 16) bank = 2; break; case 16: if (v->red_mask == 0xf800 && v->green_mask == 0x7e0 && v->blue_mask == 0x1f - && image->bpp == 16) + && image->bits_per_pixel == 16) bank = 3; break; case 24: case 32: if (v->red_mask == 0xff0000 && v->green_mask == 0xff00 && v->blue_mask == 0xff - && image->bpp == 32) + && image->bits_per_pixel == 32) bank = 4; break; } diff --git a/gdk/gdkrgb.c b/gdk/gdkrgb.c index aa24b3cfa..600d1f3b7 100644 --- a/gdk/gdkrgb.c +++ b/gdk/gdkrgb.c @@ -2872,13 +2872,7 @@ gdk_rgb_select_conv (GdkRgbInfo *image_info, GdkImage *image) depth = image_info->visual->depth; - /* FIXME: save the bpp in the image; this is hack that works for - * common visuals, not otherwise. - */ - if (depth <= 8) - bpp = depth; - else - bpp = 8 * image->bpp; + bpp = image->bits_per_pixel; byte_order = image->byte_order; if (gdk_rgb_verbose) @@ -3031,6 +3025,16 @@ gdk_rgb_select_conv (GdkRgbInfo *image_info, GdkImage *image) conv_d = gdk_rgb_convert_gray4_d_pack; } + if (!conv) + { + g_warning ("Visual type=%s depth=%d, image bpp=%d, %s first\n" + "is not supported by GdkRGB. Please submit a bug report\n" + "with the above values to bugzilla.gnome.org", + visual_names[vtype], depth, bpp, + byte_order == GDK_LSB_FIRST ? "lsb" : "msb"); + exit (1); + } + if (conv_d == NULL) conv_d = conv; diff --git a/gdk/linux-fb/gdkimage-fb.c b/gdk/linux-fb/gdkimage-fb.c index 3c112fe60..81251ff2e 100644 --- a/gdk/linux-fb/gdkimage-fb.c +++ b/gdk/linux-fb/gdkimage-fb.c @@ -122,6 +122,7 @@ gdk_image_new_bitmap(GdkVisual *visual, image->depth = 1; image->byte_order = 1 /* MSBFirst */; + image->bits_per_pixel = 1; image->bpp = 1; image->bpl = (w+7)/8; image->mem = g_malloc (image->bpl * h / 8); @@ -148,6 +149,7 @@ gdk_image_new (GdkImageType type, image->depth = visual->depth; image->byte_order = 0; + image->bits_per_pixel = image->depth; image->bpp = image->depth/8; image->bpl = (width * image->depth + 7) / 8; image->mem = g_malloc (image->bpl * height); @@ -164,7 +166,7 @@ _gdk_fb_get_image (GdkDrawable *drawable, { GdkImage *image; GdkImagePrivateFB *private; - gint bits_per_pixel = GDK_DRAWABLE_IMPL_FBDATA (gdk_parent_root)->depth; + gint bits_per_pixel = GdkPixmapFBData fbd; g_return_val_if_fail (drawable != NULL, NULL); @@ -176,13 +178,14 @@ _gdk_fb_get_image (GdkDrawable *drawable, image->visual = gdk_drawable_get_visual (drawable); image->width = width; image->height = height; - image->depth = bits_per_pixel; + image->bits_per_pixel = GDK_DRAWABLE_IMPL_FBDATA (gdk_parent_root)->depth; + image->depth = image->bits_per_pixel; - if (bits_per_pixel <= 8) + if (image->bits_per_pixel <= 8) image->bpp = 1; - else if (bits_per_pixel <= 16) + else if (image->bits_per_pixel <= 16) image->bpp = 2; - else if (bits_per_pixel <= 24) + else if (image->bits_per_pixel <= 24) image->bpp = 3; else image->bpp = 4; diff --git a/gdk/win32/gdkimage-win32.c b/gdk/win32/gdkimage-win32.c index 65ada9d6e..32c05702f 100644 --- a/gdk/win32/gdkimage-win32.c +++ b/gdk/win32/gdkimage-win32.c @@ -180,6 +180,7 @@ gdk_image_new_bitmap (GdkVisual *visual, image->bpl = bpl32; image->byte_order = GDK_MSB_FIRST; + image->bits_per_pixel = 1; image->bpp = 1; return(image); } /* gdk_image_new_bitmap() */ @@ -307,6 +308,7 @@ gdk_image_new (GdkImageType type, g_warning ("gdk_image_new: depth = %d", image->depth); g_assert_not_reached (); } + image->bits_per_pixel = image->depth; image->byte_order = GDK_LSB_FIRST; if (image->depth == 1) image->bpl = ((width-1)/32 + 1)*4; @@ -547,6 +549,7 @@ _gdk_win32_get_image (GdkDrawable *drawable, g_warning ("gdk_image_get: image->depth = %d", image->depth); g_assert_not_reached (); } + image->bits_per_pixel = image->depth; image->byte_order = GDK_LSB_FIRST; if (image->depth == 1) image->bpl = ((width - 1)/32 + 1)*4; diff --git a/gdk/x11/gdkcolor-x11.c b/gdk/x11/gdkcolor-x11.c index a20a302d7..d18e8073c 100644 --- a/gdk/x11/gdkcolor-x11.c +++ b/gdk/x11/gdkcolor-x11.c @@ -212,6 +212,14 @@ gdk_colormap_new (GdkVisual *visual, case GDK_VISUAL_STATIC_GRAY: case GDK_VISUAL_STATIC_COLOR: + private->private_val = FALSE; + private->xcolormap = XCreateColormap (private->xdisplay, gdk_root_window, + xvisual, AllocNone); + + colormap->colors = g_new (GdkColor, colormap->size); + gdk_colormap_sync (colormap); + break; + case GDK_VISUAL_TRUE_COLOR: private->private_val = FALSE; private->xcolormap = XCreateColormap (private->xdisplay, gdk_root_window, @@ -226,7 +234,7 @@ gdk_colormap_new (GdkVisual *visual, #define MIN_SYNC_TIME 2 -void +static void gdk_colormap_sync (GdkColormap *colormap, gboolean force) { @@ -249,7 +257,7 @@ gdk_colormap_sync (GdkColormap *colormap, for (i = 0; i < colormap->size; i++) { - if (private->info[i].ref_count == 0) + if (!private->info || private->info[i].ref_count == 0) { xpalette[nlookup].pixel = i; xpalette[nlookup].red = 0; @@ -297,16 +305,22 @@ gdk_colormap_get_system (void) colormap->colors = NULL; colormap->size = colormap->visual->colormap_size; - if ((colormap->visual->type == GDK_VISUAL_GRAYSCALE) || - (colormap->visual->type == GDK_VISUAL_PSEUDO_COLOR)) + switch (colormap->visual->type) { + case GDK_VISUAL_GRAYSCALE: + case GDK_VISUAL_PSEUDO_COLOR: private->info = g_new0 (GdkColorInfo, colormap->size); - colormap->colors = g_new (GdkColor, colormap->size); - private->hash = g_hash_table_new ((GHashFunc) gdk_color_hash, (GEqualFunc) gdk_color_equal); - + /* Fall through */ + case GDK_VISUAL_STATIC_GRAY: + case GDK_VISUAL_STATIC_COLOR: + colormap->colors = g_new (GdkColor, colormap->size); gdk_colormap_sync (colormap, TRUE); + + case GDK_VISUAL_DIRECT_COLOR: + case GDK_VISUAL_TRUE_COLOR: + break; } gdk_colormap_add (colormap); diff --git a/gdk/x11/gdkimage-x11.c b/gdk/x11/gdkimage-x11.c index 1eeee2297..cfdb569ca 100644 --- a/gdk/x11/gdkimage-x11.c +++ b/gdk/x11/gdkimage-x11.c @@ -155,6 +155,7 @@ gdk_image_new_bitmap(GdkVisual *visual, gpointer data, gint w, gint h) image->width = w; image->height = h; image->depth = 1; + image->bits_per_pixel = 1; xvisual = ((GdkVisualPrivate*) visual)->xvisual; private->ximage = XCreateImage(private->xdisplay, xvisual, 1, XYBitmap, 0, 0, w ,h, 8, 0); @@ -364,6 +365,7 @@ gdk_image_new (GdkImageType type, image->mem = private->ximage->data; image->bpl = private->ximage->bytes_per_line; image->bpp = (private->ximage->bits_per_pixel + 7) / 8; + image->bits_per_pixel = private->ximage->bits_per_pixel; } } @@ -415,14 +417,8 @@ _gdk_x11_get_image (GdkDrawable *drawable, image->mem = private->ximage->data; image->bpl = private->ximage->bytes_per_line; - if (private->ximage->bits_per_pixel <= 8) - image->bpp = 1; - else if (private->ximage->bits_per_pixel <= 16) - image->bpp = 2; - else if (private->ximage->bits_per_pixel <= 24) - image->bpp = 3; - else - image->bpp = 4; + image->bits_per_pixel = private->ximage->bits_per_pixel; + image->bpp = (private->ximage->bits_per_pixel + 7) / 8; image->byte_order = private->ximage->byte_order; return image; |