/* This file is part of icoformat, a Windows Icon (ICO) File Format plugin for Adobe Photoshop Copyright (C) 2002-2010 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 "ico.h" #include "ico_io.h" OSErr read_icondirentry(FILEREF f,LPICONDIRENTRY pide){ OSErr e; (e = read1 (f,&pide->bWidth)) // Width, in pixels, of the image || (e = read1 (f,&pide->bHeight)) // Height, in pixels, of the image || (e = read1 (f,&pide->bColorCount)) // Number of colors in image (0 if >=8bpp) || (e = read1 (f,&pide->bReserved)) // Reserved ( must be 0) || (e = read2L(f,(int16_t*)&pide->wPlanes)) // Color Planes || (e = read2L(f,(int16_t*)&pide->wBitCount)) // Bits per pixel || (e = read4L(f,(int32_t*)&pide->dwBytesInRes)) // How many bytes in this resource? || (e = read4L(f,(int32_t*)&pide->dwImageOffset)) ; // Where in the file is this image? return e; } OSErr write_icondirentry(FILEREF f,LPICONDIRENTRY pide){ OSErr e; (e = write1 (f,pide->bWidth)) // Width, in pixels, of the image || (e = write1 (f,pide->bHeight)) // Height, in pixels, of the image || (e = write1 (f,pide->bColorCount)) // Number of colors in image (0 if >=8bpp) || (e = write1 (f,pide->bReserved)) // Reserved ( must be 0) || (e = write2L(f,pide->wPlanes)) // Color Planes || (e = write2L(f,pide->wBitCount)) // Bits per pixel || (e = write4L(f,pide->dwBytesInRes)) // How many bytes in this resource? || (e = write4L(f,pide->dwImageOffset)) ; // Where in the file is this image? return e; } OSErr read_icondir(FILEREF f,LPICONDIR pid){ OSErr e; (e = read2L(f,(int16_t*)&pid->idReserved)) // Reserved (must be 0) || (e = read2L(f,(int16_t*)&pid->idType)) // Resource Type (1 for icons) || (e = read2L(f,(int16_t*)&pid->idCount)) ; // How many images? //ICONDIRENTRY idEntries[idCount]; // An entry for each image return e; } OSErr write_icondir(FILEREF f,LPICONDIR pid){ OSErr e; (e = write2L(f,pid->idReserved)) // Reserved (must be 0) || (e = write2L(f,pid->idType)) // Resource Type (1 for icons) || (e = write2L(f,pid->idCount)) ; // How many images? //ICONDIRENTRY idEntries[idCount]; // An entry for each image return e; } OSErr read_bitmapinfoheader(FILEREF f,BITMAPINFOHEADER *pbih){ OSErr e; (e = read4L(f,(int32_t*)&pbih->biSize)) || (e = read4L(f,&pbih->biWidth)) || (e = read4L(f,&pbih->biHeight)) || (e = read2L(f,(int16_t*)&pbih->biPlanes)) || (e = read2L(f,(int16_t*)&pbih->biBitCount)) || (e = read4L(f,(int32_t*)&pbih->biCompression)) || (e = read4L(f,(int32_t*)&pbih->biSizeImage)) || (e = read4L(f,&pbih->biXPelsPerMeter)) || (e = read4L(f,&pbih->biYPelsPerMeter)) || (e = read4L(f,(int32_t*)&pbih->biClrUsed)) || (e = read4L(f,(int32_t*)&pbih->biClrImportant)) ; return e; } OSErr write_bitmapinfoheader(FILEREF f,BITMAPINFOHEADER *pbih){ OSErr e; (e = write4L(f,pbih->biSize)) || (e = write4L(f,pbih->biWidth)) || (e = write4L(f,pbih->biHeight)) || (e = write2L(f,pbih->biPlanes)) || (e = write2L(f,pbih->biBitCount)) || (e = write4L(f,pbih->biCompression)) || (e = write4L(f,pbih->biSizeImage)) || (e = write4L(f,pbih->biXPelsPerMeter)) || (e = write4L(f,pbih->biYPelsPerMeter)) || (e = write4L(f,pbih->biClrUsed)) || (e = write4L(f,pbih->biClrImportant)) ; return e; }