home *** CD-ROM | disk | FTP | other *** search
- /*
- ** GadTools layout toolkit
- **
- ** Copyright © 1993-1996 by Olaf `Olsen' Barthel
- ** Freely distributable.
- **
- ** :ts=4
- */
-
- #ifndef _GTLAYOUT_GLOBAL_H
- #include "gtlayout_global.h"
- #endif
-
- LONG
- LTP_GetDepth(struct BitMap *BitMap)
- {
- if(V39)
- return((LONG)GetBitMapAttr(BitMap,BMA_DEPTH));
- else
- return(BitMap->Depth);
- }
-
- VOID
- LTP_DeleteBitMap(struct BitMap *BitMap,BOOL Chip)
- {
- if(V39 && !Chip)
- FreeBitMap(BitMap);
- else
- {
- if(BitMap)
- {
- LONG i,*Sizes,Width,Height;
-
- Sizes = &((LONG *)BitMap)[-2];
-
- Width = Sizes[0];
- Height = Sizes[1];
-
- if(Width && Height)
- {
- for(i = 0 ; i < BitMap->Depth ; i++)
- FreeRaster(BitMap->Planes[i],Width,Height);
- }
- else
- {
- for(i = 0 ; i < BitMap->Depth ; i++)
- FreeVec(BitMap->Planes[i]);
- }
-
- FreeVec(Sizes);
- }
- }
- }
-
- struct BitMap *
- LTP_CreateBitMap(LONG Width,LONG Height,LONG Depth,struct BitMap *Friend,BOOL Chip)
- {
- struct BitMap *BitMap;
-
- if(V39 && !Chip)
- BitMap = AllocBitMap(Width,Height,Depth,BMF_MINPLANES,Friend);
- else
- {
- LONG *Sizes;
-
- if(!(Sizes = (LONG *)AllocVec(sizeof(LONG) * 2 + sizeof(struct BitMap),MEMF_ANY | MEMF_PUBLIC | MEMF_CLEAR)))
- BitMap = NULL;
- else
- {
- LONG i;
-
- BitMap = (struct BitMap *)&Sizes[2];
-
- InitBitMap(BitMap,Depth,Width,Height);
-
- for(i = 0 ; i < Depth ; i++)
- {
- if(!(BitMap->Planes[i] = AllocRaster(Width,Height)))
- {
- LONG j;
-
- for(j = 0 ; j < i ; j++)
- FreeRaster(BitMap->Planes[j],Width,Height);
-
- FreeVec(Sizes);
-
- return(NULL);
- }
- }
-
- Sizes[0] = Width;
- Sizes[1] = Height;
-
- if(Chip)
- {
- ULONG Type = MEMF_CHIP;
-
- for(i = 0 ; i < Depth ; i++)
- Type &= TypeOfMem(BitMap->Planes[i]);
-
- if(!(Type & MEMF_CHIP))
- {
- LONG PageSize;
-
- for(i = 0 ; i < Depth ; i++)
- {
- FreeRaster(BitMap->Planes[i],Width,Height);
- BitMap->Planes[i] = NULL;
- }
-
- PageSize = BitMap->BytesPerRow * BitMap->Rows;
-
- for(i = 0 ; i < Depth ; i++)
- {
- if(!(BitMap->Planes[i] = AllocVec(PageSize,MEMF_CHIP)))
- {
- LONG j;
-
- for(j = 0 ; j < i ; j++)
- FreeVec(BitMap->Planes[j]);
-
- FreeVec(Sizes);
-
- return(NULL);
- }
- }
-
- Sizes[0] = Sizes[1] = 0;
- }
- }
- }
- }
-
- return(BitMap);
- }
-