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 --- Zoom.c | 152 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 Zoom.c (limited to 'Zoom.c') diff --git a/Zoom.c b/Zoom.c new file mode 100644 index 0000000..eb0d9fc --- /dev/null +++ b/Zoom.c @@ -0,0 +1,152 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "Bobi.h" +#include "BobStructure.h" +#include "ByteMap.h" +#include "ZoomWindow.h" + +extern struct MyBob *BobTable[]; +extern struct Screen *mainscreen; +extern struct RastPort *mainrastport; +extern UWORD mainpalette[]; +extern WORD actbobnum,mainx0,mainy0; + +/*************************************************************************/ + +static void ZoomBitMap(struct BitMap *bim, LONG faktor) +{ + register struct ByteMap *sbym,*dbym; /* Source & Destination */ + + if(sbym=MakeByteMap((WORD)(bim->BytesPerRow*8),bim->Rows)) + { + if(dbym=MakeByteMap((WORD)(bim->BytesPerRow*8),bim->Rows)) + { + BitMapToByteMap(bim,sbym); + ZoomByteMap(sbym,dbym,faktor); + ByteMapToBitMap(dbym,bim); + FreeByteMap(dbym); + } + else ShowMonoReq2("No memory for zoom"); + FreeByteMap(sbym); + } + else ShowMonoReq2("No memory for zoom"); +} + +/*************************************************************************/ + +static struct MyBob *ZoomBob(struct MyBob *bob,register LONG faktor) +{ + register struct BitMap *sbim,*dbim; + register WORD width,height; + + if((bob->Flags & BOBF_AUTOSIZE) && (faktor>100)) + { + width = (bob->Width*faktor)/100+1; + height = (bob->Height*faktor)/100+1; + } + else + { + width = bob->Width; height = bob->Height; + } + + if(sbim=BobToBitMap(bob)) + { + if(dbim=MakeBitMap(width,height,bob->Depth)) + { + BltBitMap(sbim,0,0,dbim,(width-bob->Width)/2, + (height-bob->Height)/2,bob->Width,bob->Height,0xc0,0xff,0); + ZoomBitMap(dbim,faktor); + bob=BitMapToBob(bob,dbim,width); + MyFreeBitMap(dbim); + } + else bob = 0; + MyFreeBitMap(sbim); + } + else bob = 0; + return(bob); +} + +/*************************************************************************/ + +void ZoomFunc() +{ + register struct Window *w; + register WORD flag = 0; + register LONG i,increment; + + if(BobTable[actbobnum]) + { + LockWindows(); + NewWindowStructure1.Screen = mainscreen; + if(w=OpenWindow(&NewWindowStructure1)) + { + do + { + register struct IntuiMessage *msg; + + WaitPort(w->UserPort); + msg=(struct IntuiMessage *)GetMsg(w->UserPort); + if(msg->Class == CLOSEWINDOW) + { + flag = -1; + } + else if(msg->Class == GADGETUP) + { + if(msg->IAddress == (APTR)&OKGadget) + { + flag = 1; + } + else if(msg->IAddress == (APTR)&CancelGadget) + { + flag = -1; + } + } + } while(!flag); + CloseWindow(w); + LoadPalette(mainpalette); + + if(flag>0) + { + register struct MyBob *bob; + + increment=LastGadgetSInfo.LongInt-FirstGadgetSInfo.LongInt; + increment/=FramesGadgetSInfo.LongInt; + + for(i=0; i