diff options
| author | Po Lu | 2022-02-17 12:35:39 +0000 |
|---|---|---|
| committer | Po Lu | 2022-02-17 12:36:50 +0000 |
| commit | 7e6fa8ed385a9fc096f037bcea17c18220fa69f1 (patch) | |
| tree | ab433f1768599fbfba9917f1ce886248becd852b /src | |
| parent | c218660d66394ba8306d21dcc182b82b15ba42de (diff) | |
| download | emacs-7e6fa8ed385a9fc096f037bcea17c18220fa69f1.tar.gz emacs-7e6fa8ed385a9fc096f037bcea17c18220fa69f1.zip | |
Implement XBM images on Haiku
* src/image.c (image_create_bitmap_from_data): Handle allocation
failures on Haiku.
(Create_Pixmap_From_Bitmap_Data): Implement for Haiku.
Diffstat (limited to 'src')
| -rw-r--r-- | src/image.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/image.c b/src/image.c index 3c521e413a9..e5113269356 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -543,6 +543,10 @@ image_create_bitmap_from_data (struct frame *f, char *bits, | |||
| 543 | 543 | ||
| 544 | #ifdef HAVE_HAIKU | 544 | #ifdef HAVE_HAIKU |
| 545 | void *bitmap = BBitmap_new (width, height, 1); | 545 | void *bitmap = BBitmap_new (width, height, 1); |
| 546 | |||
| 547 | if (!bitmap) | ||
| 548 | return -1; | ||
| 549 | |||
| 546 | BBitmap_import_mono_bits (bitmap, bits, width, height); | 550 | BBitmap_import_mono_bits (bitmap, bits, width, height); |
| 547 | #endif | 551 | #endif |
| 548 | 552 | ||
| @@ -3815,6 +3819,21 @@ Create_Pixmap_From_Bitmap_Data (struct frame *f, struct image *img, char *data, | |||
| 3815 | convert_mono_to_color_image (f, img, fg, bg); | 3819 | convert_mono_to_color_image (f, img, fg, bg); |
| 3816 | #elif defined HAVE_NS | 3820 | #elif defined HAVE_NS |
| 3817 | img->pixmap = ns_image_from_XBM (data, img->width, img->height, fg, bg); | 3821 | img->pixmap = ns_image_from_XBM (data, img->width, img->height, fg, bg); |
| 3822 | #elif defined HAVE_HAIKU | ||
| 3823 | img->pixmap = BBitmap_new (img->width, img->height, 0); | ||
| 3824 | |||
| 3825 | if (img->pixmap) | ||
| 3826 | { | ||
| 3827 | int bytes_per_line = (img->width + 7) / 8; | ||
| 3828 | |||
| 3829 | for (int y = 0; y < img->height; y++) | ||
| 3830 | { | ||
| 3831 | for (int x = 0; x < img->width; x++) | ||
| 3832 | PUT_PIXEL (img->pixmap, x, y, | ||
| 3833 | (data[x / 8] >> (x % 8)) & 1 ? fg : bg); | ||
| 3834 | data += bytes_per_line; | ||
| 3835 | } | ||
| 3836 | } | ||
| 3818 | #endif | 3837 | #endif |
| 3819 | } | 3838 | } |
| 3820 | 3839 | ||
| @@ -3999,6 +4018,7 @@ xbm_load_image (struct frame *f, struct image *img, char *contents, char *end) | |||
| 3999 | 4018 | ||
| 4000 | rc = xbm_read_bitmap_data (f, contents, end, &img->width, &img->height, | 4019 | rc = xbm_read_bitmap_data (f, contents, end, &img->width, &img->height, |
| 4001 | &data, 0); | 4020 | &data, 0); |
| 4021 | |||
| 4002 | if (rc) | 4022 | if (rc) |
| 4003 | { | 4023 | { |
| 4004 | unsigned long foreground = img->face_foreground; | 4024 | unsigned long foreground = img->face_foreground; |