bitblt.c

Tue, 22 Jan 2002 09:42:42 +0000

author
eric
date
Tue, 22 Jan 2002 09:42:42 +0000
changeset 43
b80cb5a4282a
parent 42
9c85a4cd88a3
child 47
bfc6aaa089b0
permissions
-rw-r--r--

*** empty log message ***

eric@42 1 #include <stdio.h>
eric@2 2 #include <stdlib.h>
eric@42 3 #include <string.h>
eric@2 4
eric@11 5 #include "type.h"
eric@2 6 #include "bitblt.h"
eric@2 7
eric@42 8
eric@43 9 #define DIV_ROUND_UP(count,pow2) (((count) - 1) / (pow2) + 1)
eric@42 10
eric@42 11
eric@42 12 static const u8 bit_reverse_byte [0x100] =
eric@42 13 {
eric@42 14 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
eric@42 15 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
eric@42 16 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
eric@42 17 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
eric@42 18 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
eric@42 19 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
eric@42 20 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
eric@42 21 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
eric@42 22 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
eric@42 23 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
eric@42 24 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
eric@42 25 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
eric@42 26 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
eric@42 27 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
eric@42 28 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
eric@42 29 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
eric@42 30 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
eric@42 31 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
eric@42 32 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
eric@42 33 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
eric@42 34 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
eric@42 35 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
eric@42 36 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
eric@42 37 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
eric@42 38 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
eric@42 39 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
eric@42 40 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
eric@42 41 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
eric@42 42 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
eric@42 43 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
eric@42 44 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
eric@42 45 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
eric@42 46 };
eric@42 47
eric@43 48 static word_type bit_reverse_word (word_type d)
eric@43 49 {
eric@43 50 return (bit_reverse_byte [d >> 24] |
eric@43 51 (bit_reverse_byte [(d >> 16) & 0xff] << 8) |
eric@43 52 (bit_reverse_byte [(d >> 8) & 0xff] << 16) |
eric@43 53 (bit_reverse_byte [d & 0xff] << 24));
eric@43 54 }
eric@42 55
eric@43 56
eric@43 57 static u32 *temp_buffer;
eric@42 58 static u32 temp_buffer_size;
eric@42 59
eric@42 60 static void realloc_temp_buffer (u32 size)
eric@42 61 {
eric@42 62 if (size <= temp_buffer_size)
eric@42 63 return;
eric@42 64 temp_buffer = realloc (temp_buffer, size);
eric@42 65 if (! temp_buffer)
eric@42 66 {
eric@42 67 fprintf (stderr, "realloc failed in bitblt library\n");
eric@42 68 exit (2);
eric@42 69 }
eric@42 70 temp_buffer_size = size;
eric@42 71 }
eric@42 72
eric@42 73
eric@43 74 static inline word_type pixel_mask (x)
eric@2 75 {
eric@2 76 #ifdef LSB_LEFT
eric@2 77 return (1 << x);
eric@2 78 #else
eric@43 79 return (1 << ((BITS_PER_WORD - 1) - x));
eric@2 80 #endif
eric@42 81 };
eric@2 82
eric@42 83 Bitmap *create_bitmap (Rect *rect)
eric@2 84 {
eric@2 85 Bitmap *bitmap;
eric@42 86 u32 width = rect_width (rect);
eric@42 87 u32 height = rect_height (rect);
eric@2 88
eric@35 89 if ((width <= 0) || (height <= 0))
eric@35 90 return (NULL);
eric@35 91
eric@2 92 bitmap = calloc (1, sizeof (Bitmap));
eric@2 93 if (! bitmap)
eric@2 94 return (NULL);
eric@42 95 bitmap->rect = * rect;
eric@43 96 bitmap->row_words = DIV_ROUND_UP (width, BITS_PER_WORD);
eric@43 97 bitmap->bits = calloc (1, height * bitmap->row_words * sizeof (word_type));
eric@2 98 if (! bitmap->bits)
eric@2 99 {
eric@2 100 free (bitmap);
eric@2 101 return (NULL);
eric@2 102 }
eric@2 103 return (bitmap);
eric@2 104 }
eric@2 105
eric@2 106 void free_bitmap (Bitmap *bitmap)
eric@2 107 {
eric@2 108 free (bitmap->bits);
eric@2 109 free (bitmap);
eric@2 110 }
eric@2 111
eric@2 112 boolean get_pixel (Bitmap *bitmap, Point coord)
eric@2 113 {
eric@43 114 word_type *p;
eric@42 115 if ((coord.x < bitmap->rect.min.x) ||
eric@42 116 (coord.x >= bitmap->rect.max.x) ||
eric@42 117 (coord.y < bitmap->rect.min.y) ||
eric@42 118 (coord.y >= bitmap->rect.max.y))
eric@2 119 return (0);
eric@42 120 p = bitmap->bits +
eric@43 121 (coord.y - bitmap->rect.min.y) * bitmap->row_words +
eric@43 122 (coord.x - bitmap->rect.min.x) / BITS_PER_WORD;
eric@43 123 return ((*p & pixel_mask (coord.x & (BITS_PER_WORD - 1))) != 0);
eric@2 124 }
eric@2 125
eric@2 126 void set_pixel (Bitmap *bitmap, Point coord, boolean value)
eric@2 127 {
eric@43 128 word_type *p;
eric@42 129 if ((coord.x < bitmap->rect.min.x) ||
eric@42 130 (coord.x >= bitmap->rect.max.x) ||
eric@42 131 (coord.y < bitmap->rect.min.y) ||
eric@42 132 (coord.y >= bitmap->rect.max.y))
eric@2 133 return;
eric@42 134 p = bitmap->bits +
eric@43 135 (coord.y - bitmap->rect.min.y) * bitmap->row_words +
eric@43 136 (coord.x - bitmap->rect.min.x) / BITS_PER_WORD;
eric@2 137 if (value)
eric@43 138 *p |= pixel_mask (coord.x & (BITS_PER_WORD - 1));
eric@2 139 else
eric@43 140 *p &= ~pixel_mask (coord.x & (BITS_PER_WORD - 1));
eric@2 141 }
eric@2 142
eric@2 143
eric@42 144 /* modifies rect1 to be the intersection of rect1 and rect2;
eric@42 145 returns true if intersection is non-null */
eric@42 146 static boolean clip_rect (Rect *rect1, Rect *rect2)
eric@42 147 {
eric@42 148 if (rect1->min.y > rect2->max.y)
eric@42 149 goto empty;
eric@42 150 if (rect1->min.y < rect2->min.y)
eric@42 151 {
eric@42 152 if (rect1->max.y < rect2->max.y)
eric@42 153 goto empty;
eric@42 154 rect1->min.y = rect2->min.y;
eric@42 155 }
eric@42 156 if (rect1->max.y > rect2->max.y)
eric@42 157 rect1->max.y = rect2->max.y;
eric@42 158
eric@42 159 if (rect1->min.x > rect2->max.x)
eric@42 160 goto empty;
eric@42 161 if (rect1->min.x < rect2->min.x)
eric@42 162 {
eric@42 163 if (rect1->max.x < rect2->max.x)
eric@42 164 goto empty;
eric@42 165 rect1->min.x = rect2->min.x;
eric@42 166 }
eric@42 167 if (rect1->max.x > rect2->max.x)
eric@42 168 rect1->max.x = rect2->max.x;
eric@42 169
eric@42 170 empty:
eric@42 171 rect1->min.x = rect1->min.y =
eric@42 172 rect1->max.x = rect1->max.y = 0;
eric@42 173 return (0);
eric@42 174 }
eric@42 175
eric@42 176
eric@43 177 #if 0
eric@43 178 static void blt_background (Bitmap *dest_bitmap,
eric@43 179 Rect *dest_rect)
eric@43 180 {
eric@43 181 s32 y;
eric@43 182 word_type *rp;
eric@43 183
eric@43 184 /* This function requires a non-null dest rect */
eric@43 185 assert (dest_rect->min.x < dest_rect->max.x);
eric@43 186 assert (dest_rect->min.y < dest_rect->max.y);
eric@43 187
eric@43 188 /* and that the rows of the dest rect lie entirely within the dest bitmap */
eric@43 189 assert (dest_rect->min.y >= dest_bitmap->rect->min.y);
eric@43 190 assert (dest_rect->max.y <= dest_bitmap->rect->max.y);
eric@43 191
eric@43 192 /* clip the x axis of the dest_rect to the bounds of the dest bitmap */
eric@43 193 if (dest_rect->min.x < dest_bitmap->rect.min.x)
eric@43 194 dest_rect->min.x = dest_bitmap->rect.min.x;
eric@43 195 if (dest_rect->max.x > dest_bitmap->rect.max.x)
eric@43 196 dest_rect->max.x = dest_bitmap->rect.max.x;
eric@43 197
eric@43 198 rp = ???;
eric@43 199 for (y = 0; y < rect_height (dest_rect); y++)
eric@43 200 {
eric@43 201 ???;
eric@43 202 rp += dest_bitmap->row_words;
eric@43 203 }
eric@43 204 }
eric@43 205
eric@43 206
eric@43 207 static void blt (Bitmap *src_bitmap,
eric@43 208 Rect *src_rect,
eric@43 209 Bitmap *dest_bitmap,
eric@43 210 Rect *dest_rect)
eric@43 211 {
eric@43 212 s32 y;
eric@43 213 word_type *rp;
eric@43 214
eric@43 215 /* This function requires a non-null src rect */
eric@43 216 assert (dest_rect->min.x < dest_rect->max.x);
eric@43 217 assert (dest_rect->min.y < dest_rect->max.y);
eric@43 218
eric@43 219 /* and a non-null dest rect */
eric@43 220 assert (dest_rect->min.x < dest_rect->max.x);
eric@43 221 assert (dest_rect->min.y < dest_rect->max.y);
eric@43 222
eric@43 223 /* and that the widths and heights of the rects match */
eric@43 224 assert (rect_width (src_rect) == rect_width (dest_rect));
eric@43 225 assert (rect_height (src_rect) == rect_height (dest_rect));
eric@43 226
eric@43 227 /* and that the rows of the src rect lie entirely within the src bitmap */
eric@43 228 assert (dest_rect->min.y >= dest_bitmap->rect->min.y);
eric@43 229 assert (dest_rect->max.y <= dest_bitmap->rect->max.y);
eric@43 230
eric@43 231 /* and that the rows of the dest rect lie entirely within the dest bitmap */
eric@43 232 assert (dest_rect->min.y >= dest_bitmap->rect->min.y);
eric@43 233 assert (dest_rect->max.y <= dest_bitmap->rect->max.y);
eric@43 234
eric@43 235 /* clip the x axis of the dest_rect to the bounds of the dest bitmap,
eric@43 236 and adjust the src_rect to match */
eric@43 237 if (dest_rect->min.x < dest_bitmap->rect.min.x)
eric@43 238 {
eric@43 239 src_rect->min.x += ???;
eric@43 240 dest_rect->min.x = dest_bitmap->rect.min.x;
eric@43 241 }
eric@43 242 if (dest_rect->max.x > dest_bitmap->rect.max.x)
eric@43 243 {
eric@43 244 dest_rect->max.x = dest_bitmap->rect.max.x;
eric@43 245 }
eric@43 246
eric@43 247 rp = ???;
eric@43 248 for (y = 0; y < rect_height (dest_rect); y++)
eric@43 249 {
eric@43 250 ???;
eric@43 251 rp += dest_bitmap->row_words;
eric@43 252 }
eric@43 253 }
eric@43 254
eric@43 255
eric@2 256 Bitmap *bitblt (Bitmap *src_bitmap,
eric@42 257 Rect *src_rect,
eric@2 258 Bitmap *dest_bitmap,
eric@42 259 Point *dest_min,
eric@43 260 int tfn,
eric@43 261 int background)
eric@43 262 {
eric@43 263 Rect sr, dr; /* src and dest rects, clipped to visible portion of
eric@43 264 dest rect */
eric@43 265 u32 drw, drh; /* dest rect width, height - gets adjusted */
eric@43 266 Point src_point, dest_point;
eric@43 267
eric@43 268 {
eric@43 269 sr = * src_rect;
eric@43 270
eric@43 271 u32 srw = rect_width (& sr);
eric@43 272 u32 srh = rect_height (& sr);
eric@43 273
eric@43 274 if ((srw < 0) || (srh < 0))
eric@43 275 goto done; /* the source rect is empty! */
eric@43 276
eric@43 277 dr.min = * dest_min;
eric@43 278 dr.max.x = dr.min.x + srw;
eric@43 279 dr.max.y = dr.min.y + srh;
eric@43 280 }
eric@43 281
eric@43 282 if (! dest_bitmap)
eric@43 283 {
eric@43 284 dest_bitmap = create_bitmap (& dr);
eric@43 285 if (! dest_bitmap)
eric@43 286 return (NULL);
eric@43 287 }
eric@43 288
eric@43 289 if ((dr.min.x >= dest_bitmap->rect.max.x) ||
eric@43 290 (dr.min.y >= dest_bitmap->rect.max.y))
eric@43 291 goto done; /* the dest rect isn't even in the dest bitmap! */
eric@43 292
eric@43 293 /* crop dest rect to dest bitmap */
eric@43 294
eric@43 295 delta = dest_bitmap->rect.min.x - dr.min.x;
eric@43 296 if (delta > 0)
eric@43 297 {
eric@43 298 sr.min.x += delta;
eric@43 299 dr.min.x += delta;
eric@43 300 }
eric@43 301
eric@43 302 delta = dest_bitmap->rect.min.y - dr.min.y;
eric@43 303 if (delta > 0)
eric@43 304 {
eric@43 305 sr.min.y += delta;
eric@43 306 dr.min.y += delta;
eric@43 307 }
eric@43 308
eric@43 309 delta = dr.max.x - dest_bitmap->rect.max.x;
eric@43 310 if (delta > 0)
eric@43 311 {
eric@43 312 sr.max.x -= delta;
eric@43 313 dr.max.x -= delta;
eric@43 314 }
eric@43 315
eric@43 316 delta = dr.max.y - dest_bitmap->rect.max.y;
eric@43 317 if (delta > 0)
eric@43 318 {
eric@43 319 sr.max.x -= delta;
eric@43 320 dr.max.x -= delta;
eric@43 321 }
eric@43 322
eric@43 323 drw = rect_width (& dr);
eric@43 324 drh = rect_height (& dh);
eric@43 325
eric@43 326 /* if the source rect min y is >= the source bitmap max y,
eric@43 327 we transfer background color to the entire dest rect */
eric@43 328 if (sr.min.y >= src->rect.max.y)
eric@43 329 {
eric@43 330 blt_background (dest_bitmap, & dr);
eric@43 331 goto done;
eric@43 332 }
eric@43 333
eric@43 334 /* if the source rect min y is less than the source bitmap min y,
eric@43 335 we need to transfer some backgound color to the top part of the dest
eric@43 336 rect */
eric@43 337 if (sr.min.y < src->rect.min.y)
eric@43 338 {
eric@43 339 Rect dr2;
eric@43 340 uint32 bg_height;
eric@43 341
eric@43 342 bg_height = src->rect.min.y - sr.min.y;
eric@43 343 if (bg_height > sh)
eric@43 344 bg_height = sh;
eric@43 345
eric@43 346 dr2 = dr;
eric@43 347 dr2.max.y = dr2.min.y + bg_height;
eric@43 348
eric@43 349 blt_background (dest_bitmap, & dr2);
eric@43 350
eric@43 351 /* now reduce the rect height by the number of lines of background
eric@43 352 color */
eric@43 353 sr.min.y += bg_height;
eric@43 354 dr.min.y += bg_height;
eric@43 355 sh -= bg_height;
eric@43 356 dh -= bg_height;
eric@43 357
eric@43 358 if (sr.min.y == sr.max.y)
eric@43 359 goto done;
eric@43 360 }
eric@43 361
eric@43 362 /* now blt the available rows of the source rect */
eric@43 363
eric@43 364 /* now transfer the background color to any remaining rows of the
eric@43 365 dest rect */
eric@43 366 if (??? )
eric@43 367 {
eric@43 368 blt_background (dest_bitmap, & dr);
eric@43 369 }
eric@43 370
eric@43 371 done:
eric@43 372 return (dest_bitmap);
eric@43 373 }
eric@43 374 #else
eric@43 375 Bitmap *bitblt (Bitmap *src_bitmap,
eric@43 376 Rect *src_rect,
eric@43 377 Bitmap *dest_bitmap,
eric@43 378 Point *dest_min,
eric@43 379 int tfn,
eric@43 380 int background)
eric@2 381 {
eric@2 382 Point src_point, dest_point;
eric@2 383
eric@2 384 if (! dest_bitmap)
eric@2 385 {
eric@42 386 Rect dest_rect = {{ 0, 0 }, { dest_min->x + rect_width (src_rect),
eric@42 387 dest_min->y + rect_height (src_rect) }};
eric@42 388 dest_bitmap = create_bitmap (& dest_rect);
eric@2 389 if (! dest_bitmap)
eric@2 390 return (NULL);
eric@2 391 }
eric@2 392
eric@42 393 for (src_point.y = src_rect->min.y;
eric@42 394 src_point.y < src_rect->max.y;
eric@2 395 src_point.y++)
eric@2 396 {
eric@42 397 dest_point.y = dest_min->y + src_point.y - src_rect->min.y;
eric@42 398
eric@42 399 for (src_point.x = src_rect->min.x;
eric@42 400 src_point.x < src_rect->max.x;
eric@2 401 src_point.x++)
eric@2 402 {
eric@2 403 boolean a, b, c;
eric@2 404
eric@42 405 dest_point.x = dest_min->x + src_point.x - src_rect->min.x;
eric@3 406
eric@2 407 a = get_pixel (src_bitmap, src_point);
eric@2 408 b = get_pixel (dest_bitmap, dest_point);
eric@2 409 c = (tfn & (1 << (a * 2 + b))) != 0;
eric@2 410
eric@2 411 set_pixel (dest_bitmap, dest_point, c);
eric@2 412 }
eric@2 413 }
eric@2 414 return (dest_bitmap);
eric@2 415 }
eric@43 416 #endif
eric@42 417
eric@42 418
eric@42 419 /* in-place transformations */
eric@42 420 void flip_h (Bitmap *src)
eric@42 421 {
eric@43 422 word_type *rp; /* row pointer */
eric@43 423 word_type *p1; /* work src ptr */
eric@43 424 word_type *p2; /* work dest ptr */
eric@42 425 s32 y;
eric@43 426 int shift1, shift2;
eric@42 427
eric@43 428 realloc_temp_buffer ((src->row_words + 1) * sizeof (word_type));
eric@42 429
eric@42 430 rp = src->bits;
eric@42 431 if ((rect_width (& src->rect) & 7) == 0)
eric@42 432 {
eric@42 433 for (y = src->rect.min.y; y < src->rect.max.y; y++)
eric@42 434 {
eric@43 435 memcpy (temp_buffer, rp, src->row_words * sizeof (word_type));
eric@43 436 p1 = temp_buffer + src->row_words;
eric@42 437 p2 = rp;
eric@42 438
eric@42 439 while (p1 >= temp_buffer)
eric@43 440 *(p2++) = bit_reverse_word (*(p1--));
eric@42 441
eric@43 442 rp += src->row_words;
eric@42 443 }
eric@42 444 return;
eric@42 445 }
eric@42 446
eric@42 447 temp_buffer [0] = 0;
eric@43 448 shift1 = rect_width (& src->rect) & (BITS_PER_WORD - 1);
eric@43 449 shift2 = BITS_PER_WORD - shift1;
eric@42 450
eric@42 451 for (y = src->rect.min.y; y < src->rect.max.y; y++)
eric@42 452 {
eric@43 453 word_type d1, d2;
eric@43 454
eric@43 455 memcpy (temp_buffer + 1, rp, src->row_words * sizeof (word_type));
eric@43 456 p1 = temp_buffer + src->row_words;
eric@42 457 p2 = rp;
eric@42 458
eric@43 459 d2 = *(p1--);
eric@42 460
eric@42 461 while (p1 >= temp_buffer)
eric@42 462 {
eric@43 463 d1 = *(p1--);
eric@43 464 *(p2++) = bit_reverse_word ((d1 << shift1) | (d2 >> shift2));
eric@43 465 d2 = d1;
eric@42 466 }
eric@42 467
eric@43 468 rp += src->row_words;
eric@42 469 }
eric@42 470 }
eric@42 471
eric@42 472 void flip_v (Bitmap *src)
eric@42 473 {
eric@43 474 word_type *p1, *p2;
eric@42 475
eric@43 476 realloc_temp_buffer (src->row_words * sizeof (word_type));
eric@42 477
eric@42 478 p1 = src->bits;
eric@43 479 p2 = src->bits + src->row_words * (rect_height (& src->rect) - 1);
eric@42 480 while (p1 < p2)
eric@42 481 {
eric@43 482 memcpy (temp_buffer, p1, src->row_words * sizeof (word_type));
eric@43 483 memcpy (p1, p2, src->row_words * sizeof (word_type));
eric@43 484 memcpy (p2, temp_buffer, src->row_words * sizeof (word_type));
eric@43 485 p1 += src->row_words;
eric@43 486 p2 -= src->row_words;
eric@42 487 }
eric@42 488 }
eric@42 489
eric@42 490 void rot_180 (Bitmap *src) /* combination of flip_h and flip_v */
eric@42 491 {
eric@42 492 flip_h (src);
eric@42 493 flip_v (src);
eric@42 494 }
eric@42 495
eric@42 496 /* "in-place" transformations - will allocate new memory and free old */
eric@42 497 void transpose (Bitmap *src)
eric@42 498 {
eric@43 499 u32 new_row_words = DIV_ROUND_UP (rect_height (& src->rect), 32);
eric@43 500 word_type *new_bits;
eric@42 501
eric@43 502 new_bits = calloc (1, new_row_words * rect_width (& src->rect) * sizeof (word_type));
eric@42 503
eric@42 504 /* $$$ more code needed here */
eric@42 505 }
eric@42 506
eric@42 507 void rot_90 (Bitmap *src) /* transpose + flip_h */
eric@42 508 {
eric@42 509 transpose (src);
eric@42 510 flip_h (src);
eric@42 511 }
eric@42 512
eric@42 513 void rot_270 (Bitmap *src) /* transpose + flip_v */
eric@42 514 {
eric@42 515 transpose (src);
eric@42 516 flip_v (src);
eric@42 517 }