Changeset View
Changeset View
Standalone View
Standalone View
source/blender/imbuf/intern/jp2.c
| Show First 20 Lines • Show All 307 Lines • ▼ Show 20 Lines | |||||
| static ImBuf *imb_load_jp2_stream(opj_stream_t *stream, | static ImBuf *imb_load_jp2_stream(opj_stream_t *stream, | ||||
| OPJ_CODEC_FORMAT p_format, | OPJ_CODEC_FORMAT p_format, | ||||
| int flags, | int flags, | ||||
| char colorspace[IM_MAX_SPACE]); | char colorspace[IM_MAX_SPACE]); | ||||
| ImBuf *imb_load_jp2(const unsigned char *mem, | ImBuf *imb_load_jp2(const unsigned char *mem, | ||||
| size_t size, | size_t size, | ||||
| int flags, | eImBufFlags flags, | ||||
| char colorspace[IM_MAX_SPACE]) | char colorspace[IM_MAX_SPACE]) | ||||
| { | { | ||||
| const OPJ_CODEC_FORMAT format = (size > JP2_FILEHEADER_SIZE) ? format_from_header(mem) : | const OPJ_CODEC_FORMAT format = (size > JP2_FILEHEADER_SIZE) ? format_from_header(mem) : | ||||
| OPJ_CODEC_UNKNOWN; | OPJ_CODEC_UNKNOWN; | ||||
| struct BufInfo buf_wrapper = { | struct BufInfo buf_wrapper = { | ||||
| .buf = mem, | .buf = mem, | ||||
| .cur = mem, | .cur = mem, | ||||
| .len = size, | .len = size, | ||||
| ▲ Show 20 Lines • Show All 865 Lines • ▼ Show 20 Lines | static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters) | ||||
| if (img_fol.rates) { | if (img_fol.rates) { | ||||
| MEM_freeN(img_fol.rates); | MEM_freeN(img_fol.rates); | ||||
| } | } | ||||
| return image; | return image; | ||||
| } | } | ||||
| int imb_save_jp2_stream(struct ImBuf *ibuf, opj_stream_t *stream, int flags); | int imb_save_jp2_stream(struct ImBuf *ibuf, opj_stream_t *stream, eImBufFlags flags); | ||||
| int imb_save_jp2(struct ImBuf *ibuf, const char *filepath, int flags) | int imb_save_jp2(struct ImBuf *ibuf, const char *filepath, eImBufFlags flags) | ||||
| { | { | ||||
| opj_stream_t *stream = opj_stream_create_from_file( | opj_stream_t *stream = opj_stream_create_from_file( | ||||
| filepath, OPJ_J2K_STREAM_CHUNK_SIZE, false, NULL); | filepath, OPJ_J2K_STREAM_CHUNK_SIZE, false, NULL); | ||||
| if (stream == NULL) { | if (stream == NULL) { | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| int ret = imb_save_jp2_stream(ibuf, stream, flags); | int ret = imb_save_jp2_stream(ibuf, stream, flags); | ||||
| opj_stream_destroy(stream); | opj_stream_destroy(stream); | ||||
| return ret; | return ret; | ||||
| } | } | ||||
| /* 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_save_jp2_stream(struct ImBuf *ibuf, opj_stream_t *stream, int UNUSED(flags)) | int imb_save_jp2_stream(struct ImBuf *ibuf, opj_stream_t *stream, eImBufFlags UNUSED(flags)) | ||||
| { | { | ||||
| int quality = ibuf->foptions.quality; | int quality = ibuf->foptions.quality; | ||||
| opj_cparameters_t parameters; /* compression parameters */ | opj_cparameters_t parameters; /* compression parameters */ | ||||
| opj_image_t *image = NULL; | opj_image_t *image = NULL; | ||||
| /* set encoding parameters to default values */ | /* set encoding parameters to default values */ | ||||
| opj_set_default_encoder_parameters(¶meters); | opj_set_default_encoder_parameters(¶meters); | ||||
| ▲ Show 20 Lines • Show All 68 Lines • Show Last 20 Lines | |||||