Commits

shuerhaaken committed 5509a79

start new image api

Comments (0)

Files changed (22)

bindings/c/taginfo_c.cc

     i->set_images(imgs, image_count);
 }
 
+
+char * taginfo_image_get_data(const TagInfo_Image * img, int * image_data_length) {
+    image_data_length = 0;
+    if(!img)
+        return NULL;
+    const Image *i = reinterpret_cast<const Image *>(img);
+    return i->get_data(*image_data_length);
+}
+
+TagInfo_ImageType taginfo_image_get_image_type(const TagInfo_Image * img) {
+    if(!img)
+        return TAG_INFO_IMAGE_TYPE_OTHER;
+    const Image *i = reinterpret_cast<const Image *>(img);
+    return static_cast<TagInfo_ImageType>(i->get_image_type());
+}
+
 /*!
  * Frees a TagInfo_Image object.
  */

bindings/c/taginfo_c.h

 void taginfo_info_set_images(TagInfo_Info *info,
                              const TagInfo_Image ** images,
                              const int image_count);
+char * taginfo_image_get_data(const TagInfo_Image * image, int * image_data_length);
+
+TagInfo_ImageType taginfo_image_get_image_type(const TagInfo_Image * image);
+
 
 // LYRICS
 char * taginfo_info_get_lyrics(const TagInfo_Info *info);

libtaginfo/apetaginfo.cc

 }
 
 void extract_image(const APE::Item &image_item, Image *& image) {
-    image->image_file_type = IMAGE_FILE_TYPE_UNKNOWN;
-    image->description = NULL; // description not supported in APE tags!
+    image->set_image_file_type(IMAGE_FILE_TYPE_UNKNOWN);
+//    image->description = NULL; // description not supported in APE tags!
     if(image_item.type() == APE::Item::Binary) {
         ByteVector CoverData = image_item.binaryData();
         if(CoverData.size() > 0) {
-            image->data_length = CoverData.size();
-            image->data = new char[image->data_length];
-            memcpy(image->data, CoverData.data(), CoverData.size());
+            image->set_data(CoverData);
+//            image->data_length = CoverData.size();
+//            image->data = new char[image->data_length];
+//            memcpy(image->data, CoverData.data(), CoverData.size());
             return;
         }
     }
-    image->data = NULL;
-    image->data_length = 0;
+//    image->data = NULL;
+//    image->data_length = 0;
 }
 
 String image_type_to_ape_image_name(const ImageType& image_type) {
                    it->first == APE_TAG_COVER_ART_PUBLISHER_LOGO   ) {
                     image = new Image();
                     extract_image(it->second, image);
-                    if(image->data && image->data_length > 0) {
+//                    if(image->data && image->data_length > 0) {
                         String apetype = String(it->first);
-                        image->image_type = ape_image_type_to_image_type(apetype);
+                        image->set_image_type(ape_image_type_to_image_type(apetype));
                         imageList.prepend(image);
                         i++;
-                    }
-                    else {
-                        delete image;
-                    }
+//                    }
+//                    else {
+//                        delete image;
+//                    }
                }
             }
             if(0 < imageList.size()) {
         taglib_apetag->removeItem(APE_TAG_COVER_ART_PUBLISHER_LOGO);
         
         for(int p = 0; p < image_count; p++) {
-            if(!images[p]->data || images[p]->data_length == 0)
+cout << "sjdf 1" << endl;
+            if(images[p]->get_data().isEmpty())
                 continue;
-            
-            ByteVector ImgData = ByteVector((uint) images[p]->data_length);
-            memcpy(ImgData.data(), images[p]->data, images[p]->data_length);
+cout << "sjdf 2" << endl;
+            ByteVector image_vect(images[p]->get_data());
+//            memcpy(ImgData.data(), images[p]->data, images[p]->data_length);
             
             APE::Item imageItem = APE::Item();
             imageItem.setType(APE::Item::Binary);
-            String key = image_type_to_ape_image_name(images[p]->image_type);
+            String key = image_type_to_ape_image_name(images[p]->get_image_type());
             imageItem.setKey(key);
-            imageItem.setBinaryData(ImgData);
+            imageItem.setBinaryData(image_vect);
             taglib_apetag->setItem(key, imageItem);
         }
     }
     }
     return false;
 }
+

libtaginfo/asfinfo.cc

                     ByteVector pict_data = pict.picture();
                     Image * image = new Image();
                     if(pict_data.size() > 0) {
-                        image->data_length = pict_data.size();
-                        image->data = new char[image->data_length];
-                        memcpy(image->data, pict_data.data(), pict_data.size());
+                        image->set_data(pict_data);
+//                        image->data_length = pict_data.size();
+//                        image->data = new char[image->data_length];
+//                        memcpy(image->data, pict_data.data(), pict_data.size());
                         
                         String mimetype = pict.mimeType();
                         if(mimetype.find("/jpeg") != -1 || mimetype.find("/jpg") != -1)
-                            image->image_file_type = IMAGE_FILE_TYPE_JPEG;
+                            image->set_image_file_type(IMAGE_FILE_TYPE_JPEG);
                         else if(mimetype.find("/png") != -1)
-                            image->image_file_type = IMAGE_FILE_TYPE_PNG;
+                            image->set_image_file_type(IMAGE_FILE_TYPE_PNG);
                         else if(mimetype.find("/bmp") != -1)
-                            image->image_file_type = IMAGE_FILE_TYPE_BMP;
+                            image->set_image_file_type(IMAGE_FILE_TYPE_BMP);
                         else if(mimetype.find("/gif") != -1)
-                            image->image_file_type = IMAGE_FILE_TYPE_GIF;
+                            image->set_image_file_type(IMAGE_FILE_TYPE_GIF);
                         
-                        image->image_type  = get_image_type_from_pic_type(pict.type()); 
-                        const char * cstr = pict.description().toCString(false);
-                        if(cstr)
-                            image->description = ::strdup(cstr);
+                        image->set_image_type(get_image_type_from_pic_type(pict.type())); 
+//                        const char * cstr = pict.description().toCString(false);
+//                        if(cstr)
+//                            image->description = ::strdup(cstr);
+                        image->set_description(pict.description());
                         images[i] = image;
                         i--;
                     }
         
         for(int p = 0; p < image_count; p++) {
             const Image * image = images[p];
-            if(!image->data || image->data_length == 0)
+            if( image->get_data().isEmpty())
                 continue;
             ASF::Picture picture = ASF::Picture();
-            if(image->image_file_type == IMAGE_FILE_TYPE_JPEG || 
-               image->image_file_type == IMAGE_FILE_TYPE_UNKNOWN) //default to jpeg
+            if(image->get_image_file_type() == IMAGE_FILE_TYPE_JPEG || 
+               image->get_image_file_type() == IMAGE_FILE_TYPE_UNKNOWN) //default to jpeg
                 picture.setMimeType("image/jpeg");
-            else if(image->image_file_type == IMAGE_FILE_TYPE_PNG)
+            else if(image->get_image_file_type() == IMAGE_FILE_TYPE_PNG)
                 picture.setMimeType("image/png");
-            else if(image->image_file_type == IMAGE_FILE_TYPE_GIF)
+            else if(image->get_image_file_type() == IMAGE_FILE_TYPE_GIF)
                 picture.setMimeType("image/gif");
-            else if(image->image_file_type == IMAGE_FILE_TYPE_BMP)
+            else if(image->get_image_file_type() == IMAGE_FILE_TYPE_BMP)
                 picture.setMimeType("image/bmp");
             
-            ByteVector ImgData = ByteVector((uint) image->data_length);
-            memcpy(ImgData.data(), image->data, image->data_length);
-            if(image->description) {
-                String desc = String(image->description);
-                picture.setDescription(desc);
-            }
+            ByteVector ImgData(image->get_data());// = ;//ByteVector((uint) image->data_length);
+//            memcpy(ImgData.data(), image->data, image->data_length);
+//            if(image->description) {
+//                String desc = String(image->description);
+                picture.setDescription(image->get_description());
+//            }
             picture.setPicture(ImgData);
-            picture.setType(image_type_to_picture_type(image->image_type));
+            picture.setType(image_type_to_picture_type(image->get_image_type()));
             ASF::Attribute attr = ASF::Attribute(picture);
             asf_tag->addAttribute(PICTURE_FLAG, attr);
         }

libtaginfo/flacinfo.cc

             for(List<FLAC::Picture *>::Iterator it = plist.begin(); it != plist.end(); ++it) {
                 Image * image = new Image();
                 FLAC::Picture * p = (*it);
-                image->image_type = flac_image_type_to_image_type(p->type());
-                image->description = ::strdup(p->description().toCString(false));
-                image->data_length = p->data().size();
-                image->data = new char[image->data_length];
-                memcpy(image->data, p->data().data(), image->data_length);
-                if(image->data) {
+                image->set_image_type(flac_image_type_to_image_type(p->type()));
+                image->set_description(p->description());
+//                image->description = ::strdup(p->description().toCString(false));
+                image->set_data(p->data());
+//                image->data_length = p->data().size();
+//                image->data = new char[image->data_length];
+//                memcpy(image->data, p->data().data(), image->data_length);
+//                if(image->data) {
                     images[image_count] = image;
                     image_count++;
-                }
-                else {
-                    delete image;
-                }
+//                }
+//                else {
+//                    delete image;
+//                }
             }
             return images;
         }
         flac_file->removePictures();
         
         for(int p = 0; p < image_count; p++) {
-            if(!images[p]->data || images[p]->data_length == 0)
+            if(images[p]->get_data().isEmpty())
                 continue;
-            ByteVector vect((uint) images[p]->data_length);
-            memcpy(vect.data(), images[p]->data, images[p]->data_length);
+//            if(!images[p]->data || images[p]->data_length == 0)
+//                continue;
+            ByteVector vect(images[p]->get_data());//((uint) images[p]->data_length);
+//            memcpy(vect.data(), images[p]->data, images[p]->data_length);
             FLAC::Picture * picture = new FLAC::Picture();
             if(!picture) {
                 std::cout << "could not create picture" << std::endl;
                 continue;
             }
             picture->setData(vect);
-            if(images[p]->description) {
-                String desc(images[p]->description);
-                picture->setDescription(desc);
-            }
+//            if(images[p]->description) {
+//                String desc(images[p]->description);
+                picture->setDescription(images[p]->get_description());
+//            }
             picture->setMimeType("image/jpeg"); //TODO
-            picture->setType((FLAC::Picture::Type) images[p]->image_type);
+            picture->setType((FLAC::Picture::Type) images[p]->get_image_type());
             //std::cout << "pic size:" << picture->data().size() << std::endl;
             flac_file->addPicture(picture);
         }

libtaginfo/id3info.cc

         for(list<ID3v2::Frame*>::iterator iter = framelist.begin(); iter != framelist.end(); iter++) {
             pic_frame = static_cast<ID3v2::AttachedPictureFrame *>(*iter);
             Image * image = new Image();
-            image->image_type = get_image_type_from_pic_frame_type(pic_frame->type());
-            if(image) {
+            image->set_image_type(get_image_type_from_pic_frame_type(pic_frame->type()));
+//            if(image) {
                 if(pic_frame->picture().size() > 0) {
-                    image->data_length = pic_frame->picture().size();
-                    image->data = new char[image->data_length];
-                    memcpy(image->data, pic_frame->picture().data(), pic_frame->picture().size());
+                    image->set_data(pic_frame->picture());
+//                    image->data_length = pic_frame->picture().size();
+//                    image->data = new char[image->data_length];
+//                    memcpy(image->data, pic_frame->picture().data(), pic_frame->picture().size());
                     String mimetype = pic_frame->mimeType();
                     if(mimetype.find("/jpeg") != -1 || mimetype.find("/jpg") != -1)
-                        image->image_file_type = IMAGE_FILE_TYPE_JPEG;
+                        image->set_image_file_type(IMAGE_FILE_TYPE_JPEG);
                     else if(mimetype.find("/png") != -1)
-                        image->image_file_type = IMAGE_FILE_TYPE_PNG;
+                        image->set_image_file_type(IMAGE_FILE_TYPE_PNG);
                     else if(mimetype.find("/gif") != -1)
-                        image->image_file_type = IMAGE_FILE_TYPE_GIF;
+                        image->set_image_file_type(IMAGE_FILE_TYPE_GIF);
                     else if(mimetype.find("/bmp") != -1)
-                        image->image_file_type = IMAGE_FILE_TYPE_BMP;
-                    image->description = ::strdup(pic_frame->description().toCString(false));
+                        image->set_image_file_type(IMAGE_FILE_TYPE_BMP);
+                    image->set_description(pic_frame->description());// = ::strdup(pic_frame->description().toCString(false));
                 }
-                if(image->data && image->data_length > 0) {
+//                if(image->data && image->data_length > 0) {
                     images[i] = image;
                     i++;
-                }
-                else
-                    delete image;
-            }
+//                }
+//                else
+//                    delete image;
+//            }
         }
         image_count = i;
         return images;
         ID3v2::AttachedPictureFrame * PicFrame = NULL;
         ID3v2::FrameList frameList = taglib_tagId3v2->frameListMap()[IMAGES];
         for(int p = 0; p < image_count; p++) {
-            if(!images[p] || !images[p]->data || images[p]->data_length == 0)
+            if(images[p]->get_data().isEmpty())
                 continue;
+//            if(!images[p] || !images[p]->data || images[p]->data_length == 0)
+//                continue;
             
             for(list<ID3v2::Frame*>::iterator iter = frameList.begin(); iter != frameList.end(); iter++) {
                 PicFrame = static_cast<ID3v2::AttachedPictureFrame *>(*iter);
-                if((PicFrame->type() == image_type_to_picframetype(images[p]->image_type)))
+                if((PicFrame->type() == image_type_to_picframetype(images[p]->get_image_type())))
                     taglib_tagId3v2->removeFrame(PicFrame, true);
             }
             PicFrame = new ID3v2::AttachedPictureFrame;
-            if(images[p]->image_file_type == IMAGE_FILE_TYPE_JPEG || 
-               images[p]->image_file_type == IMAGE_FILE_TYPE_UNKNOWN) //default to jpeg
+            if(images[p]->get_image_file_type() == IMAGE_FILE_TYPE_JPEG || 
+               images[p]->get_image_file_type() == IMAGE_FILE_TYPE_UNKNOWN) //default to jpeg
                 PicFrame->setMimeType("image/jpeg");
-            else if(images[p]->image_file_type == IMAGE_FILE_TYPE_PNG)
+            else if(images[p]->get_image_file_type() == IMAGE_FILE_TYPE_PNG)
                 PicFrame->setMimeType("image/png");
-            else if(images[p]->image_file_type == IMAGE_FILE_TYPE_GIF)
+            else if(images[p]->get_image_file_type() == IMAGE_FILE_TYPE_GIF)
                 PicFrame->setMimeType("image/gif");
-            else if(images[p]->image_file_type == IMAGE_FILE_TYPE_BMP)
+            else if(images[p]->get_image_file_type() == IMAGE_FILE_TYPE_BMP)
                 PicFrame->setMimeType("image/bmp");
-            PicFrame->setType(image_type_to_picframetype(images[p]->image_type));
-            if(images[p]->description) {
-                String desc = String(::strdup(images[p]->description));
-                PicFrame->setDescription(desc);
-            }
-            ByteVector ImgData((uint) images[p]->data_length);
-            memcpy(ImgData.data(), images[p]->data, images[p]->data_length);
+            PicFrame->setType(image_type_to_picframetype(images[p]->get_image_type()));
+//            if(images[p]->description) {
+//                String desc = String(::strdup(images[p]->description));
+                PicFrame->setDescription(images[p]->get_description());
+//            }
+            ByteVector ImgData(images[p]->get_data());//((uint) images[p]->data_length);
+//            memcpy(ImgData.data(), images[p]->data, images[p]->data_length);
             PicFrame->setPicture(ImgData);
             taglib_tagId3v2->addFrame(PicFrame);
         }

libtaginfo/image.cc

 #include "taginfo_internal.h"
 
 
-
 using namespace TagInfo;
 
 
-
-// Image
-
 Image::Image() {
-    data            = NULL;
-    data_length     = 0;
     image_type      = IMAGE_TYPE_OTHER;
     image_file_type = IMAGE_FILE_TYPE_UNKNOWN;
-    description     = NULL;
+    description     = String::null;
 }
 
 Image::~Image() {
-//    if(data)
-        delete [] data;
-//    if(description)
-        delete [] description;
+}
+
+const ByteVector Image::get_data() const {
+    return bytes;
+}
+
+char * Image::get_data(int &image_data_length) const {
+    image_data_length = bytes.size();
+    char * idat;
+    memcpy(idat, bytes.data(), bytes.size());
+    return idat;
+}
+
+void Image::set_data(const ByteVector &image_data) {
+    bytes = image_data;
+}
+
+void Image::set_data(const char * image_data, const int image_data_length) {
+    ByteVector v(image_data, image_data_length);
+    bytes = v;
+}
+
+ImageType Image::get_image_type(void) const {
+    return image_type;
+}
+void Image::set_image_type(const ImageType it) {
+    image_type = it;
+}
+
+ImageFileType Image::get_image_file_type(void) const {
+    return image_file_type;
+}
+void Image::set_image_file_type(const ImageFileType ft) {
+    image_file_type = ft;
+}
+
+const String Image::get_description(void) const {
+    if(description == String::null)
+        return String();
+    return description;
+}
+void Image::set_description(const String &new_description) {
+    description = new_description;
 }
 
 

libtaginfo/mp4info.cc

             int i = 0;
             for(MP4::CoverArtList::Iterator it = covers.begin(); it != covers.end(); it++) {
                 image = new Image();
-                image->image_type = IMAGE_TYPE_OTHER;
-                image->data_length = it->data().size();
-                image->data = new char[image->data_length];
-                memcpy(image->data, it->data().data(), it->data().size());
-                image->image_file_type = get_image_file_type_from_format(it->format());
+                image->set_image_type(IMAGE_TYPE_OTHER);
+                image->set_data(it->data());
+//                image->data_length = it->data().size();
+//                image->data = new char[image->data_length];
+//                memcpy(image->data, it->data().data(), it->data().size());
+                image->set_image_file_type(get_image_file_type_from_format(it->format()));
                 
-                if(image->data && image->data_length > 0) {
-                    image->description = NULL;
+//                if(image->data && image->data_length > 0) {
+//                    image->description = NULL;
                     images[i] = image;
                     i++;
-                }
+//                }
             }
             image_count = i;
         }
         MP4::CoverArtList cover_list;
         for(int p = 0; p < image_count; p++) {
             const Image * image = images[p];
-            if(image->data && image->data_length > 0) {
-                ByteVector image_data((uint) image->data_length);
-                memcpy(image_data.data(), image->data, image->data_length);
-                MP4::CoverArt::Format format = get_format_from_image_file_type(image->image_file_type);
+            if(!image->get_data().isEmpty()) {
+                ByteVector image_data = image->get_data();//((uint) image->data_length);
+//                memcpy(image_data.data(), image->data, image->data_length);
+                MP4::CoverArt::Format format = get_format_from_image_file_type(image->get_image_file_type());
                 MP4::CoverArt cover(format, image_data);
                 cover_list.append(cover);
             }

libtaginfo/taginfo.h

 #ifndef TAGINFO_H
 #define TAGINFO_H
 
-#include "taginfo_image.h"
-
 #include <stdio.h>
 #include <string.h>
 
 #include <mp4tag.h>
 #include <xiphcomment.h>
 
+#include "taginfo_image.h"
+
 
 using namespace TagLib;
 using namespace std;
   */
 namespace TagInfo {
     
+    typedef TagLib::List<Image *> ImageList;
+    
     //! \enum MediaFileType describes the media file type
     /*! Enumerator for the type of the media file. */
     enum MediaFileType {

libtaginfo/taginfo_image.h

 
 #include "taginfo.h"
 
+using namespace TagLib;
+
 
 /** @file */
 
             */
             ~Image();
             
-            //! \a data is a pointer to the image data. NULL if not set
-            char *        data;
+            //! Get image binary data
+            //! \return ByteVector with binary data
+            const ByteVector get_data() const;
+            
+            //! Get image binary data
+            //! \param image_data_length is the return location for the length of the binary data array
+            //! \return Byte array with binary data
+            char * get_data(int &image_data_length) const;
+            
+            //! Set image binary data
+            //! \param image_data The Byte array with binary image data
+            //! \param image_data_length is the length of the binary image data array
+            void set_data(const char * image_data, const int image_data_length);
+            
+            //! Set image binary data
+            //! \param image_data ByteVector with binary image data
+            void set_data(const ByteVector &image_data);
+            
+            ImageType get_image_type(void) const;
+            void set_image_type(const ImageType it);
+            
+            ImageFileType get_image_file_type(void) const;
+            void set_image_file_type(const ImageFileType ft);
             
-            //! \a data_length is the length of the image data
-            long         data_length;
+            const String get_description(void) const;
+            void set_description(const String &description);
             
+        private:
+//            //! \a bytes the image binary data
+            ByteVector      bytes;
             //! \a image_type is the ImageType enum, giving information 
             //! on the content of the picture 
-            ImageType     image_type;
+            ImageType       image_type;
             
             //! \a image_file_type is the ImageFileType enum, giving 
             //! information on the file type of the embedded picture
-            ImageFileType image_file_type;
+            ImageFileType   image_file_type;
             
             //! The \a description gives extra information on the image
             //! (Not supported by all media tags). NULL if not set
-            char *        description;
+            String          description;
     };
 }
 

libtaginfo/xiphinfo.cc

             if(i < mimes_cnt) {
                 mimetype = pic_mimes[i];//.to8Bit(false); 
                 if(mimetype.find("/jpeg") != -1 || mimetype.find("/jpg") != -1)
-                    image->image_file_type = IMAGE_FILE_TYPE_JPEG;
+                    image->set_image_file_type(IMAGE_FILE_TYPE_JPEG);
                 else if(mimetype.find("/png") != -1)
-                    image->image_file_type = IMAGE_FILE_TYPE_PNG;
+                    image->set_image_file_type(IMAGE_FILE_TYPE_PNG);
                 else if(mimetype.find("/gif") != -1)
-                    image->image_file_type = IMAGE_FILE_TYPE_GIF;
+                    image->set_image_file_type(IMAGE_FILE_TYPE_GIF);
                 else if(mimetype.find("/bmp") != -1)
-                    image->image_file_type = IMAGE_FILE_TYPE_BMP;
+                    image->set_image_file_type(IMAGE_FILE_TYPE_BMP);
             }
             if(i < types_cnt) {
                 itype = pic_types[i];
-                image->image_type = (ImageType) atol(itype.toCString(false));
+                image->set_image_type((ImageType) atol(itype.toCString(false)));
             }
             if(i < descr_cnt) {
                 description = pic_descr[i];
-                image->description = ::strdup(description.toCString(false));
+                image->set_description(description);// = ::strdup(description.toCString(false));
             }
-            
             const char* CoverEncData = pics[i].toCString(false);
             
-            string CoverDecData = base64_decode(CoverEncData);
+            string CoverDecData = base64_decode(CoverEncData); /* STANDARD STRING !! */
             
-            image->data_length = CoverDecData.size();
-            image->data = new char[image->data_length];
-            memcpy(image->data, CoverDecData.data(), CoverDecData.size());
+            ByteVector bv(CoverDecData.data(), CoverDecData.size());
+            image->set_data(bv);
             
-            if(image->data && image->data_length > 0) {
+//            if(image->data && image->data_length > 0) {
                 images[i] = image;
                 image_count++;
-            }
-            else
-                delete image;
+//            }
+//            else
+//                delete image;
         }
         return images;
     }
         xiphcomment->removeField(COVERARTDESCRIPTION);
          for(int p = 0; p < image_count; p++) {
             const Image * image = images[p];
-            if(image && image->data && image->data_length > 0) {
-                if(image->image_file_type == IMAGE_FILE_TYPE_UNKNOWN || 
-                   image->image_file_type == IMAGE_FILE_TYPE_JPEG)
+            if(!image->get_data().isEmpty()) {
+                if(image->get_image_file_type() == IMAGE_FILE_TYPE_UNKNOWN || 
+                   image->get_image_file_type() == IMAGE_FILE_TYPE_JPEG)
                     xiphcomment->addField(COVERARTMIME, "image/jpeg", false);
-                else if(image->image_file_type == IMAGE_FILE_TYPE_PNG)
+                else if(image->get_image_file_type() == IMAGE_FILE_TYPE_PNG)
                     xiphcomment->addField(COVERARTMIME, "image/png", false);
-                else if(image->image_file_type == IMAGE_FILE_TYPE_GIF)
+                else if(image->get_image_file_type() == IMAGE_FILE_TYPE_GIF)
                     xiphcomment->addField(COVERARTMIME, "image/gif", false);
-                else if(image->image_file_type == IMAGE_FILE_TYPE_BMP)
+                else if(image->get_image_file_type() == IMAGE_FILE_TYPE_BMP)
                     xiphcomment->addField(COVERARTMIME, "image/bmp", false);
-                
+                String b64Encoded = base64encode(image->get_data().data(), image->get_data().size());
+//                cout << "64bitEncoded " << b64Encoded << endl;
                 xiphcomment->addField(COVERART, 
-                                      base64encode(image->data, image->data_length).toCString(false),
+                                      b64Encoded.toCString(false),
                                       false);
-                xiphcomment->addField(COVERARTTYPE, format("%d", (int)image->image_type), false);
+                xiphcomment->addField(COVERARTTYPE, format("%d", (int)image->get_image_type()), false);
                 
-                if(image->description) {
-                    const char* ds = ::strdup(image->description);
-                    String desc = String(ds);
-                    xiphcomment->addField(COVERARTDESCRIPTION, desc, false);
+                if(!image->get_description().isEmpty()) {
+//                    const char* ds = ::strdup(image->description);
+//                    String desc = String(ds);
+                    xiphcomment->addField(COVERARTDESCRIPTION, image->get_description(), false);
                 }
             }
         }

tests/write_image_ape/main.cc

     std::ifstream  src(val.c_str());
     std::ofstream  dst(target.c_str());
     dst << src.rdbuf();
-    //std::cout << "##1" << std::endl;
     Image * img = new Image();
-    img->image_file_type = IMAGE_FILE_TYPE_JPEG;
-    img->image_type      = IMAGE_TYPE_COVER_FRONT;
+    img->set_image_file_type(IMAGE_FILE_TYPE_JPEG);
+    img->set_image_type(IMAGE_TYPE_COVER_FRONT);
     // Image description not supported by APE
     
     Image * img2 = new Image();
-    img2->image_file_type = IMAGE_FILE_TYPE_JPEG;
-    img2->image_type      = IMAGE_TYPE_COVER_BACK;
+    img2->set_image_file_type(IMAGE_FILE_TYPE_JPEG);
+    img2->set_image_type(IMAGE_TYPE_COVER_BACK);
     // Image description not supported by APE
     
     struct stat filestatus;
     stat( image.c_str(), &filestatus );
     //cout << filestatus.st_size << " bytes\n";
-    img->data_length = filestatus.st_size;
-    img2->data_length = filestatus.st_size;
     int fd;
     
     fd = open(image.c_str(), O_RDONLY);
         perror("Error opening file for reading");
         EXIT_FAILURE;
     }
-    
-    img->data  = (char*)mmap(0, img->data_length, PROT_READ, MAP_SHARED, fd, 0);
-    img2->data = (char*)mmap(0, img2->data_length, PROT_READ, MAP_SHARED, fd, 0);
-    if(img->data == MAP_FAILED || img2->data == MAP_FAILED) {
-        close(fd);
-        perror("Error mmapping the file");
-        EXIT_FAILURE;
-    }
+    ByteVector vect = ByteVector((char*) mmap(0, filestatus.st_size, PROT_READ, MAP_SHARED, fd, 0), (uint)filestatus.st_size);
+    ByteVector vect2 = ByteVector((char*) mmap(0, filestatus.st_size, PROT_READ, MAP_SHARED, fd, 0), (uint)filestatus.st_size);
+    img->set_data(vect);
+    img2->set_data(vect2);
     
     info = Info::create(target);
     if(info) {
     delete info;
     info = NULL;
     
-    info = Info::create(target);
+   info = Info::create(target);
     Image * read_image;
     Image * read_image2;
     if(info) {
                     return EXIT_FAILURE;
                 }
             }
-            if(img->image_type != read_image->image_type) {
+            if(img->get_image_type() != read_image->get_image_type()) {
                 if(images)
                     delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-            if(read_image->description != NULL) {
+            if(img2->get_image_type() != read_image2->get_image_type()) {
                 if(images)
                     delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-            if(read_image2->description != NULL) {
+            int i;
+            if(img->get_data() != read_image->get_data()) {
                 if(images)
                     delete [] images;
-                if(read_image)
-                    delete read_image;
                 return EXIT_FAILURE;
             }
-            if(img2->image_type != read_image2->image_type) {
+            if(img2->get_data() != read_image2->get_data()) {
                 if(images)
                     delete [] images;
-                if(read_image)
-                    delete read_image;
                 return EXIT_FAILURE;
             }
-            int i;
-            for(i = 0; i<img->data_length; i++) {
-                if(img->data[i] != read_image->data[i]) {
-                    if(images)
-                        delete [] images;
-                    return EXIT_FAILURE;
-                }
-            }
-            for(i = 0; i<img2->data_length; i++) {
-                if(img2->data[i] != read_image2->data[i]) {
-                    if(images)
-                        delete [] images;
-                    return EXIT_FAILURE;
-                }
-            }
             if(images)
                 delete [] images;
             if(remove(target.c_str()) != 0 )
                 return EXIT_FAILURE;
             return EXIT_SUCCESS;
         }
-        delete info;
-        if(remove(target.c_str()) != 0 )
-            return EXIT_FAILURE;
-        return EXIT_FAILURE;
     }
-    else {
        delete info;
         if(remove(target.c_str()) != 0 )
             return EXIT_FAILURE;
         return EXIT_FAILURE;
-    }
-    return EXIT_FAILURE;
 }
 
 

tests/write_image_flac/main.cc

     dst << src.rdbuf();
     
     Image * img = new Image();
-    img->image_file_type = IMAGE_FILE_TYPE_JPEG;
-    img->image_type      = IMAGE_TYPE_COVER_FRONT;
-    img->description     = ::strdup(String("Bescräibunk").toCString(false));
+    img->set_image_file_type(IMAGE_FILE_TYPE_JPEG);
+    img->set_image_type(IMAGE_TYPE_COVER_FRONT);
+    img->set_description("Bescräibunk");
     
     Image * img2 = new Image();
-    img2->image_file_type = IMAGE_FILE_TYPE_JPEG;
-    img2->image_type      = IMAGE_TYPE_COVER_BACK;
-    img2->description     = ::strdup(String("Beßcräibunk").toCString(false));
+    img2->set_image_file_type(IMAGE_FILE_TYPE_JPEG);
+    img2->set_image_type(IMAGE_TYPE_COVER_BACK);
+    img2->set_description("Beßcräibunk");
 
     struct stat filestatus;
     stat( image.c_str(), &filestatus );
     //cout << filestatus.st_size << " bytes\n";
-    img->data_length = filestatus.st_size;
-    img2->data_length = filestatus.st_size;
+//    img->data_length = filestatus.st_size;
+//    img2->data_length = filestatus.st_size;
     int fd;
     
     fd = open(image.c_str(), O_RDONLY);
         perror("Error opening file for reading");
         EXIT_FAILURE;
     }
+    ByteVector vect = ByteVector((char*)mmap(0, filestatus.st_size, PROT_READ, MAP_SHARED, fd, 0), (uint)filestatus.st_size);
+    ByteVector vect2 = ByteVector((char*)mmap(0, filestatus.st_size, PROT_READ, MAP_SHARED, fd, 0), (uint)filestatus.st_size);
     
-    img->data  = (char*)mmap(0, img->data_length, PROT_READ, MAP_SHARED, fd, 0);
-    img2->data = (char*)mmap(0, img2->data_length, PROT_READ, MAP_SHARED, fd, 0);
-    if(img->data == MAP_FAILED || img2->data == MAP_FAILED) {
-        close(fd);
-        perror("Error mmapping the file");
-        EXIT_FAILURE;
-    }
+    img->set_data(vect);
+    img2->set_data(vect2);
+//    img->data  = (char*)mmap(0, img->data_length, PROT_READ, MAP_SHARED, fd, 0);
+//    img2->data = (char*)mmap(0, img2->data_length, PROT_READ, MAP_SHARED, fd, 0);
+//    if(img->data == MAP_FAILED || img2->data == MAP_FAILED) {
+//        close(fd);
+//        perror("Error mmapping the file");
+//        EXIT_FAILURE;
+//    }
     
     //std::cout <<  "++1 " << std::endl;
     info = Info::create(target);
                     return EXIT_FAILURE;
                 }
             }
-            if(img->image_type != read_image->image_type) {
+            if(img->get_image_type() != read_image->get_image_type()) {
                 if(images)
                     delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-            String st = String(read_image->description);
-            if(strcmp(img->description, st.toCString(false)) != 0) {
+//            String st = String(read_image->description);
+            if(img->get_description() != read_image->get_description()) {
                 if(images)
                     delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-            st = String(read_image2->description);
-            if(strcmp(img2->description, st.toCString(false)) != 0) {
+//            st = String(read_image2->description);
+            if(img2->get_description() != read_image2->get_description()) {
                 if(images)
                     delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-            if(img2->image_type != read_image2->image_type) {
+            if(img2->get_image_type() != read_image2->get_image_type()) {
                 if(images)
                     delete [] images;
                 if(read_image)
                 return EXIT_FAILURE;
             }
             int i;
-            for(i = 0; i<img->data_length; i++) {
-                if(img->data[i] != read_image->data[i]) {
+//            for(i = 0; i<img->data_length; i++) {
+//                if(img->data[i] != read_image->data[i]) {
+                if(img->get_data() != read_image->get_data()) {
                     if(images)
                         delete [] images;
                     return EXIT_FAILURE;
                 }
-            }
-            for(i = 0; i<img2->data_length; i++) {
-                if(img2->data[i] != read_image2->data[i]) {
+//            }
+//            for(i = 0; i<img2->data_length; i++) {
+//                if(img2->data[i] != read_image2->data[i]) {
+                if(img2->get_data() != read_image2->get_data()) {
                     if(images)
                         delete [] images;
                     return EXIT_FAILURE;
                 }
-            }
+//            }
             if(images)
                 delete [] images;
             if(remove(target.c_str()) != 0 )

tests/write_image_mp3/main.cc

     dst << src.rdbuf();
     
     Image * img = new Image();
-    img->image_file_type = IMAGE_FILE_TYPE_JPEG;
-    img->image_type      = IMAGE_TYPE_COVER_FRONT;
-    img->description     = ::strdup(String("Bescräibunk").toCString(false));
+    img->set_image_file_type(IMAGE_FILE_TYPE_JPEG);
+    img->set_image_type(IMAGE_TYPE_COVER_FRONT);
+    img->set_description("Bescräibunk");
     
     Image * img2 = new Image();
-    img2->image_file_type = IMAGE_FILE_TYPE_JPEG;
-    img2->image_type      = IMAGE_TYPE_COVER_BACK;
-    img2->description     = ::strdup(String("Beßcräibunk").toCString(false));
+    img2->set_image_file_type(IMAGE_FILE_TYPE_JPEG);
+    img2->set_image_type(IMAGE_TYPE_COVER_BACK);
+    img2->set_description("Beßcräibunk");
 
     struct stat filestatus;
     stat( image.c_str(), &filestatus );
     //cout << filestatus.st_size << " bytes\n";
-    img->data_length = filestatus.st_size;
-    img2->data_length = filestatus.st_size;
+//    img->data_length = filestatus.st_size;
+//    img2->data_length = filestatus.st_size;
     int fd;
     
     fd = open(image.c_str(), O_RDONLY);
         perror("Error opening file for reading");
         EXIT_FAILURE;
     }
+    ByteVector vect = ByteVector((char*)mmap(0, filestatus.st_size, PROT_READ, MAP_SHARED, fd, 0), (uint)filestatus.st_size);
+    ByteVector vect2 = ByteVector((char*)mmap(0, filestatus.st_size, PROT_READ, MAP_SHARED, fd, 0), (uint)filestatus.st_size);
     
-    img->data  = (char*)mmap(0, img->data_length, PROT_READ, MAP_SHARED, fd, 0);
-    img2->data = (char*)mmap(0, img2->data_length, PROT_READ, MAP_SHARED, fd, 0);
-    if(img->data == MAP_FAILED || img2->data == MAP_FAILED) {
-        close(fd);
-        perror("Error mmapping the file");
-        EXIT_FAILURE;
-    }
+    img->set_data(vect);
+    img2->set_data(vect2);
+//    img->data  = (char*)mmap(0, img->data_length, PROT_READ, MAP_SHARED, fd, 0);
+//    img2->data = (char*)mmap(0, img2->data_length, PROT_READ, MAP_SHARED, fd, 0);
+//    if(img->data == MAP_FAILED || img2->data == MAP_FAILED) {
+//        close(fd);
+//        perror("Error mmapping the file");
+//        EXIT_FAILURE;
+//    }
     
+    //std::cout <<  "++1 " << std::endl;
     info = Info::create(target);
     if(info) {
         Image ** imgs = new Image*[2];
                     return EXIT_FAILURE;
                 }
             }
-            if(img->image_type != read_image->image_type) {
+            if(img->get_image_type() != read_image->get_image_type()) {
                 if(images)
                     delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-            String st = String(read_image->description);
-            if(strcmp(img->description, st.toCString(false)) != 0) {
+//            String st = String(read_image->description);
+            if(img->get_description() != read_image->get_description()) {
                 if(images)
                     delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-            st = String(read_image2->description);
-            if(strcmp(img2->description, st.toCString(false)) != 0) {
+//            st = String(read_image2->description);
+            if(img2->get_description() != read_image2->get_description()) {
                 if(images)
                     delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-            if(img2->image_type != read_image2->image_type) {
+            if(img2->get_image_type() != read_image2->get_image_type()) {
                 if(images)
                     delete [] images;
                 if(read_image)
                 return EXIT_FAILURE;
             }
             int i;
-            for(i = 0; i<img->data_length; i++) {
-                if(img->data[i] != read_image->data[i]) {
+//            for(i = 0; i<img->data_length; i++) {
+//                if(img->data[i] != read_image->data[i]) {
+                if(img->get_data() != read_image->get_data()) {
                     if(images)
                         delete [] images;
                     return EXIT_FAILURE;
                 }
-            }
-            for(i = 0; i<img2->data_length; i++) {
-                if(img2->data[i] != read_image2->data[i]) {
+//            }
+//            for(i = 0; i<img2->data_length; i++) {
+//                if(img2->data[i] != read_image2->data[i]) {
+                if(img2->get_data() != read_image2->get_data()) {
                     if(images)
                         delete [] images;
                     return EXIT_FAILURE;
                 }
-            }
+//            }
             if(images)
                 delete [] images;
             if(remove(target.c_str()) != 0 )
     return EXIT_FAILURE;
 }
 
+

tests/write_image_mp4/main.cc

+
 #include "taginfo.h"
 #include <stdio.h>
 #include <iostream>
     dst << src.rdbuf();
     
     Image * img = new Image();
-    img->image_file_type = IMAGE_FILE_TYPE_JPEG;
-//    img->image_type      = IMAGE_TYPE_COVER_FRONT;
-//    img->description     = ::strdup(String("Bescräibunk").toCString(false));
+    img->set_image_file_type(IMAGE_FILE_TYPE_JPEG);
+//    img->set_image_type(IMAGE_TYPE_COVER_FRONT);
+//    img->set_description("Bescräibunk");
     
     Image * img2 = new Image();
-    img2->image_file_type = IMAGE_FILE_TYPE_JPEG;
-//    img2->image_type      = IMAGE_TYPE_COVER_BACK;
-//    img2->description     = ::strdup(String("Beßcräibunk").toCString(false));
+    img2->set_image_file_type(IMAGE_FILE_TYPE_JPEG);
+//    img2->set_image_type(IMAGE_TYPE_COVER_BACK);
+//    img2->set_description("Beßcräibunk");
 
     struct stat filestatus;
     stat( image.c_str(), &filestatus );
     //cout << filestatus.st_size << " bytes\n";
-    img->data_length = filestatus.st_size;
-    img2->data_length = filestatus.st_size;
+//    img->data_length = filestatus.st_size;
+//    img2->data_length = filestatus.st_size;
     int fd;
     
     fd = open(image.c_str(), O_RDONLY);
         perror("Error opening file for reading");
         EXIT_FAILURE;
     }
+    ByteVector vect = ByteVector((char*)mmap(0, filestatus.st_size, PROT_READ, MAP_SHARED, fd, 0), (uint)filestatus.st_size);
+    ByteVector vect2 = ByteVector((char*)mmap(0, filestatus.st_size, PROT_READ, MAP_SHARED, fd, 0), (uint)filestatus.st_size);
     
-    img->data  = (char*)mmap(0, img->data_length, PROT_READ, MAP_SHARED, fd, 0);
-    img2->data = (char*)mmap(0, img2->data_length, PROT_READ, MAP_SHARED, fd, 0);
-    if(img->data == MAP_FAILED || img2->data == MAP_FAILED) {
-        close(fd);
-        perror("Error mmapping the file");
-        EXIT_FAILURE;
-    }
+    img->set_data(vect);
+    img2->set_data(vect2);
+//    img->data  = (char*)mmap(0, img->data_length, PROT_READ, MAP_SHARED, fd, 0);
+//    img2->data = (char*)mmap(0, img2->data_length, PROT_READ, MAP_SHARED, fd, 0);
+//    if(img->data == MAP_FAILED || img2->data == MAP_FAILED) {
+//        close(fd);
+//        perror("Error mmapping the file");
+//        EXIT_FAILURE;
+//    }
     
+    //std::cout <<  "++1 " << std::endl;
     info = Info::create(target);
     if(info) {
         Image ** imgs = new Image*[2];
                     return EXIT_FAILURE;
                 }
             }
+//            if(img->get_image_type() != read_image->get_image_type()) {
+//                if(images)
+//                    delete [] images;
+//                if(read_image)
+//                    delete read_image;
+//                return EXIT_FAILURE;
+//            }
+//            String st = String(read_image->description);
+//            if(img->get_description() != read_image->get_description()) {
+//                if(images)
+//                    delete [] images;
+//                if(read_image)
+//                    delete read_image;
+//                return EXIT_FAILURE;
+//            }
+////            st = String(read_image2->description);
+//            if(img2->get_description() != read_image2->get_description()) {
+//                if(images)
+//                    delete [] images;
+//                if(read_image)
+//                    delete read_image;
+//                return EXIT_FAILURE;
+//            }
+//            if(img2->get_image_type() != read_image2->get_image_type()) {
+//                if(images)
+//                    delete [] images;
+//                if(read_image)
+//                    delete read_image;
+//                return EXIT_FAILURE;
+//            }
             int i;
-            for(i = 0; i<img->data_length; i++) {
-                if(img->data[i] != read_image->data[i]) {
+//            for(i = 0; i<img->data_length; i++) {
+//                if(img->data[i] != read_image->data[i]) {
+                if(img->get_data() != read_image->get_data()) {
                     if(images)
                         delete [] images;
                     return EXIT_FAILURE;
                 }
-            }
-            for(i = 0; i<img2->data_length; i++) {
-                if(img2->data[i] != read_image2->data[i]) {
+//            }
+//            for(i = 0; i<img2->data_length; i++) {
+//                if(img2->data[i] != read_image2->data[i]) {
+                if(img2->get_data() != read_image2->get_data()) {
                     if(images)
                         delete [] images;
                     return EXIT_FAILURE;
                 }
-            }
+//            }
             if(images)
                 delete [] images;
             if(remove(target.c_str()) != 0 )
 }
 
 
+
+

tests/write_image_mpc/main.cc

     dst << src.rdbuf();
     
     Image * img = new Image();
-    img->image_file_type = IMAGE_FILE_TYPE_JPEG;
-    img->image_type      = IMAGE_TYPE_COVER_FRONT;
+    img->set_image_file_type(IMAGE_FILE_TYPE_JPEG);
+    img->set_image_type(IMAGE_TYPE_COVER_FRONT);
     
     Image * img2 = new Image();
-    img2->image_file_type = IMAGE_FILE_TYPE_JPEG;
-    img2->image_type      = IMAGE_TYPE_COVER_BACK;
-    
+    img2->set_image_file_type(IMAGE_FILE_TYPE_JPEG);
+    img2->set_image_type(IMAGE_TYPE_COVER_BACK);
+
     struct stat filestatus;
     stat( image.c_str(), &filestatus );
     //cout << filestatus.st_size << " bytes\n";
-    img->data_length = filestatus.st_size;
-    img2->data_length = filestatus.st_size;
+//    img->data_length = filestatus.st_size;
+//    img2->data_length = filestatus.st_size;
     int fd;
     
     fd = open(image.c_str(), O_RDONLY);
         perror("Error opening file for reading");
         EXIT_FAILURE;
     }
+    ByteVector vect = ByteVector((char*)mmap(0, filestatus.st_size, PROT_READ, MAP_SHARED, fd, 0), (uint)filestatus.st_size);
+    ByteVector vect2 = ByteVector((char*)mmap(0, filestatus.st_size, PROT_READ, MAP_SHARED, fd, 0), (uint)filestatus.st_size);
     
-    img->data  = (char*)mmap(0, img->data_length, PROT_READ, MAP_SHARED, fd, 0);
-    img2->data = (char*)mmap(0, img2->data_length, PROT_READ, MAP_SHARED, fd, 0);
-    if(img->data == MAP_FAILED || img2->data == MAP_FAILED) {
-        close(fd);
-        perror("Error mmapping the file");
-        EXIT_FAILURE;
-    }
+    img->set_data(vect);
+    img2->set_data(vect2);
+//    img->data  = (char*)mmap(0, img->data_length, PROT_READ, MAP_SHARED, fd, 0);
+//    img2->data = (char*)mmap(0, img2->data_length, PROT_READ, MAP_SHARED, fd, 0);
+//    if(img->data == MAP_FAILED || img2->data == MAP_FAILED) {
+//        close(fd);
+//        perror("Error mmapping the file");
+//        EXIT_FAILURE;
+//    }
     
+    //std::cout <<  "++1 " << std::endl;
     info = Info::create(target);
     if(info) {
         Image ** imgs = new Image*[2];
                     return EXIT_FAILURE;
                 }
             }
-            if(img->image_type != read_image->image_type) {
+            if(img->get_image_type() != read_image->get_image_type()) {
                 if(images)
                     delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-            if(img2->image_type != read_image2->image_type) {
+            if(img2->get_image_type() != read_image2->get_image_type()) {
                 if(images)
                     delete [] images;
                 if(read_image)
                 return EXIT_FAILURE;
             }
             int i;
-            for(i = 0; i<img->data_length; i++) {
-                if(img->data[i] != read_image->data[i]) {
+//            for(i = 0; i<img->data_length; i++) {
+//                if(img->data[i] != read_image->data[i]) {
+                if(img->get_data() != read_image->get_data()) {
                     if(images)
                         delete [] images;
                     return EXIT_FAILURE;
                 }
-            }
-            for(i = 0; i<img2->data_length; i++) {
-                if(img2->data[i] != read_image2->data[i]) {
+//            }
+//            for(i = 0; i<img2->data_length; i++) {
+//                if(img2->data[i] != read_image2->data[i]) {
+                if(img2->get_data() != read_image2->get_data()) {
                     if(images)
                         delete [] images;
                     return EXIT_FAILURE;
                 }
-            }
+//            }
             if(images)
                 delete [] images;
             if(remove(target.c_str()) != 0 )

tests/write_image_ogg/main.cc

     Info * info;
     std::string val   = TESTDIR "samples/sample.ogg";
     std::string image = TESTDIR "samples/test.jpg";
-    
-    //std::cout << std::endl << "val: " << val << std::endl;
     std::string target = "/tmp/out_01.ogg";
-    //std::cout << "##1: " << std::endl;
+    
     std::ifstream  src(val.c_str());
     std::ofstream  dst(target.c_str());
     dst << src.rdbuf();
     
-
     Image * img = new Image();
-    img->image_file_type = IMAGE_FILE_TYPE_JPEG;
-    img->image_type      = IMAGE_TYPE_OTHER;
-    img->description     = ::strdup(String("Bescräibunk").toCString(false));
-
-    Image * img2 = new Image();
-    img2->image_file_type = IMAGE_FILE_TYPE_JPEG;
-    img2->image_type      = IMAGE_TYPE_COVER_FRONT;
-    img2->description     = ::strdup(String("Beßcräibunk").toCString(false));
+    img->set_image_file_type(IMAGE_FILE_TYPE_JPEG);
+    img->set_image_type(IMAGE_TYPE_COVER_FRONT);
+    img->set_description("Bescräibunk");
     
+    Image * img2 = new Image();
+    img2->set_image_file_type(IMAGE_FILE_TYPE_JPEG);
+    img2->set_image_type(IMAGE_TYPE_COVER_BACK);
+    img2->set_description("Beßcräibunk");
+
     struct stat filestatus;
     stat( image.c_str(), &filestatus );
     //cout << filestatus.st_size << " bytes\n";
-    img->data_length  = filestatus.st_size;
-    img2->data_length = filestatus.st_size;
+//    img->data_length = filestatus.st_size;
+//    img2->data_length = filestatus.st_size;
     int fd;
+    
     fd = open(image.c_str(), O_RDONLY);
     if (fd == -1) {
         perror("Error opening file for reading");
         EXIT_FAILURE;
     }
+    ByteVector vect = ByteVector((char*)mmap(0, filestatus.st_size, PROT_READ, MAP_SHARED, fd, 0), (uint)filestatus.st_size);
+    ByteVector vect2 = ByteVector((char*)mmap(0, filestatus.st_size, PROT_READ, MAP_SHARED, fd, 0), (uint)filestatus.st_size);
     
-    img->data = (char*)mmap(0, img->data_length, PROT_READ, MAP_SHARED, fd, 0);
-    img2->data = (char*)mmap(0, img2->data_length, PROT_READ, MAP_SHARED, fd, 0);
-    if(img->data == MAP_FAILED || img2->data == MAP_FAILED) {
-        close(fd);
-        perror("Error mmapping the file");
-        EXIT_FAILURE;
-    }
+    img->set_data(vect);
+    img2->set_data(vect2);
+//    img->data  = (char*)mmap(0, img->data_length, PROT_READ, MAP_SHARED, fd, 0);
+//    img2->data = (char*)mmap(0, img2->data_length, PROT_READ, MAP_SHARED, fd, 0);
+//    if(img->data == MAP_FAILED || img2->data == MAP_FAILED) {
+//        close(fd);
+//        perror("Error mmapping the file");
+//        EXIT_FAILURE;
+//    }
     
+std::cout <<  "++1 " << std::endl;
     info = Info::create(target);
     if(info) {
         Image ** imgs = new Image*[2];
         imgs[0] = img;
         imgs[1] = img2;
         info->set_images((const Image **)imgs, 2);
+        if(imgs)
+            delete [] imgs;
         info->save();
     }
     delete info;
     info = NULL;
     
+std::cout <<  "++2 " << std::endl;
     info = Info::create(target);
-    Image * read_image = NULL;
-    Image * read_image2 = NULL;
-    
+    Image * read_image;
+    Image * read_image2;
     if(info) {
+std::cout <<  "++3 " << std::endl;
         if(info->load()) {
             int len = 0;
+std::cout <<  "++4 " << std::endl;
             Image ** images = info->get_images(len);
-            if(!images || len != 2) {
+std::cout <<  "++5 " << std::endl;
+            if(!images) {
                 delete info;
                 if(remove(target.c_str()) != 0 ) {
                     return EXIT_FAILURE;
                 }
                 return EXIT_FAILURE;
             }
-            read_image = images[0];
+std::cout <<  "++6 " << std::endl;
+            read_image  = images[0];
             read_image2 = images[1];
             if(!images[0] || !read_image|| !read_image2) {
                 delete info;
                 if(remove(target.c_str()) != 0 ) {
-                    if(img)
-                        delete img;
-                    if(img2)
-                        delete img2;
+                    if(images)
+                        delete [] images;
                     return EXIT_FAILURE;
                 }
             }
-            int i;
-            if(img->image_type != read_image->image_type) {
+            if(img->get_image_type() != read_image->get_image_type()) {
                 if(images)
                     delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-            String st = String(read_image->description);
-            if(strcmp(img->description, st.toCString(false)) != 0) {
+//            String st = String(read_image->description);
+std::cout <<  "++7 " << std::endl;
+            if(img->get_description() != read_image->get_description()) {
                 if(images)
                     delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-            st = String(read_image2->description);
-            if(strcmp(img2->description, st.toCString(false)) != 0) {
+//            st = String(read_image2->description);
+            if(img2->get_description() != read_image2->get_description()) {
                 if(images)
                     delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-            if(img2->image_type != read_image2->image_type) {
+std::cout <<  "++8 " << std::endl;
+            if(img2->get_image_type() != read_image2->get_image_type()) {
                 if(images)
                     delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-            for(i = 0; i<img->data_length; i++) {
-                if(img->data[i] != read_image->data[i]) {
+std::cout <<  "++8.1 : " << img->get_data().size() << " " << read_image->get_data().size() << std::endl;
+std::cout <<  "++8.2 : " << img2->get_data().size() << " " << read_image2->get_data().size() << std::endl;
+            int i;
+//            for(i = 0; i<img->data_length; i++) {
+//                if(img->data[i] != read_image->data[i]) {
+                if(img->get_data() != read_image->get_data()) {
                     if(images)
                         delete [] images;
-                    if(read_image)
-                        delete read_image;
                     return EXIT_FAILURE;
                 }
-            }
-            for(i = 0; i<img2->data_length; i++) {
-                if(img2->data[i] != read_image->data[i]) {
+//            }
+//            for(i = 0; i<img2->data_length; i++) {
+//                if(img2->data[i] != read_image2->data[i]) {
+std::cout <<  "++9 " << std::endl;
+                if(img2->get_data() != read_image2->get_data()) {
                     if(images)
                         delete [] images;
-                    if(read_image2)
-                        delete read_image;
                     return EXIT_FAILURE;
                 }
-            }
+//            }
             if(images)
                 delete [] images;
             if(remove(target.c_str()) != 0 )
     return EXIT_FAILURE;
 }
 
+

tests/write_image_speex/main.cc

     std::string image = TESTDIR "samples/test.jpg";
     
     std::string target = "/tmp/out_01.spx";
-    //std::cout << "##1: " << std::endl;
+    
     std::ifstream  src(val.c_str());
     std::ofstream  dst(target.c_str());
     dst << src.rdbuf();
     
-
     Image * img = new Image();
-    img->image_file_type = IMAGE_FILE_TYPE_JPEG;
-    img->image_type      = IMAGE_TYPE_OTHER;
-    img->description     = ::strdup(String("Bescräibunk").toCString(false));
-
-    Image * img2 = new Image();
-    img2->image_file_type = IMAGE_FILE_TYPE_JPEG;
-    img2->image_type      = IMAGE_TYPE_COVER_FRONT;
-    img2->description     = ::strdup(String("Beßcräibunk").toCString(false));
+    img->set_image_file_type(IMAGE_FILE_TYPE_JPEG);
+    img->set_image_type(IMAGE_TYPE_COVER_FRONT);
+    img->set_description("Bescräibunk");
     
+    Image * img2 = new Image();
+    img2->set_image_file_type(IMAGE_FILE_TYPE_JPEG);
+    img2->set_image_type(IMAGE_TYPE_COVER_BACK);
+    img2->set_description("Beßcräibunk");
+
     struct stat filestatus;
     stat( image.c_str(), &filestatus );
     //cout << filestatus.st_size << " bytes\n";
-    img->data_length  = filestatus.st_size;
-    img2->data_length = filestatus.st_size;
+//    img->data_length = filestatus.st_size;
+//    img2->data_length = filestatus.st_size;
     int fd;
+    
     fd = open(image.c_str(), O_RDONLY);
     if (fd == -1) {
         perror("Error opening file for reading");
         EXIT_FAILURE;
     }
+    ByteVector vect = ByteVector((char*)mmap(0, filestatus.st_size, PROT_READ, MAP_SHARED, fd, 0), (uint)filestatus.st_size);
+    ByteVector vect2 = ByteVector((char*)mmap(0, filestatus.st_size, PROT_READ, MAP_SHARED, fd, 0), (uint)filestatus.st_size);
     
-    img->data = (char*)mmap(0, img->data_length, PROT_READ, MAP_SHARED, fd, 0);
-    img2->data = (char*)mmap(0, img2->data_length, PROT_READ, MAP_SHARED, fd, 0);
-    if(img->data == MAP_FAILED || img2->data == MAP_FAILED) {
-        close(fd);
-        perror("Error mmapping the file");
-        EXIT_FAILURE;
-    }
+    img->set_data(vect);
+    img2->set_data(vect2);
+//    img->data  = (char*)mmap(0, img->data_length, PROT_READ, MAP_SHARED, fd, 0);
+//    img2->data = (char*)mmap(0, img2->data_length, PROT_READ, MAP_SHARED, fd, 0);
+//    if(img->data == MAP_FAILED || img2->data == MAP_FAILED) {
+//        close(fd);
+//        perror("Error mmapping the file");
+//        EXIT_FAILURE;
+//    }
     
+    //std::cout <<  "++1 " << std::endl;
     info = Info::create(target);
     if(info) {
         Image ** imgs = new Image*[2];
         imgs[0] = img;
         imgs[1] = img2;
         info->set_images((const Image **)imgs, 2);
+        if(imgs)
+            delete [] imgs;
         info->save();
     }
     delete info;
     info = NULL;
     
     info = Info::create(target);
-    Image * read_image = NULL;
-    Image * read_image2 = NULL;
-    
+    Image * read_image;
+    Image * read_image2;
     if(info) {
         if(info->load()) {
             int len = 0;
             Image ** images = info->get_images(len);
-            if(!images || len != 2) {
+            if(!images) {
                 delete info;
                 if(remove(target.c_str()) != 0 ) {
                     return EXIT_FAILURE;
                 }
                 return EXIT_FAILURE;
             }
-            read_image = images[0];
+            read_image  = images[0];
             read_image2 = images[1];
             if(!images[0] || !read_image|| !read_image2) {
                 delete info;
                 if(remove(target.c_str()) != 0 ) {
-                    if(img)
-                        delete img;
-                    if(img2)
-                        delete img2;
+                    if(images)
+                        delete [] images;
                     return EXIT_FAILURE;
                 }
             }
-            int i;
-            if(img->image_type != read_image->image_type) {
+            if(img->get_image_type() != read_image->get_image_type()) {
                 if(images)
                     delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-            String st = String(read_image->description);
-            if(strcmp(img->description, st.toCString(false)) != 0) {
+//            String st = String(read_image->description);
+            if(img->get_description() != read_image->get_description()) {
                 if(images)
                     delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-            st = String(read_image2->description);
-            if(strcmp(img2->description, st.toCString(false)) != 0) {
+//            st = String(read_image2->description);
+            if(img2->get_description() != read_image2->get_description()) {
                 if(images)
                     delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-            if(img2->image_type != read_image2->image_type) {
+            if(img2->get_image_type() != read_image2->get_image_type()) {
                 if(images)
                     delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-            for(i = 0; i<img->data_length; i++) {
-                if(img->data[i] != read_image->data[i]) {
+            int i;
+//            for(i = 0; i<img->data_length; i++) {
+//                if(img->data[i] != read_image->data[i]) {
+                if(img->get_data() != read_image->get_data()) {
                     if(images)
                         delete [] images;
-                    if(read_image)
-                        delete read_image;
                     return EXIT_FAILURE;
                 }
-            }
-            for(i = 0; i<img2->data_length; i++) {
-                if(img2->data[i] != read_image->data[i]) {
+//            }
+//            for(i = 0; i<img2->data_length; i++) {
+//                if(img2->data[i] != read_image2->data[i]) {
+                if(img2->get_data() != read_image2->get_data()) {
                     if(images)
                         delete [] images;
-                    if(read_image2)
-                        delete read_image;
                     return EXIT_FAILURE;
                 }
-            }
+//            }
             if(images)
                 delete [] images;
             if(remove(target.c_str()) != 0 )

tests/write_image_tta/main.cc

     dst << src.rdbuf();
     
     Image * img = new Image();
-    img->image_file_type = IMAGE_FILE_TYPE_JPEG;
-    img->image_type      = IMAGE_TYPE_COVER_FRONT;
-    img->description     = ::strdup(String("Bescräibunk").toCString(false));
+    img->set_image_file_type(IMAGE_FILE_TYPE_JPEG);
+    img->set_image_type(IMAGE_TYPE_COVER_FRONT);
+    img->set_description("Bescräibunk");
     
     Image * img2 = new Image();
-    img2->image_file_type = IMAGE_FILE_TYPE_JPEG;
-    img2->image_type      = IMAGE_TYPE_COVER_BACK;
-    img2->description     = ::strdup(String("Beßcräibunk").toCString(false));
+    img2->set_image_file_type(IMAGE_FILE_TYPE_JPEG);
+    img2->set_image_type(IMAGE_TYPE_COVER_BACK);
+    img2->set_description("Beßcräibunk");
 
     struct stat filestatus;
     stat( image.c_str(), &filestatus );
     //cout << filestatus.st_size << " bytes\n";
-    img->data_length = filestatus.st_size;
-    img2->data_length = filestatus.st_size;
+//    img->data_length = filestatus.st_size;
+//    img2->data_length = filestatus.st_size;
     int fd;
     
     fd = open(image.c_str(), O_RDONLY);
         perror("Error opening file for reading");
         EXIT_FAILURE;
     }
+    ByteVector vect = ByteVector((char*)mmap(0, filestatus.st_size, PROT_READ, MAP_SHARED, fd, 0), (uint)filestatus.st_size);
+    ByteVector vect2 = ByteVector((char*)mmap(0, filestatus.st_size, PROT_READ, MAP_SHARED, fd, 0), (uint)filestatus.st_size);
     
-    img->data  = (char*)mmap(0, img->data_length, PROT_READ, MAP_SHARED, fd, 0);
-    img2->data = (char*)mmap(0, img2->data_length, PROT_READ, MAP_SHARED, fd, 0);
-    if(img->data == MAP_FAILED || img2->data == MAP_FAILED) {
-        close(fd);
-        perror("Error mmapping the file");
-        EXIT_FAILURE;
-    }
+    img->set_data(vect);
+    img2->set_data(vect2);
+//    img->data  = (char*)mmap(0, img->data_length, PROT_READ, MAP_SHARED, fd, 0);
+//    img2->data = (char*)mmap(0, img2->data_length, PROT_READ, MAP_SHARED, fd, 0);
+//    if(img->data == MAP_FAILED || img2->data == MAP_FAILED) {
+//        close(fd);
+//        perror("Error mmapping the file");
+//        EXIT_FAILURE;
+//    }
     
+    //std::cout <<  "++1 " << std::endl;
     info = Info::create(target);
     if(info) {
         Image ** imgs = new Image*[2];
                     return EXIT_FAILURE;
                 }
             }
-            if(img->image_type != read_image->image_type) {
+            if(img->get_image_type() != read_image->get_image_type()) {
                 if(images)
                     delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-            String st = String(read_image->description);
-            if(strcmp(img->description, st.toCString(false)) != 0) {
+//            String st = String(read_image->description);
+            if(img->get_description() != read_image->get_description()) {
                 if(images)
                     delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-            st = String(read_image2->description);
-            if(strcmp(img2->description, st.toCString(false)) != 0) {
+//            st = String(read_image2->description);
+            if(img2->get_description() != read_image2->get_description()) {
                 if(images)
                     delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-            if(img2->image_type != read_image2->image_type) {
+            if(img2->get_image_type() != read_image2->get_image_type()) {
                 if(images)
                     delete [] images;
                 if(read_image)
                 return EXIT_FAILURE;
             }
             int i;
-            for(i = 0; i<img->data_length; i++) {
-                if(img->data[i] != read_image->data[i]) {
+//            for(i = 0; i<img->data_length; i++) {
+//                if(img->data[i] != read_image->data[i]) {
+                if(img->get_data() != read_image->get_data()) {
                     if(images)
                         delete [] images;
                     return EXIT_FAILURE;
                 }
-            }
-            for(i = 0; i<img2->data_length; i++) {
-                if(img2->data[i] != read_image2->data[i]) {
+//            }
+//            for(i = 0; i<img2->data_length; i++) {
+//                if(img2->data[i] != read_image2->data[i]) {
+                if(img2->get_data() != read_image2->get_data()) {
                     if(images)
                         delete [] images;
                     return EXIT_FAILURE;
                 }
-            }
+//            }
             if(images)
                 delete [] images;
             if(remove(target.c_str()) != 0 )

tests/write_image_wav/main.cc

     dst << src.rdbuf();
     
     Image * img = new Image();
-    img->image_file_type = IMAGE_FILE_TYPE_JPEG;
-    img->image_type      = IMAGE_TYPE_COVER_FRONT;
-    img->description     = ::strdup(String("Bescräibunk").toCString(false));
+    img->set_image_file_type(IMAGE_FILE_TYPE_JPEG);
+    img->set_image_type(IMAGE_TYPE_COVER_FRONT);
+    img->set_description("Bescräibunk");
     
     Image * img2 = new Image();
-    img2->image_file_type = IMAGE_FILE_TYPE_JPEG;
-    img2->image_type      = IMAGE_TYPE_COVER_BACK;
-    img2->description     = ::strdup(String("Beßcräibunk").toCString(false));
+    img2->set_image_file_type(IMAGE_FILE_TYPE_JPEG);
+    img2->set_image_type(IMAGE_TYPE_COVER_BACK);
+    img2->set_description("Beßcräibunk");
 
     struct stat filestatus;
     stat( image.c_str(), &filestatus );
     //cout << filestatus.st_size << " bytes\n";
-    img->data_length = filestatus.st_size;
-    img2->data_length = filestatus.st_size;
+//    img->data_length = filestatus.st_size;
+//    img2->data_length = filestatus.st_size;
     int fd;
     
     fd = open(image.c_str(), O_RDONLY);
         perror("Error opening file for reading");
         EXIT_FAILURE;
     }
+    ByteVector vect = ByteVector((char*)mmap(0, filestatus.st_size, PROT_READ, MAP_SHARED, fd, 0), (uint)filestatus.st_size);
+    ByteVector vect2 = ByteVector((char*)mmap(0, filestatus.st_size, PROT_READ, MAP_SHARED, fd, 0), (uint)filestatus.st_size);
     
-    img->data  = (char*)mmap(0, img->data_length, PROT_READ, MAP_SHARED, fd, 0);
-    img2->data = (char*)mmap(0, img2->data_length, PROT_READ, MAP_SHARED, fd, 0);
-    if(img->data == MAP_FAILED || img2->data == MAP_FAILED) {
-        close(fd);
-        perror("Error mmapping the file");
-        EXIT_FAILURE;
-    }
+    img->set_data(vect);
+    img2->set_data(vect2);
+//    img->data  = (char*)mmap(0, img->data_length, PROT_READ, MAP_SHARED, fd, 0);
+//    img2->data = (char*)mmap(0, img2->data_length, PROT_READ, MAP_SHARED, fd, 0);
+//    if(img->data == MAP_FAILED || img2->data == MAP_FAILED) {
+//        close(fd);
+//        perror("Error mmapping the file");
+//        EXIT_FAILURE;
+//    }
     
+    //std::cout <<  "++1 " << std::endl;
     info = Info::create(target);
     if(info) {
         Image ** imgs = new Image*[2];
                     return EXIT_FAILURE;
                 }
             }
-            if(img->image_type != read_image->image_type) {
+            if(img->get_image_type() != read_image->get_image_type()) {
                 if(images)
                     delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-            String st = String(read_image->description);
-            if(strcmp(img->description, st.toCString(false)) != 0) {
+//            String st = String(read_image->description);
+            if(img->get_description() != read_image->get_description()) {
                 if(images)
                     delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-            st = String(read_image2->description);
-            if(strcmp(img2->description, st.toCString(false)) != 0) {
+//            st = String(read_image2->description);
+            if(img2->get_description() != read_image2->get_description()) {
                 if(images)
                     delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-            if(img2->image_type != read_image2->image_type) {
+            if(img2->get_image_type() != read_image2->get_image_type()) {
                 if(images)
                     delete [] images;
                 if(read_image)
                 return EXIT_FAILURE;
             }
             int i;
-            for(i = 0; i<img->data_length; i++) {
-                if(img->data[i] != read_image->data[i]) {
+//            for(i = 0; i<img->data_length; i++) {
+//                if(img->data[i] != read_image->data[i]) {
+                if(img->get_data() != read_image->get_data()) {
                     if(images)
                         delete [] images;
                     return EXIT_FAILURE;
                 }
-            }
-            for(i = 0; i<img2->data_length; i++) {
-                if(img2->data[i] != read_image2->data[i]) {
+//            }
+//            for(i = 0; i<img2->data_length; i++) {
+//                if(img2->data[i] != read_image2->data[i]) {
+                if(img2->get_data() != read_image2->get_data()) {
                     if(images)
                         delete [] images;
                     return EXIT_FAILURE;
                 }
-            }
+//            }
             if(images)
                 delete [] images;
             if(remove(target.c_str()) != 0 )

tests/write_image_wma/main.cc

     Info * info;
     std::string val   = TESTDIR "samples/sample.wma";
     std::string image = TESTDIR "samples/test.jpg";
-    
     std::string target = "/tmp/out_01.wma";
-    //std::cout << "##1: " << std::endl;
+    
     std::ifstream  src(val.c_str());
     std::ofstream  dst(target.c_str());
     dst << src.rdbuf();
     
-
     Image * img = new Image();
-    img->image_file_type = IMAGE_FILE_TYPE_JPEG;
-    img->image_type      = IMAGE_TYPE_ILLUSTRATION;
-    img->description     = ::strdup(String("Bescräibunk").toCString(false));
-
-    Image * img2 = new Image();
-    img2->image_file_type = IMAGE_FILE_TYPE_JPEG;
-    img2->image_type      = IMAGE_TYPE_COVER_FRONT;
-    img2->description     = ::strdup(String("Beßcräibunk").toCString(false));
+    img->set_image_file_type(IMAGE_FILE_TYPE_JPEG);
+    img->set_image_type(IMAGE_TYPE_COVER_FRONT);
+    img->set_description("Bescräibunk");
     
+    Image * img2 = new Image();
+    img2->set_image_file_type(IMAGE_FILE_TYPE_JPEG);
+    img2->set_image_type(IMAGE_TYPE_COVER_BACK);
+    img2->set_description("Beßcräibunk");
+
     struct stat filestatus;
     stat( image.c_str(), &filestatus );
     //cout << filestatus.st_size << " bytes\n";
-    img->data_length  = filestatus.st_size;
-    img2->data_length = filestatus.st_size;
+//    img->data_length = filestatus.st_size;
+//    img2->data_length = filestatus.st_size;
     int fd;
+    
     fd = open(image.c_str(), O_RDONLY);
     if (fd == -1) {
         perror("Error opening file for reading");
         EXIT_FAILURE;
     }
+    ByteVector vect = ByteVector((char*)mmap(0, filestatus.st_size, PROT_READ, MAP_SHARED, fd, 0), (uint)filestatus.st_size);
+    ByteVector vect2 = ByteVector((char*)mmap(0, filestatus.st_size, PROT_READ, MAP_SHARED, fd, 0), (uint)filestatus.st_size);
     
-    img->data = (char*)mmap(0, img->data_length, PROT_READ, MAP_SHARED, fd, 0);
-    img2->data = (char*)mmap(0, img2->data_length, PROT_READ, MAP_SHARED, fd, 0);
-    if(img->data == MAP_FAILED || img2->data == MAP_FAILED) {
-        close(fd);
-        perror("Error mmapping the file");
-        EXIT_FAILURE;
-    }
+    img->set_data(vect);
+    img2->set_data(vect2);
+//    img->data  = (char*)mmap(0, img->data_length, PROT_READ, MAP_SHARED, fd, 0);
+//    img2->data = (char*)mmap(0, img2->data_length, PROT_READ, MAP_SHARED, fd, 0);
+//    if(img->data == MAP_FAILED || img2->data == MAP_FAILED) {
+//        close(fd);
+//        perror("Error mmapping the file");
+//        EXIT_FAILURE;
+//    }
     
+    //std::cout <<  "++1 " << std::endl;
     info = Info::create(target);
     if(info) {
         Image ** imgs = new Image*[2];
         imgs[0] = img;
         imgs[1] = img2;
         info->set_images((const Image **)imgs, 2);
+        if(imgs)
+            delete [] imgs;
         info->save();
     }
     delete info;
     info = NULL;
     
     info = Info::create(target);
-    Image * read_image = NULL;
-    Image * read_image2 = NULL;
-    
+    Image * read_image;
+    Image * read_image2;
     if(info) {
         if(info->load()) {
             int len = 0;
             Image ** images = info->get_images(len);
-            if(!images || len != 2) {
+            if(!images) {
                 delete info;
                 if(remove(target.c_str()) != 0 ) {
                     return EXIT_FAILURE;
                 }
                 return EXIT_FAILURE;
             }
-            read_image = images[0];
+            read_image  = images[0];
             read_image2 = images[1];
             if(!images[0] || !read_image|| !read_image2) {
                 delete info;
                 if(remove(target.c_str()) != 0 ) {
-                    if(img)
-                        delete img;
-                    if(img2)
-                        delete img2;
+                    if(images)
+                        delete [] images;
                     return EXIT_FAILURE;
                 }
             }
-            int i;
-            if(img->image_type != read_image->image_type) {
+            if(img->get_image_type() != read_image->get_image_type()) {
                 if(images)
                     delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-            String st = String(read_image->description);
-            if(strcmp(img->description, st.toCString(false)) != 0) {
+//            String st = String(read_image->description);
+            if(img->get_description() != read_image->get_description()) {
                 if(images)
                     delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-            st = String(read_image2->description);
-            if(strcmp(img2->description, st.toCString(false)) != 0) {
+//            st = String(read_image2->description);
+            if(img2->get_description() != read_image2->get_description()) {
                 if(images)
                     delete [] images;
                 if(read_image)
                     delete read_image;
                 return EXIT_FAILURE;
             }
-            if(img2->image_type != read_image2->image_type) {
+            if(img2->get_image_type() != read_image2->get_image_type()) {
                 if(images)
                     delete [] images;
                 if(read_image)
                     delete read_image;