Artifact f57b604e946969c4ea65e82c353a0d99e265807d:
- File
format/read-bmp.crimp
— part of check-in
[fc7e925cfb]
at
2011-08-23 03:30:01
on branch image-io-experiments
— Bugfixes in the core IO support (mostly off by one), and extended with
function to align, relative to a base location.
Plus fixes in the BMP reader: Bad return value, and data alignment when decoding pixel data is relative to the base location. Error messages modified to uniquely identify each location and problem. (user: andreask size: 864) [more...]
read::bmp Tcl_Obj* bmpdata #include "bmp.h" /* * Reader for images in BMP format (Window's BitMap Image File). * See http://en.wikipedia.org/wiki/BMP_file_format * Original code derived from TkImg bmp/bmp.c, modified to suit (no Tk!). */ crimp_buffer buf; bmp_info bmp; crimp_image* result; /* * Check input, i.e. verify structure and extract dimensions */ crimp_buf_init (&buf, bmpdata); if (!bmp_read_header (interp, &buf, &bmp)) { return TCL_ERROR; } result = crimp_new_rgb (bmp.w, bmp.h); if (!bmp_read_pixels (&bmp, result)) { Tcl_SetResult (interp, "Bad BMP image (Pixel decode failure)", TCL_STATIC); return TCL_ERROR; } Tcl_SetObjResult(interp, crimp_new_image_obj (result)); return TCL_OK; /* vim: set sts=4 sw=4 tw=80 et ft=c: */ /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */