/* This file is part of icobundle Copyright (C) 2003-7 Toby Thain, toby@telegraphics.com.au This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include "file_io.h" #include "ico.h" #include "ico_io.h" void bad(char *s){ fprintf(stderr,"## ERROR: %s\n",s); } int main(int argc,char *argv[]){ FILE *f; ICONDIR id; ICONDIRENTRY ide; BITMAPINFOHEADER bih; uint32_t pos,resbytes; int i; static const char* const typestr[] = {"ICON", "CURSOR"}; for(; ++argv, --argc;) if( (f = fopen(*argv,"r")) ){ puts(*argv); if(!read_icondir(f,&id)){ if(id.idType == IDTYPE_ICON || id.idType == IDTYPE_CUR) printf("idType = %d (%s)\n", id.idType, typestr[id.idType-1]); else fprintf(stderr,"## WARNING: idType = %d (should be 1 or 2)\n",id.idType); for(i = 0, pos = FIRST_ICONDIRENTRY; i < id.idCount; pos += SIZEOF_ICONDIRENTRY, ++i) if( !fseek(f,pos,SEEK_SET) && !read_icondirentry(f,&ide) ){ printf("ICONDIRENTRY[%2d] @%7d", i, ide.dwImageOffset); if( !fseek(f,ide.dwImageOffset,SEEK_SET) && !read_bitmapinfoheader(f,&bih) ){ if(bih.biSize == 0x474e5089) puts(" : PNG (Vista) format icon"); else{ printf(" : biWidth =%4d biHeight =%4d*2 biPlanes =%2d biBitCount =%3d biClrUsed =%4d\n", bih.biWidth,bih.biHeight/2,bih.biPlanes,bih.biBitCount,bih.biClrUsed); if(id.idType == IDTYPE_CUR) printf(" : xHotSpot =%4d yHotSpot =%4d\n", ide.xHotSpot, ide.yHotSpot); resbytes = SIZEOF_BMIHEADER + sizeof(RGBQUAD)*(bih.biBitCount>8 ? 0 : (1<