home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fred Fish Collection 1.5
/
ffcollection-1-5-1992-11.iso
/
ff_disks
/
200-299
/
ff223.lzh
/
IFFtoSUN
/
IFFtoSUN.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-06-25
|
28KB
|
970 lines
/* TITLE: IFF to Sun Raster Bitmap File Format. Version 1.31
by Richard Frost, © 1989.
If this is program is to be used for personal financial gain
PLEASE inform the author FIRST!
Please keep my name in this program, this is FREEWARE !!!
SOON TO BE SUBMITTED FOR INCLUSION ON THE FISH LIBRARY!!
(I hope !!)
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
WARNING: DO NOT attempt any file conversions into
RAM DISK or any normal disk until you
are sure that the disk has the space
to hold the converted images, else
the program will crash (I couldn't be
bothered checking for this) and you will
get a friendly visit from MR GURU!
HALFBRITE NOT SUPPORTED YET!!!!
NOTE: 640 X 400 images create files that are
over 256K long! (USE 1 MEG RAM or nearly
an empty disk!)
Expect even larger than this for PAL
(typically at most, say 704 X 512 ) images.
HAM images come out OK, as the colour choice
algorithm needs some tweaking!
Expect to see even faster conversions and better
colour choice in the next versions and maybe
HALFBRITE mode.
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
AUTHOR: Richard Frost,
Adelaide (The Grand Prix State)
South Australia,
Australia. (Yes that place DOWN-UNDER! NOT AUSTRIA!!!)
You can mail any messages to me (RICHARD FROST) on the
'ADAM-LINK' BBS (Located in Adelaide, South Australia)
Using the IFF routines 'Jiff.c' by
Jim Kent.
HISTORY:
- Started Version 1.0 7th February 1989.
- Version 1.0 WORKED FIRST TIME WITH NON-HAM images!!!
- HAM implementation 23rd February 1989.
- Aspect ratio correction for INTERLACE added 5th March 1989
- HAM finished 5th March 1989
- HAM checked on SUN 3/60 & working 6th March 1989
- HAM colour choice algorith improved (not completed yet)
BUGS: As with all programs their complexity hides all bugs!.
- Funny things happen to memory & Workbench when input files
hack up, ie LOTS of RAM NOT reallocated, an error in the
READ IFF routine???
THANKS: I must thank my friend ROBERT WOZNIAK for the idea
behind the extra 'map_to' field in the histogram entry,
which involved mapping ALL colours ONCE before the second
pass of the screen and thus using the histogram as a look-up
table. ROBERT'S very simple (yet INCREDIBLY EFFICIENT) idea
has improved the speed of my program incredibly.
Thanks Rob !! (You are famous too now!!)
I must also thank ALEX WAKEFIELD for his patience in porting
generated SUN rasterfiles over to the SUN 3/60, and then putting
up with DISK QUOTA errors on his SUN account !!
Once the AMIGA images got onto ETHERNET, boy did they travel
to other SUNS quick !!
The Electronics Arts people who decided that there
should be ONE, and ONLY ONE standard image format on the AMIGA,
IFF !!!
INFORMATION:
I hope you find this program as useful as I did. I did it mainly because
a friend of mine at university had access to a colour Sun 3/60. If you are
not aquainted with this computer, here are some juicy specs :
Resolution: 1152 X 900 (NON INTERLACED)
Colour Pallete: 16 million colours to choose from
Number of bitplanes: 8 ( means 256 on screen colours)
This means that you can view AMIGA INTERLACED pictures in their
NON-INTERLACED form on the Sun, plus you have a VERY high resolution
which gives some pictures a photographic-like quality, (ie. the IFF
picture .. 'Legends', 'Dusky Hopping Mouse', 'Tiger' etc. !!!).
Yes, this version DOES handle HAM pics, so now all those great HAM pics
out there can be ported to SUN Workstations!!!
NOTE: I went to some effort in optimising the colour choice algorithm
as some HAM pics have LOTS of distinct on-screen colours!
The classic HAM pic of an attractive lady's face holding a
pencil near her mouth has over 1300 distinct colours, from
this I had to choose a GOOD 256 palette for the SUN. My first
attempt was reasonable but the picture still had some very
obvious colour defects for a few pixels which needed improving.
I love the idea of STANDARDISATION !
Richard Frost.
Adelaide,
South Australia.
*/
/* NOTE: Full description of raster format omitted this time, in case of
copyright infringements with Sun Microsystems Inc. */
#include <exec/types.h>
#include <exec/nodes.h>
#include <exec/libraries.h>
#include <graphics/gfx.h>
#include <graphics/rastport.h>
#include <graphics/text.h>
#include <intuition/intuition.h>
#include <stdio.h>
#include <fcntl.h>
#include "jiff.h"
/* Sun TYPE definitions for it's own BITMAP FORMAT... */
/* each line of the image is rounded to 16 bits */
#define RAS_MAGIC 0x59a66a95 /* Don't ask me how they decided on this number! */
#define RT_STANDARD 1 /* Each scanline saved in 68000 order */
#define RMT_EQUAL_RGB 1 /* Means we are using the RGB colour table vectors */
#define RMT_NONE 0
#define RMT_RAW 8
/* colour macros .. */
/* macro for working out the distance between 2 colours */
#define colourval(r,g,b) ( ((int)(r) << 4) + (int)(g) + ((int)(b) >> 4))
#define col_dist(r,g,b,r2,g2,b2) ( ((r-r2)*(r-r2)) + \
((g-g2)*(g-g2)) + \
((b-b2)*(b-b2)) )
/* extract the SCALED R G B for the SUN */
/* ie. TOP nibble contains the 4bit value */
#define RED(col) ((unsigned char ) ((col & 0x0f00) >> 4))
#define GREEN(col) ((unsigned char ) (col & 0x00f0) )
#define BLUE(col) ((unsigned char ) ((col & 0x000f) << 4))
int NumCols, /* Number of distinct colours in the palette */
LaceFlag; /* internal flag to indicate INTERLACE PICS to other routines */
struct rasterfile
{
long ras_magic; /* Sun's Magic Number to identify the UNIX file type */
long ras_width; /* Width of the Raster to be displayed */
long ras_height; /* Height of the Raster to be displayed */
long ras_depth; /* Number of bitplanes: 1, 8 or 24 Bitpalnes! */
long ras_length; /* Total number of raster pixels = Width * Height */
long ras_type; /* The storage type of the Bitmap */
long ras_maptype; /* The type of the colour map used */
long ras_maplength; /* Total length (in bytes) of the colour map */
/* which is = 3 * (1 << #bitplanes ) */
} ;
struct rasterfile writerast;
/* An entry from the HISTOGRAM : */
typedef struct ent
{
long count ; /* Colour frequency */
unsigned char map_to ; /* Equivalent map position in the final 256 */
/* colour palette for the SUN */
} entry;
entry Histogram[4096] ; /* Histogram of ALL of the possible colours */
/* on the Amiga. */
struct node /* temporary Histogram which is sorted */
{
int colr;
long count;
unsigned char map_to;
} sortedHist[4096];
/* The SUN colour palette */
unsigned char col_RED[256], /* RED COMPONENTS OF THE PALLETE ENTRIES */
col_GREEN[256], /* GREEN COMPONENTS OF THE PALLETE ENTRIES */
col_BLUE[256]; /* BLUE COMPONENTS OF THE PALLETE ENTRIES */
extern struct Library *OpenLibrary(); /*This should be in exec/libraries.h */
extern struct Screen *OpenScreen(); /*This should be in intuition/intuition.h */
struct Library *GfxBase = NULL;
struct Library *LayersBase = NULL;
struct Library *IntuitionBase = NULL;
struct Screen *PlopScreen = NULL;
struct TextAttr PlopFont =
{
(UBYTE *)"topaz.font", /* I think this is the ROM font */
8,
0,
0,
};
static struct NewScreen PlopNewScreen =
{
0, 0, 0, 0, 0,
0, 1,
0,
CUSTOMSCREEN,
&PlopFont,
NULL,
NULL,
NULL,
};
struct RastPort PlopRastPort;
FILE *fd,*fopen(); /* filing devices */
unsigned short amy_cmap[MAXCOL];
/* Put_ea_cmap given an ea-type color map:
an array of unsigned chars of form ea_cmap[] = {r, g, b, r, g, b...}
turn it into an amiga-type color map:
an array of unsigned short of form amiga_cmap = {0xrgb, 0xrgb, ...}
and then tell Dale this is the colors we want for our viewport */
/* This routine will obtain the RGB colour of that x-y locn. in a HAM image */
/* NOTE: This routine assumes it is being called in order of all adjacent pixels
in a HAM image. It is NOT a general 'readpixel' for HAM!! */
int Next_Colour(x,y)
int x,y;
{
static unsigned char red,
green,
blue; /* previous pixel's RED GREEN & BLUE vals */
int col_bits, /* lower 4 bits are either the index to Amy palette */
/* or the NEW red,green or blue component */
acol,
val, /* current pixel's value */
control_bits; /* upper 2 bits are the control bits */
val = ReadPixel( &PlopScreen->RastPort,(long)x,(long)y) ;
control_bits = (val & 0x00f0) >> 4;
col_bits = val & 0x000f;
switch (control_bits)
{
/* normal addressing mode ... col_bits = index in Amy palette */
case 0 : acol = (int) amy_cmap[col_bits];
red = RED(acol); /* store away the RGB info */
green = GREEN(acol);
blue = BLUE(acol);
return(acol);
break;
/* col_bits represent the NEW BLUE register value of previous */
/* pixel's RGB colour. */
case 1 : blue = (unsigned char) (col_bits << 4);
return(colourval(red,green,blue));
break;
/* col_bits represent the NEW RED register value of previous */
/* pixel's RGB colour. */
case 2 : red = (unsigned char) (col_bits << 4);
return(colourval(red,green,blue));
break;
/* col_bits represent the NEW GREEN register value of previous */
/* pixel's RGB colour. */
case 3 : green = (unsigned char) (col_bits << 4);
return(colourval(red,green,blue));
break;
}
}
/* Write the Current Screen to a SUN raster file */
void write_rast(width,height,depth,x,y,cmap)
int width,height,depth,x,y;
unsigned char *cmap;
{
int i,
acol,
actual,numcols,
maxAmigaCols,
xmax,ymax;
long dep;
register int xpos,ypos;
unsigned char col;
actual = width;
if (width & 1) actual++;
/* check for the single bitplane case */
if (depth != 1)
{
numcols = 256; /* set 8 bitplanes */
dep = 8;
}
else
{
numcols = 2 ; /* else use 1 bitplane */
dep = 1;
}
writerast.ras_magic = RAS_MAGIC;
writerast.ras_width = (long) width;
writerast.ras_height = (long) height;
writerast.ras_depth = (long) dep;
writerast.ras_length = (long) width * height;
writerast.ras_type = (long) RT_STANDARD;
writerast.ras_maptype = (long) RMT_EQUAL_RGB;
writerast.ras_maplength = (long) (3 * numcols);
/* Fill the Sun colour map with RED GREEN BLUE components
from the AMIGA'S PALLETE.
*/
if (LaceFlag)
writerast.ras_width *= 2; /* twice the width if interlaced */
if (depth < 6)
{
maxAmigaCols = (1 << depth);
for (i = 0 ; i < numcols ; i++ )
{
if (i < maxAmigaCols)
{
col_RED[i] = cmap[0]; /* RED */
col_GREEN[i] = cmap[1]; /* GREEN */
col_BLUE[i] = cmap[2]; /* BLUE */
cmap += 3;
}
else
col_RED[i] = col_GREEN[i] = col_BLUE[i] = 0;
#ifdef CHECK
fprintf(stdout,"[%3u] R =%3u, G =%3u , B =%3u\n",i,
col_RED[i],col_GREEN[i],col_BLUE[i]);
#endif CHECK
}
}
/* Write out the header info .. */
fwrite(&writerast,sizeof(writerast),1,fd);
/* Write out the R,G, & B colour maps */
fwrite(col_RED,numcols,1,fd);
fwrite(col_GREEN,numcols,1,fd);
fwrite(col_BLUE,numcols,1,fd);
/* Begin writing out the actual bitmap ! */
SetAPen(&PlopScreen->RastPort,1);
SetDrMd(&PlopScreen->RastPort,COMPLEMENT);
ymax = height + y;
xmax = width + x ;
if (depth < 6)
{
fprintf(stdout,"Please wait, converting %d scanlines [see display] ... ",ymax);
fflush(stdout);
for (ypos = y ; ypos < ymax ; ypos++)
{
for (xpos = x ; xpos < xmax ; xpos++ )
{
/* I hope Commodore speed up WritePixel soon or I'll kill myself !!! */
col = ReadPixel( &PlopScreen->RastPort, (long) xpos, (long) ypos ) ;
WritePixel( &PlopScreen->RastPort,(long) xpos, (long) ypos ) ;
fputc(col,fd);
/* If the pic is interlaced then double the width */
/* have TWICE as many pixels per scanline */
if (LaceFlag)
fputc(col,fd);
}
}
fprintf(stdout,"Done.\n\n");
}
else /* Do the HAM case, scan the image ! */
{
fprintf(stdout,"Please wait, converting %d scanlines ... ",ymax);
fflush(stdout);
for (ypos = y; ypos < ymax ; ypos++)
{
for (xpos = x; xpos < xmax ; xpos++ )
{
/* get the next ACTUAL colour from the screen */
acol = Next_Colour(xpos,ypos);
/* write the Sun colour palette index to the file */
/* if the pic is interlaced then double the width */
/* have TWICE as many pixels per scanline */
fputc(Histogram[acol].map_to,fd);
if (LaceFlag)
fputc(Histogram[acol].map_to,fd);
}
}
fprintf(stdout,"Done.\n\n");
}
}
void put_ea_cmap(cmap, colors)
unsigned char *cmap;
int colors;
{
int i;
unsigned char r, g, b;
if (colors > MAXCOL) /*color clipping*/
colors = MAXCOL;
for (i=0; i<colors; i++)
{
amy_cmap[i] =
((cmap[0] & 0xf0) << 4) + (cmap[1] & 0xf0) + ((cmap[2] & 0xf0) >> 4);
cmap += 3;
}
LoadRGB4( &PlopScreen->ViewPort, amy_cmap, (long)colors);
}
/* back out backwards */
void plop_cleanup()
{
if (PlopScreen != NULL)
CloseScreen(PlopScreen);
if (IntuitionBase != NULL)
CloseLibrary(IntuitionBase);
if (LayersBase != NULL)
CloseLibrary(LayersBase);
if (GfxBase != NULL)
CloseLibrary(GfxBase);
}
/* This procedure will build up a histogram of all the colours */
/* used in a particular HAM image. */
void make_histogram(width,height)
int width,height;
{
int xmax,ymax,
col,
xpos,ypos;
/* set up the drawing pen mode & colour .. */
SetAPen(&PlopScreen->RastPort,1);
SetDrMd(&PlopScreen->RastPort,COMPLEMENT);
/* initialize the histogram ... */
for (col = 0; col < 4096 ; col++);
{
Histogram[col].count = 0;
Histogram[col].map_to = 0;
}
ymax = height ;
xmax = width ;
fprintf(stdout,"Please wait, building the histogram ... ");
fflush(stdout);
NumCols = 0;
for (ypos = 0 ; ypos < ymax ; ypos++)
{
for (xpos = 0 ; xpos < xmax ; xpos++ )
{
col = Next_Colour(xpos,ypos); /* get the next RGB colour from HAM pic */
if (Histogram[col].count == 0) /* new colour! */
NumCols++;
Histogram[col].count++;
}
}
fprintf(stdout,"Done.\n");
}
/* Find a colour in the SUN palette that is closest to 'colour' */
/* and return that found colour's INDEX in the SUN palette */
unsigned char best_match(colour)
int colour;
{
register int pos; /* the current index */
unsigned char fpos; /* the found index */
long mindist, /* the smallest distance to a colour so far */
dist, /* the distance (in RGB space) between 2 colours */
r,g,b,
r2,g2,b2;
mindist = 3 * ( 256 * 256 - 1) + 100; /* ensure we have the largest distance possible */
/* between any given 2 colours */
r = RED(colour); /* extract RED */
g = GREEN(colour); /* extract GREEN */
b = BLUE(colour); /* extract BLUE */
for (pos = 0 ; pos < 256 ; pos++)
{
r2 = (long) col_RED[pos];
g2 = (long) col_GREEN[pos];
b2 = (long) col_BLUE[pos];
dist = col_dist(r,g,b,r2,g2,b2);
if (dist < mindist)
{
fpos = (unsigned char) pos;
mindist = dist;
}
}
return((unsigned char) fpos);
}
/* For each colour in the Histogram find the best match in the SUN palette */
/* and store this in the 'map_to' field of the entry */
void map_colours()
{
int col;
unsigned char bestmatch();
fprintf(stdout,"Mapping colours ... ");
fflush(stdout);
for (col = 0 ; col < 4096 ; col++)
{
if (Histogram[col].count)
Histogram[col].map_to = (unsigned char) best_match(col);
}
fprintf(stdout,"Done.\n\n");
}
/* Comparison function use for frequency sorting the Histogram */
int cmpfreq(nod1,nod2)
struct node *nod1,*nod2;
{
long c1,c2;
c1 = nod1->count;
c2 = nod2->count;
if (c1 < c2)
return(-1);
else if (c1 > c2)
return(1);
else return(0);
}
/* Choose the best 256 colours out of 4096 possible colours! */
/* This method I employ currently may seem crude, but it worked
well in a program which went from 24 million colours to 256 !!! */
/* NOTE: ALTER THIS ROUTINE ONLY if you wish to improve the
colour choices! */
void make_palette()
{
int col;
int register pos;
/* store the current histogram away to a temporary histogram to be sorted */
for (pos= 0; pos < 4096 ; pos++)
{
sortedHist[pos].colr = pos;
sortedHist[pos].count = Histogram[pos].count;
sortedHist[pos].map_to = Histogram[pos].map_to;
}
/* sort the histogram due to colour frequency */
fprintf(stdout,"Sorting Histogram ... ");
fflush(stdout);
qsort((char *)sortedHist,(unsigned) 4096,sizeof(struct node),cmpfreq);
fprintf(stdout,"Done.\n");
#ifdef CHECK
printf("Dumping sorted Histogram:\n");
for (pos = 0; pos < 4096 ; pos++)
if (sortedHist[pos].count)
{
col = sortedHist[pos].colr;
printf("[%4d] Colour %4d (RED %2x ,GREEN %2x, BLUE %2x) , Count %ld\n",
pos,col,RED(col),GREEN(col),BLUE(col),sortedHist[pos].count);
}
#endif
/* strip off the top 256 most frequent colours out of the sorted Histogram */
if (NumCols <= 32)
{
fprintf(stdout,"\n\tNOTE: I suggest you convert this picture to NON-HAM and\n");
fprintf(stdout,"\t re-run this program on it for faster conversion.\n\n");
}
fprintf(stdout,"Choosing best 256 colours out of %d ... ",NumCols);
fflush(stdout);
/* My old CHEAPO method : (Works though!) */
/* I have thrown 2 new colour choice algorithms at this
and both didn't improve on my original method, grrrr!!!
I am not sure if the error is in my theory or a weird bug? */
/* I hope someone can come up with an improved method! */
/* As the HAM conversions are still only 90% perfect. */
for (pos = 0; pos < 256 ; pos++)
if (pos < NumCols)
{
col = sortedHist[4095-pos].colr;
col_RED[pos] = RED(col);
col_GREEN[pos] = GREEN(col);
col_BLUE[pos] = BLUE(col);
}
else /* we have less than 256 colours, thus zero the rest. */
{
col_RED[pos] = 0;
col_GREEN[pos] = 0;
col_BLUE[pos] = 0;
}
fprintf(stdout,"Done.\n");
}
void hist_info()
{
int colcnt, /* number of distinct colours */
maxcol; /* it's col */
long maxfreq, /* maximum freq of a col */
pixcnt, /* # pixels read in */
cnt; /* colour frequency */
int pos;
maxcol= maxfreq = colcnt = pixcnt = 0;
fprintf(stdout,"Analysing histogram ... ");
fflush(stdout);
for(pos = 0; pos < 4096; pos++)
{
cnt = Histogram[pos].count;
if (cnt)
{
colcnt++; /* bump the # of colours */
pixcnt += cnt; /* keep a runing total of # pixels read so far */
if (cnt > maxfreq) /* find MAX frequency */
{
maxfreq = cnt;
maxcol = pos;
}
}
}
fprintf(stdout,"Done.\n");
fprintf(stdout,"\n\t Histogram Information:\n");
fprintf(stdout,"\t==========================================\n");
fprintf(stdout,"\tTotal number of pixels read = %ld\n",pixcnt);
fprintf(stdout,"\tNumber of distinct colours = %d\n",colcnt);
fprintf(stdout,"\tColour %4d has Maximum Frequency = %ld\n",maxcol,maxfreq);
fprintf(stdout,"\t==========================================\n\n");
}
main(argc, argv)
int argc;
char *argv[];
{
int i;
SHORT swidth,sheight,sdepth;
struct ILBM_info *info;
/*Before we can do ANYTHING have to get our libraries... */
if ((GfxBase = OpenLibrary("graphics.library", (long)0)) == NULL)
{
fprintf(stderr,"Can't open Graphics Library\n");
return(-1);
}
if ((LayersBase = OpenLibrary("layers.library", (long)0)) == NULL)
{
fprintf(stderr,"Can't open Layers Library\n");
plop_cleanup();
return(-2);
}
/* Two for Dale and one for RJ */
if ((IntuitionBase = OpenLibrary("intuition.library",(long) 0)) == NULL)
{
fprintf(stderr,"Can't open Intuition Library\n");
plop_cleanup();
return(-3);
}
InitRastPort(&PlopRastPort);
PlopRastPort.Mask = 0xff; /* enable ALL bitplanes for writing */
if (argc < 3)
{
fprintf(stdout,"\n\t AMIGA IFF Format -> SUN RASTER BITMAP V1.31\n\n");
fprintf(stdout,"\t By Richard Frost. 5th March 1989.\n");
fprintf(stdout,"\t using Jim Kent's IFF routines .. 'Jiff.c'\n\n");
fprintf(stdout,"\tConversion of HAM pics supported in this version!\n");
fprintf(stdout,"\t Aspect Ratio correction for interlace pics only.\n");
fprintf(stdout,"\n\tUSAGE: %s <IFF-File> <SUN-Raster-File>\n\n",argv[0]);
}
else
{
fd = fopen(argv[2],"w");
if (fd == NULL)
{
fprintf(stderr,"Could not open file %s for read.\n",argv[1]);
exit(0);
}
if ( (info = read_iff(argv[1], 0) ) != NULL)
{
fprintf(stdout,"\n\tScreen Information For %s\n",argv[1]);
fprintf(stdout,"\t==============================\n");
fprintf(stdout,"\t Display Width = %d\n",info->header.pageWidth);
fprintf(stdout,"\t Display Height = %d\n",info->header.pageHeight);
fprintf(stdout,"\t # Bitplanes = %d\n",info->header.nPlanes);
fprintf(stdout,"\t Image X offset = %d\n",info->header.x);
fprintf(stdout,"\t Image Y offset = %d\n",info->header.y);
fprintf(stdout,"\t Image Width = %d\n",info->header.w);
fprintf(stdout,"\t Image Height = %d\n",info->header.h);
fprintf(stdout,"\t==============================\n\n");
swidth = (SHORT) info->header.w ;
sheight = (SHORT) info->header.h ;
sdepth = (SHORT) info->header.nPlanes ;
PlopNewScreen.Width = (SHORT) info->header.pageWidth;
PlopNewScreen.Height = (SHORT) info->header.pageHeight;
PlopNewScreen.Depth = (SHORT) info->header.nPlanes ;
if (sdepth == 6) /* ie. We want HAM mode ! */
PlopNewScreen.ViewModes = HAM;
if (info->header.pageWidth >= 640)
PlopNewScreen.ViewModes = HIRES;
if (info->header.pageHeight >= 256)
{
PlopNewScreen.ViewModes |= INTERLACE;
if (info->header.pageWidth < 640)
{
fprintf(stdout,"Aspect Ratio Correction ON.\n");
LaceFlag = 1;
}
else
LaceFlag = 0;
}
if ( (PlopScreen = OpenScreen(&PlopNewScreen) ) == NULL)
{
fprintf(stderr,"OpenScreen failed\n");
plop_cleanup();
return(-4);
}
else
{
WBenchToFront();
if (sdepth < 6)
put_ea_cmap(&info->cmap, (1 << info->bitmap.Depth));
else
put_ea_cmap(&info->cmap,16);
PlopRastPort.BitMap = &info->bitmap;
ClipBlit(&PlopRastPort, (long)0, (long)0,
&PlopScreen->RastPort, (long)info->header.x, (long)info->header.y,
(long)info->header.w, (long)info->header.h, (long)COPY_MINTERM);
free_planes(&info->bitmap);
if (sdepth == 6) /* ie. We got a HAM pic! */
{
make_histogram(swidth,sheight);
hist_info(); /* OPTIONAL ROUTINE for interest only */
make_palette();
map_colours();
}
write_rast(info->header.w, info->header.h,
info->header.nPlanes,
info->header.x, info->header.y,
&info->cmap);
fclose(fd);
fprintf(stdout,"\nAll Done, have a nice day.\n");
}
}
else
fprintf(stderr,"Couldn't load %s as an IFF file\n",argv[1]);
}
plop_cleanup();
}