Changeset View
Changeset View
Standalone View
Standalone View
source/blender/imbuf/intern/bmp.c
| Show First 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | static int checkbmp(const uchar *mem) | ||||
| return (ret_val); | return (ret_val); | ||||
| } | } | ||||
| int imb_is_a_bmp(const uchar *buf) | int imb_is_a_bmp(const uchar *buf) | ||||
| { | { | ||||
| return checkbmp(buf); | return checkbmp(buf); | ||||
| } | } | ||||
| ImBuf *imb_bmp_decode(const uchar *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]) | ImBuf *imb_bmp_decode(const uchar *mem, | ||||
| size_t size, | |||||
| eImBufFlags flags, | |||||
| char colorspace[IM_MAX_SPACE]) | |||||
| { | { | ||||
| ImBuf *ibuf = NULL; | ImBuf *ibuf = NULL; | ||||
| BMPINFOHEADER bmi; | BMPINFOHEADER bmi; | ||||
| int x, y, depth, ibuf_depth, skip; | int x, y, depth, ibuf_depth, skip; | ||||
| const uchar *bmp; | const uchar *bmp; | ||||
| uchar *rect; | uchar *rect; | ||||
| ushort col; | ushort col; | ||||
| double xppm, yppm; | double xppm, yppm; | ||||
| ▲ Show 20 Lines • Show All 168 Lines • ▼ Show 20 Lines | |||||
| static int putShortLSB(ushort us, FILE *ofile) | static int putShortLSB(ushort us, FILE *ofile) | ||||
| { | { | ||||
| putc((us >> 0) & 0xFF, ofile); | putc((us >> 0) & 0xFF, ofile); | ||||
| return putc((us >> 8) & 0xFF, ofile); | return putc((us >> 8) & 0xFF, ofile); | ||||
| } | } | ||||
| /* Found write info at http://users.ece.gatech.edu/~slabaugh/personal/c/bitmapUnix.c */ | /* Found write info at http://users.ece.gatech.edu/~slabaugh/personal/c/bitmapUnix.c */ | ||||
| int imb_savebmp(ImBuf *ibuf, const char *name, int UNUSED(flags)) | int imb_savebmp(ImBuf *ibuf, const char *name, eImBufFlags UNUSED(flags)) | ||||
| { | { | ||||
| BMPINFOHEADER infoheader; | BMPINFOHEADER infoheader; | ||||
| const size_t bytes_per_pixel = (ibuf->planes + 7) >> 3; | const size_t bytes_per_pixel = (ibuf->planes + 7) >> 3; | ||||
| BLI_assert(bytes_per_pixel == 1 || bytes_per_pixel == 3); | BLI_assert(bytes_per_pixel == 1 || bytes_per_pixel == 3); | ||||
| const size_t pad_bytes_per_scanline = (4 - ibuf->x * bytes_per_pixel % 4) % 4; | const size_t pad_bytes_per_scanline = (4 - ibuf->x * bytes_per_pixel % 4) % 4; | ||||
| const size_t bytesize = (ibuf->x * bytes_per_pixel + pad_bytes_per_scanline) * ibuf->y; | const size_t bytesize = (ibuf->x * bytes_per_pixel + pad_bytes_per_scanline) * ibuf->y; | ||||
| ▲ Show 20 Lines • Show All 84 Lines • Show Last 20 Lines | |||||