Library header. More...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Go to the source code of this file.
Defines | |
#define | LI_UNSELECTED 0 |
#define | LI_SELECTED 1 |
#define | LI_OUTPUT_XPM |
#define | LI_OUTPUT_PPM |
#define | LIBINFO_VERSION "1.2 Beta" |
#define | LIBINFO_DATE "03/02/2010" |
#define | LIBINFO_COPYRIGHT "Copyright (C) 2003-2010 Gary Harris <garyjharris@users.sourceforge.net>" |
Typedefs | |
typedef unsigned char | u8 |
typedef signed char | s8 |
typedef unsigned short | u16 |
typedef unsigned int | u32 |
Functions | |
int | LIReadDefIcon (const char *filename) |
Read images from a default icon. | |
int | LIReadNewIcon (const char *filename) |
Read images from a NewIcon. | |
void | LICleanUp (void) |
Release memory and clean up. | |
int | LISetXPMTransparency (int colour, int image) |
int | LIWriteXPM (char *filename, int image) |
Write icon image to XPM image. | |
void | LIGetMemoryXPM (char **xpm, int image) |
int | LIWritePPM (char *filename, int image) |
Write icon image to PPM image. | |
char * | LIGetVersion (void) |
char * | LIGetDate (void) |
char * | LIGetCopyright (void) |
Get the library copyright. | |
u16 | Get16 (u8 *p) |
u32 | Get32 (u8 *p) |
int | Read8 (u8 *buf, int len) |
int | ReadHeader (void) |
int | ReadIcon (int image) |
int | ReadNewicon (int image, char *name) |
u8 * | DecompressNewicon (u8 *src, char *name, int len, int bits) |
u8 * | ReadString () |
int | StartTooltypes () |
u8 * | GetTooltype (char *name) |
int | WriteXPM (char *filename, int width, int height, int ncols, u8 *palette, int image) |
void | GetMemoryXPM (char **amigaicon_xpm, int width, int height, int ncols, u8 *palette, int image) |
int | WritePPM (char *filename, int width, int height, int ncols, u8 *palette, int image) |
Variables | |
u8 * | LIBitmapUnselected |
u8 * | LIBitmapSelected |
u8 * | LIPaletteUnselected |
u8 * | LIPaletteSelected |
int | LIWidth |
int | LIHeight |
int | LINumColoursUnselected |
int | LINumColoursSelected |
char * | LIErrorString |
FILE * | fileIcon |
u16 | magic |
u16 | version |
u16 | type |
u32 | image1 |
u32 | image2 |
u32 | tool |
u32 | num_tooltypes |
Library header.
libinfo - a library to read Amiga icon files.
wxAmicon - An Amiga icon viewer. Copyright (C) 2010 Gary Harris <garyjharris@users.sourceforge.net>.
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 3 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, see <http://www.gnu.org/licenses/>.
libinfo recognizes the default Workbench and NewIcons formats.
libinfo is based on:
amicon: an Amiga icon to ppm/xpm convertor. Copyright 2001 Adam Sampson <ats@offog.org>
Definition in file libinfo.h.
void LICleanUp | ( | void | ) |
Release memory and clean up.
Release memory etc.
Definition at line 319 of file libinfo.c.
00320 { 00321 free(LIPaletteSelected); 00322 free(LIPaletteUnselected); 00323 free(LIBitmapSelected); 00324 free(LIBitmapUnselected); 00325 }
char* LIGetCopyright | ( | void | ) |
char* LIGetDate | ( | void | ) |
void LIGetMemoryXPM | ( | char ** | xpm, | |
int | image | |||
) |
Get an XPM image in memory.
xpm | - a pre-allocated char** to hold the XPM data. | |
image | - constant identifying the image to write. LI_UNSELECTED or LI_SELECTED. |
Definition at line 256 of file libinfo.c.
00257 { 00258 u8 *palette; 00259 int ncols; 00260 00261 if(image == LI_UNSELECTED){ 00262 palette = LIPaletteUnselected; 00263 ncols = LINumColoursUnselected; 00264 } 00265 else{ 00266 palette = LIPaletteSelected; 00267 ncols = LINumColoursSelected; 00268 } 00269 00270 GetMemoryXPM(xpm, LIWidth, LIHeight, ncols, palette, image); 00271 }
char* LIGetVersion | ( | void | ) |
int LIReadDefIcon | ( | const char * | filename | ) |
Read images from a default icon.
Get both default icons.
filename | - The path to the icon. |
Definition at line 78 of file libinfo.c.
00079 { 00080 if((fileIcon = fopen(filename, "rb")) == NULL){ 00081 LIErrorString = "Error opening input file."; 00082 return -1; 00083 } 00084 00085 /* Zero interface variables.*/ 00086 LIWidth = 0; 00087 LIHeight = 0; 00088 LINumColoursUnselected = 0; 00089 LINumColoursSelected = 0; 00090 00091 if(ReadHeader() == -1) 00092 return -1; 00093 if(ReadIcon(LI_UNSELECTED) == -1) 00094 return -1; 00095 if(image2) 00096 if(ReadIcon(LI_SELECTED) == -1) 00097 return -1; 00098 00099 fclose(fileIcon); 00100 return 0; 00101 }
int LIReadNewIcon | ( | const char * | filename | ) |
Read images from a NewIcon.
Get both NewIcons icons.
filename | - The path to the icon. |
Definition at line 122 of file libinfo.c.
00123 { 00124 int ret; 00125 00126 if((fileIcon = fopen(filename, "rb")) == NULL){ 00127 LIErrorString = "Error opening input file"; 00128 return -1; 00129 } 00130 00131 if(ReadHeader() == -1) 00132 return -1; 00133 if(ReadIcon(LI_UNSELECTED) == -1) 00134 return -1; 00135 if(image2) 00136 if(ReadIcon(LI_SELECTED) == -1) 00137 return -1; 00138 if(tool) 00139 free(ReadString()); 00140 if(StartTooltypes() == -1) 00141 return -1; 00142 00143 /* Zero interface variables.*/ 00144 LIWidth = 0; 00145 LIHeight = 0; 00146 LINumColoursUnselected = 0; 00147 LINumColoursSelected = 0; 00148 00149 ret = ReadNewicon(LI_UNSELECTED, "IM1="); 00150 if(ret == -2) 00151 /* Couldn't find unselected image. */ 00152 return -2; 00153 else if(ret == -1) 00154 return -1; 00155 ret = ReadNewicon(LI_SELECTED, "IM2="); 00156 if(ret == -2) 00157 /* Couldn't find selected image. */ 00158 return -3; 00159 else if(ret == -1) 00160 return -1; 00161 00162 fclose(fileIcon); 00163 return 0; 00164 }
int LISetXPMTransparency | ( | int | colour, | |
int | image | |||
) |
Set transparent colour for XPM output.
colour | - the colour to make transparent. |
Definition at line 180 of file libinfo.c.
00181 { 00182 int ncols; 00183 00184 if(image == LI_UNSELECTED){ 00185 ncols = LINumColoursUnselected; 00186 } 00187 else{ 00188 ncols = LINumColoursSelected; 00189 } 00190 00191 if(colour >= ncols){ 00192 LIErrorString = "Can't set colour transparency."; 00193 return -1; 00194 } 00195 transparent = colour; 00196 00197 return 0; 00198 }
int LIWritePPM | ( | char * | filename, | |
int | image | |||
) |
Write icon image to PPM image.
Write an image to an PPM file.
filename | - path to output image. | |
image | - constant identifying the image to write. LI_UNSELECTED or LI_SELECTED. |
Definition at line 290 of file libinfo.c.
00291 { 00292 u8 *palette; 00293 int ncols; 00294 00295 if(image == LI_UNSELECTED){ 00296 palette = LIPaletteUnselected; 00297 ncols = LINumColoursUnselected; 00298 } 00299 else{ 00300 palette = LIPaletteSelected; 00301 ncols = LINumColoursSelected; 00302 } 00303 00304 return WritePPM(filename, LIWidth, LIHeight, ncols, palette, image); 00305 }
int LIWriteXPM | ( | char * | filename, | |
int | image | |||
) |
Write icon image to XPM image.
Write an image to an XPM file.
filename | - path to output image. | |
image | - constant identifying the image to write. LI_UNSELECTED or LI_SELECTED. |
Definition at line 215 of file libinfo.c.
00216 { 00217 u8 *palette; 00218 int ncols; 00219 00220 if(image == LI_UNSELECTED){ 00221 palette = LIPaletteUnselected; 00222 ncols = LINumColoursUnselected; 00223 } 00224 else{ 00225 palette = LIPaletteSelected; 00226 ncols = LINumColoursSelected; 00227 } 00228 00229 return WriteXPM(filename, LIWidth, LIHeight, ncols, palette, image); 00230 }
u8* LIBitmapSelected |
char* LIErrorString |