Changeset View
Changeset View
Standalone View
Standalone View
source/blender/imbuf/intern/jpeg.c
| Show All 34 Lines | |||||
| #include <stdio.h> | #include <stdio.h> | ||||
| #include <setjmp.h> | #include <setjmp.h> | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "BLI_string.h" | #include "BLI_string.h" | ||||
| #include "BLI_fileops.h" | #include "BLI_fileops.h" | ||||
| #include "BKE_idprop.h" | |||||
| #include "imbuf.h" | #include "imbuf.h" | ||||
| #include "IMB_imbuf_types.h" | #include "IMB_imbuf_types.h" | ||||
| #include "IMB_imbuf.h" | #include "IMB_imbuf.h" | ||||
| #include "IMB_metadata.h" | #include "IMB_metadata.h" | ||||
| #include "IMB_filetype.h" | #include "IMB_filetype.h" | ||||
| #include "jpeglib.h" | #include "jpeglib.h" | ||||
| #include "jerror.h" | #include "jerror.h" | ||||
| ▲ Show 20 Lines • Show All 422 Lines • ▼ Show 20 Lines | |||||
| static void write_jpeg(struct jpeg_compress_struct *cinfo, struct ImBuf *ibuf) | static void write_jpeg(struct jpeg_compress_struct *cinfo, struct ImBuf *ibuf) | ||||
| { | { | ||||
| JSAMPLE *buffer = NULL; | JSAMPLE *buffer = NULL; | ||||
| JSAMPROW row_pointer[1]; | JSAMPROW row_pointer[1]; | ||||
| uchar *rect; | uchar *rect; | ||||
| int x, y; | int x, y; | ||||
| char neogeo[128]; | char neogeo[128]; | ||||
| ImMetaData *iptr; | |||||
| char *text; | char *text; | ||||
| jpeg_start_compress(cinfo, true); | jpeg_start_compress(cinfo, true); | ||||
| strcpy(neogeo, "NeoGeo"); | strcpy(neogeo, "NeoGeo"); | ||||
| ibuf_ftype = BIG_LONG(ibuf->ftype); | ibuf_ftype = BIG_LONG(ibuf->ftype); | ||||
| memcpy(neogeo + 6, &ibuf_ftype, 4); | memcpy(neogeo + 6, &ibuf_ftype, 4); | ||||
| jpeg_write_marker(cinfo, 0xe1, (JOCTET *) neogeo, 10); | jpeg_write_marker(cinfo, 0xe1, (JOCTET *) neogeo, 10); | ||||
| if (ibuf->metadata) { | if (ibuf->metadata) { | ||||
| IDProperty *prop; | |||||
| /* key + max value + "Blender" */ | /* key + max value + "Blender" */ | ||||
| text = MEM_mallocN(530, "stamp info read"); | text = MEM_mallocN(530, "stamp info read"); | ||||
| iptr = ibuf->metadata; | for (prop = ibuf->metadata->data.group.first; prop; prop = prop->next) { | ||||
| while (iptr) { | if (prop->type == IDP_STRING) { | ||||
| if (!strcmp(iptr->key, "None")) { | int text_len; | ||||
| jpeg_write_marker(cinfo, JPEG_COM, (JOCTET *) iptr->value, strlen(iptr->value) + 1); | if (!strcmp(prop->name, "None")) { | ||||
| goto next_stamp_info; | jpeg_write_marker(cinfo, JPEG_COM, (JOCTET *) IDP_String(prop), prop->len + 1); | ||||
| } | } | ||||
| /* | /* | ||||
| * The JPEG format don't support a pair "key/value" | * The JPEG format don't support a pair "key/value" | ||||
| * like PNG, so we "encode" the stamp in a | * like PNG, so we "encode" the stamp in a | ||||
| * single string: | * single string: | ||||
| * "Blender:key:value" | * "Blender:key:value" | ||||
| * | * | ||||
| * The first "Blender" is a simple identify to help | * The first "Blender" is a simple identify to help | ||||
| * in the read process. | * in the read process. | ||||
| */ | */ | ||||
| sprintf(text, "Blender:%s:%s", iptr->key, iptr->value); | text_len = sprintf(text, "Blender:%s:%s", prop->name, IDP_String(prop)); | ||||
| jpeg_write_marker(cinfo, JPEG_COM, (JOCTET *) text, strlen(text) + 1); | jpeg_write_marker(cinfo, JPEG_COM, (JOCTET *) text, text_len + 1); | ||||
| next_stamp_info: | } | ||||
| iptr = iptr->next; | |||||
| } | } | ||||
| MEM_freeN(text); | MEM_freeN(text); | ||||
| } | } | ||||
| row_pointer[0] = | row_pointer[0] = | ||||
| MEM_mallocN(sizeof(JSAMPLE) * | MEM_mallocN(sizeof(JSAMPLE) * | ||||
| cinfo->input_components * | cinfo->input_components * | ||||
| cinfo->image_width, "jpeg row_pointer"); | cinfo->image_width, "jpeg row_pointer"); | ||||
| ▲ Show 20 Lines • Show All 238 Lines • Show Last 20 Lines | |||||