1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
/*
** Bobi - The Ultimate Amiga Bob Manipulator
**
** BMapSupport.c - Erstellen und Vernichten von BitMaps und ByteMaps
**
** COPYRIGHT (C) 1989-1993 BY CHRISTIAN A. WEBER, ZUERICH, SWITZERLAND.
** ALL RIGHTS RESERVED. NO PART OF THIS SOFTWARE MAY BE COPIED, REPRODUCED,
** OR TRANSMITTED IN ANY FORM OR BY ANY MEANS, WITHOUT THE PRIOR WRITTEN
** PERMISSION OF THE AUTHOR. NO WARRANTY. USE AT YOUR OWN RISK.
*/
#include <proto/exec.h>
#include <exec/memory.h>
#include <graphics/gfx.h>
#include <proto/graphics.h>
#include "ByteMap.h"
struct BitMap *MakeBitMap(WORD width, WORD height, WORD depth)
{
register long i;
register struct BitMap *b;
register WORD planesize;
if(b = AllocMem(sizeof(struct BitMap),MEMF_CLEAR))
{
InitBitMap(b,depth,width,height);
planesize=b->BytesPerRow*b->Rows;
if(b->Planes[0]=AllocMem(planesize*depth,MEMF_CHIP|MEMF_CLEAR))
{
for(i=1; i<depth; ++i)
b->Planes[i] = b->Planes[0]+i*planesize;
}
else
{
FreeMem(b,sizeof(*b));
b=0;
}
}
return(b);
}
/*************************************************************************/
void MyFreeBitMap(struct BitMap *b)
{
FreeMem(b->Planes[0],b->BytesPerRow*b->Rows*b->Depth);
FreeMem(b,sizeof(*b));
}
/*************************************************************************/
struct ByteMap *MakeByteMap(register WORD width,register WORD height)
{
register struct ByteMap *b;
register long planesize;
planesize = width*height;
if(b = AllocMem(sizeof(struct ByteMap),MEMF_CLEAR))
{
if(b->Plane = AllocMem(planesize,MEMF_CLEAR))
{
b->Width = width;
b->Height = height;
b->PlaneSize = planesize;
}
else
{
FreeMem(b,sizeof(*b));
b=0;
}
}
return b;
}
/*************************************************************************/
void FreeByteMap(struct ByteMap *b)
{
if(b->Plane)
{
FreeMem(b->Plane,b->PlaneSize);
}
FreeMem(b,sizeof(*b));
}
|