1 --- gdk-pixbuf-0.22.0/gdk-pixbuf/io-bmp.c.bmp-colormap 2002-09-27 17:12:40.000000000 -0400
2 +++ gdk-pixbuf-0.22.0/gdk-pixbuf/io-bmp.c 2004-03-03 08:58:43.000000000 -0500
5 guint Negative; /* Negative = 1 -> top down BMP,
6 Negative = 0 -> bottom up BMP */
10 /* Data needed for the "state" during decompression */
12 guint Lines; /* # of finished lines */
20 guchar (*Colormap)[3];
23 DecodeHeader (unsigned char *BFH, unsigned char *BIH,
24 struct bmp_progressive_state *State)
28 g_assert (State->read_state == READ_STATE_HEADERS);
30 /* FIXME this is totally unrobust against bogus image data. */
35 + clrUsed = (int) (BIH[35] << 24) + (BIH[34] << 16) + (BIH[33] << 8) + (BIH[32]);
37 + State->Header.n_colors = clrUsed;
39 + State->Header.n_colors = 1 << State->Header.depth;
41 + if (State->Header.n_colors > 1 << State->Header.depth) {
45 + GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
46 + _("BMP image has bogus header data"));
48 + State->read_state = READ_STATE_ERROR;
52 State->Type = State->Header.depth; /* This may be less trivial someday */
54 /* Negative heights indicates bottom-down pixelorder */
56 struct bmp_progressive_state *State)
62 g_assert (State->read_state == READ_STATE_PALETTE);
64 + samples = (State->Header.size == 12 ? 3 : 4);
65 + if (State->BufferSize < State->Header.n_colors * samples) {
66 + State->BufferSize = State->Header.n_colors * samples;
67 + if (!grow_buffer (State))
72 State->Colormap = g_malloc ((1 << State->Header.depth) * sizeof (*State->Colormap));
74 - for (i = 0; i < (1 << State->Header.depth); i++)
75 + for (i = 0; i < State->Header.n_colors; i++)
77 - State->Colormap[i][0] = buff[i * (State->Header.size == 12 ? 3 : 4)];
78 - State->Colormap[i][1] = buff[i * (State->Header.size == 12 ? 3 : 4) + 1];
79 - State->Colormap[i][2] = buff[i * (State->Header.size == 12 ? 3 : 4) + 2];
80 + State->Colormap[i][0] = buff[i * samples];
81 + State->Colormap[i][1] = buff[i * samples + 1];
82 + State->Colormap[i][2] = buff[i * samples + 2];
85 State->read_state = READ_STATE_DATA;