home *** CD-ROM | disk | FTP | other *** search
- #include <exec/types.h>
- #include <intuition/intuition.h>
- #include <graphics/gfxmacros.h>
-
- #include <proto/intuition.h>
- #include <proto/graphics.h>
-
- #include "View_define.h"
- #include "ViewProtos.h"
- #include "hame.h"
-
- extern struct HamePort *hamePort;
- extern struct Library *HameBase;
- extern struct Screen *gScreen;
-
-
- /* Draw the image */
- int
- drawImage (struct Window *win,
- char *image,
- int width, int height,int mode)
- {
-
- register int j,i;
- char *data=image;
- int level, level0;
- int factor=8;
- int ht, wt;
-
- setColors(mode);
-
- if( (mode==COLORS_32) || (mode==COLORS_LACE_32) ||
- (mode==COLORS_16) || (mode==COLORS_LACE_16) )
- {
- /* This is meant to try to cut down on drawing time. I have
- noticed that many images have some background color that makes
- up a large part of the image. So here I look at the first
- entry in the image array and flood the background with that
- color. Then whenever the image has the entry again I don't have to
- draw anything. It would be better perhaps to search for the most
- common color and use that instead. */
-
- if( (mode==COLORS_16) || (mode==COLORS_LACE_16) ) factor=16;
-
- level0 = (int)(*image)/factor;
- SetAPen(win->RPort,level0);
- RectFill(win->RPort,0,0, win->Width,win->Height);
-
-
- /* Do the actual drawing */
- for(j=0;j<height;j++)
- {
- for(i=0;i<width;i++)
- {
- level = (int)(*data)/factor;
- if( (level != level0) &&
- (i<win->Width) && (j<win->Height) )
- {
- SetAPen(win->RPort,level);
- WritePixel(win->RPort,i,j);
- }
- data++;
- }
- }
- }
-
-
-
- if( (mode==HAME) || (mode==HAME_LACE) )
- {
- if(mode==HAME_LACE) ht = win->Height-8;
- else ht = win->Height-4;
- wt = win->Width/2;
-
- level0 = (int)(*data);
- HAME_SetAPen(hamePort,level0);
- HAME_Box(hamePort,0,0, wt,ht, 1);
-
- HAME_SetAPen(hamePort,255);
- HAME_Line(hamePort,0,0,0,ht);
-
- HAME_8BitRender(hamePort,data,1,0,width,height);
-
- /* for(i=1;i<height+1;i++)
- {
- HAME_LockLayer(hamePort);
- for(j=1;j<width+1;j++)
- {
- level = (int)(*data);
- if( (i<win->Height-1) && (j<win->Width-1) && (level!=level0) )
- {
- HAME_SetAPen(hamePort,level);
- HAME_WritePixel(hamePort, j, i);
- }
- data++;
- }
- HAME_UnlockLayer(hamePort);
- }
- */
- }
-
- if(gScreen) ScreenToFront(gScreen);
- return(1);
- }
-
-
-
-
-