From f7da340d0de3c6e4ab8bffdb7ef4d9969bec7993 Mon Sep 17 00:00:00 2001 From: scuri Date: Fri, 30 Apr 2010 18:06:28 +0000 Subject: Changed: ICON format now supports writing up to 10 images. --- html/en/history.html | 3 +++ include/im_format_all.h | 2 +- src/im_format_ico.cpp | 12 +++++++----- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/html/en/history.html b/html/en/history.html index 80446f5..1b815be 100644 --- a/html/en/history.html +++ b/html/en/history.html @@ -18,6 +18,9 @@ New: function imVideoCaptureReleaseDevices. +
  • + Changed: ICON format now supports + writing up to 10 images.
  • Version 3.6.1 (23/Apr/2010)

    diff --git a/include/im_format_all.h b/include/im_format_all.h index dc07886..3c8e9b4 100644 --- a/include/im_format_all.h +++ b/include/im_format_all.h @@ -498,7 +498,7 @@ void imFormatRegisterPNM(void); Color Spaces: RGB, MAP and Binary (Gray saved as MAP) Compressions: NONE - no compression [default] - Can have more than one image. But writing is limited to 5 images, + Can have more than one image. But reading and writing is limited to 10 images max, and all images must have different sizes and bpp. Can have an alpha channel (only for RGB) Internally the components are always packed. diff --git a/src/im_format_ico.cpp b/src/im_format_ico.cpp index b10f30e..7079952 100644 --- a/src/im_format_ico.cpp +++ b/src/im_format_ico.cpp @@ -2,7 +2,7 @@ * \brief ICO - Windows Icon * * See Copyright Notice in im_lib.h - * $Id: im_format_ico.cpp,v 1.2 2008/12/03 15:45:34 scuri Exp $ + * $Id: im_format_ico.cpp,v 1.3 2010/04/30 18:06:31 scuri Exp $ */ #include "im_format.h" @@ -49,11 +49,13 @@ static const char* iICOCompTable[1] = "NONE" }; +#define IMICON_MAX 10 + class imFileFormatICO: public imFileFormatBase { imBinFile* handle; /* the binary file handle */ unsigned short bpp; /* number of bits per pixel */ - unsigned int offset[10], + unsigned int offset[IMICON_MAX], next_offset; int line_raw_size; // raw line size @@ -134,7 +136,7 @@ int imFileFormatICO::Open(const char* file_name) /* reads the number of images */ imBinFileRead(handle, &word, 1, 2); - this->image_count = word > 10? 10: word; + this->image_count = word > IMICON_MAX? IMICON_MAX: word; strcpy(this->compression, "NONE"); for (int i = 0; i < this->image_count; i++) @@ -170,7 +172,7 @@ int imFileFormatICO::New(const char* file_name) imBinFileWrite(handle, &word_value, 1, 2); /* resource type */ imBinFileWrite(handle, &word_value, 1, 2); /* number of images, at least one, must update at close */ - this->next_offset = 6 + 5 * 16; // offset to the first image, room for 5 ICONDIRENTRY + this->next_offset = 6 + IMICON_MAX * 16; // offset to the first image, room for IMICON_MAX ICONDIRENTRY return IM_ERR_NONE; } @@ -285,7 +287,7 @@ int imFileFormatICO::WriteImageInfo() this->file_data_type = IM_BYTE; this->file_color_mode = imColorModeSpace(this->user_color_mode); - if (this->image_count == 5) + if (this->image_count == IMICON_MAX) return IM_ERR_DATA; if (this->width > 255 || this->height > 255) -- cgit v1.2.3