[trunk] WIP: add a read CBD marker function (JPEG2000 part 2)
[openjpeg.git] / libopenjpeg / image.c
index a368c942c1eaf45c0951566ef2d520664b51e8a8..21a0f503d52f05b51a57dfc2cd1bf7bf6fc1b3d6 100644 (file)
@@ -31,11 +31,6 @@ opj_image_t* opj_image_create0(void) {
        return image;
 }
 
-opj_image_header_t* opj_image_header_create0(void) {
-       opj_image_header_t *image_header = (opj_image_header_t*)opj_calloc(1, sizeof(opj_image_header_t));
-       return image_header;
-}
-
 opj_image_t* OPJ_CALLCONV opj_image_create(int numcmpts, opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc) {
        int compno;
        opj_image_t *image = NULL;
@@ -75,32 +70,24 @@ opj_image_t* OPJ_CALLCONV opj_image_create(int numcmpts, opj_image_cmptparm_t *c
        return image;
 }
 
-// TODO remove this one
 void OPJ_CALLCONV opj_image_destroy(opj_image_t *image) {
-       int i;
        if(image) {
                if(image->comps) {
+                       OPJ_UINT32 compno;
                        /* image components */
-                       for(i = 0; i < image->numcomps; i++) {
-                               opj_image_comp_t *image_comp = &image->comps[i];
+                       for(compno = 0; compno < image->numcomps; compno++) {
+                               opj_image_comp_t *image_comp = &(image->comps[compno]);
                                if(image_comp->data) {
                                        opj_free(image_comp->data);
                                }
                        }
                        opj_free(image->comps);
                }
-               opj_free(image);
-       }
-}
-
 
-void OPJ_CALLCONV opj_image_header_destroy(opj_image_header_t *image) {
-       if(image) {
-               if(image->comps) {
-                       /* image components */
-                       opj_free(image->comps);
+               if(image->icc_profile_buf) {
+                       opj_free(image->icc_profile_buf);
                }
-               opj_free(image);
+               //FIXME opj_free(image);
        }
 }
 
@@ -110,12 +97,12 @@ void OPJ_CALLCONV opj_image_header_destroy(opj_image_header_t *image) {
  * @param p_image_header       the image header to update.
  * @param p_cp                         the coding parameters from which to update the image.
  */
-void opj_image_comp_header_update(opj_image_header_t * p_image_header, const opj_cp_v2_t * p_cp)
+void opj_image_comp_header_update(opj_image_t * p_image_header, const struct opj_cp_v2 * p_cp)
 {
        OPJ_UINT32 i, l_width, l_height;
        OPJ_INT32 l_x0, l_y0, l_x1, l_y1;
        OPJ_INT32 l_comp_x0, l_comp_y0, l_comp_x1, l_comp_y1;
-       opj_image_comp_header_t* l_img_comp = NULL;
+       opj_image_comp_t* l_img_comp = NULL;
 
        l_x0 = int_max(p_cp->tx0 , p_image_header->x0);
        l_y0 = int_max(p_cp->ty0 , p_image_header->y0);
@@ -132,9 +119,8 @@ void opj_image_comp_header_update(opj_image_header_t * p_image_header, const opj
                l_height = int_ceildivpow2(l_comp_y1 - l_comp_y0, l_img_comp->factor);
                l_img_comp->w = l_width;
                l_img_comp->h = l_height;
-               l_img_comp->x0 = l_x0;
-               l_img_comp->y0 = l_y0;
+               l_img_comp->x0 = l_comp_x0/*l_x0*/;
+               l_img_comp->y0 = l_comp_y0/*l_y0*/;
                ++l_img_comp;
        }
 }
-