From 62e509e9c90d728c9f65145947276f79112ab48c Mon Sep 17 00:00:00 2001 From: "Christian A. Weber" Date: Tue, 2 Nov 1993 18:53:33 +0000 Subject: Initial revision --- Picture.c | 174 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 Picture.c (limited to 'Picture.c') diff --git a/Picture.c b/Picture.c new file mode 100644 index 0000000..19213fe --- /dev/null +++ b/Picture.c @@ -0,0 +1,174 @@ +#include +#include +#include +#include +#include +#include +#include + +#include "Bobi.h" +#define MAX(a,b) ((a)>(b)?(a):(b)) + +extern struct Screen *mainscreen; +extern struct Screen *picturescreen; +extern struct Window *picturewindow; + +extern UWORD mainpalette[],picturepalette[]; + +extern char PicPath[]; /* Definiert in LoadBobs.c wegen '.bobi' */ +extern char PicName[]; + +extern BYTE arexxflag; +extern char arexxfilename[]; + +static struct RastPort *picturerastport; + + +/**************************************************************************** +** Ein IFF-Bild von Disk laden +*/ + +void LoadPicFunc() +{ + ULONG *formptr; + struct IFFL_BMHD *bmhd; + LONG count; + IFFL_HANDLE ifffile; + char *name; + + LockWindows(); + + if(arexxflag) + name = arexxfilename; + else + name=FileRequest("Load Picture from Disk", "LOAD", PicPath, PicName); + + if(name) + { + if(ifffile = IFFL_OpenIFF(name, IFFL_MODE_READ)) + { + formptr = ifffile; + if(formptr[2]==ID_ANIM) formptr+=3; + + if(bmhd = IFFL_GetBMHD(formptr)) + { + CloseScreenFunc(); + if(picturerastport = CreateRastPort(bmhd->nPlanes, + MAX(bmhd->w,GfxBase->NormalDisplayColumns>>1), + MAX(bmhd->h,GfxBase->NormalDisplayRows))) + { + static struct TagItem mytagitems[] = + { + SA_Overscan,OSCAN_TEXT, + SA_AutoScroll,TRUE, + }; + struct ExtNewScreen ns; + struct NewWindow nw; + + ClearMem(&ns,sizeof(ns)); + ClearMem(&nw,sizeof(nw)); + + if(OSVERSION(37)) + { + ns.Width = bmhd->w; + ns.Height = bmhd->h; + } + else + { + ns.Width = GfxBase->NormalDisplayColumns>>1; + ns.Height = GfxBase->NormalDisplayRows; + } + ns.Depth = bmhd->nPlanes; + // ns.Depth = (bmhd->nPlanes > 5) ? bmhd->nPlanes:5; + ns.ViewModes = IFFL_GetViewModes(formptr); + ns.CustomBitMap = picturerastport->BitMap; + ns.Type = CUSTOMSCREEN|CUSTOMBITMAP|SCREENQUIET|SCREENBEHIND|NS_EXTENDED; + ns.Extension = mytagitems; + + nw.IDCMPFlags = IDCMP_MOUSEBUTTONS | IDCMP_MOUSEMOVE | IDCMP_DELTAMOVE; + nw.Flags = WFLG_BACKDROP | WFLG_BORDERLESS + | WFLG_SIMPLE_REFRESH | WFLG_NOCAREREFRESH + | WFLG_REPORTMOUSE | WFLG_RMBTRAP; + nw.Type = CUSTOMSCREEN; + + if(picturescreen = OpenScreen(&ns)) + { + nw.Screen = picturescreen; + nw.Width = picturescreen->Width; + nw.Height = picturescreen->Height; + if(picturewindow = OpenWindow(&nw)) + { + ShowTitle(picturescreen,FALSE); + count = IFFL_GetColorTab(formptr,(WORD *)picturepalette); + if(count>32) count = 32; + CopyMem(picturepalette,mainpalette,count*2); + LoadRGB4(&picturescreen->ViewPort,picturepalette,count); + + if(IFFL_DecodePic(formptr,&(picturescreen->BitMap))) + { + if(!arexxflag) + { + ScreenToFront(picturescreen); + MoveScreen(mainscreen,0,-255); + MoveScreen(mainscreen,0,255); + Delay(15); + ScreenToFront(mainscreen); + for(count=28; count>0; --count) + MoveScreen(mainscreen,0,-10); + } + } + else + { + CloseScreenFunc(); + ShowIFFError("Error decoding picture"); + } + } + else + { + CloseScreenFunc(); + ShowMonoReq2("Can't open window!"); + } + } + else + { + CloseScreenFunc(); + ShowMonoReq2("Can't open screen!"); + } + } + else ShowMonoReq2("No mem for rastport!"); + } + else ShowIFFError("Mangled IFF picture"); + IFFL_CloseIFF(ifffile); + } + else ShowIFFError(name); + + } /* if(FileRequest()) */ + UnLockWindows(); +} + +/**************************************************************************** +** Picture-Screen schliessen und Bild freigeben +*/ + +void CloseScreenFunc() +{ + if(picturewindow) + { + CloseWindow(picturewindow); + picturewindow = 0; + } + + if(picturescreen) + { + CloseScreen(picturescreen); + picturescreen = 0; + } + + if(picturerastport) + { + DeleteRastPort(picturerastport); + picturerastport = 0; + } + +} + -- cgit v1.2.3