2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Free the memory occupied by a BitMap.
8 #include <aros/debug.h>
9 #include <exec/memory.h>
10 #include <proto/exec.h>
11 #include "graphics_intern.h"
12 #include "gfxfuncsupport.h"
14 /*****************************************************************************
17 #include <graphics/gfx.h>
18 #include <proto/graphics.h>
20 AROS_LH1(void, FreeBitMap
,
23 AROS_LHA(struct BitMap
*, bm
, A0
),
26 struct GfxBase
*, GfxBase
, 154, Graphics
)
29 Returns the memory occupied by the BitMap to the system.
32 bm - The result of AllocBitMap(). Must be non-NULL.
44 AllocBitMap(), AllocRaster(), FreeRaster()
50 *****************************************************************************/
53 AROS_LIBBASE_EXT_DECL(struct GfxBase
*,GfxBase
)
59 if (bm
->pad
!= 0 || (bm
->Flags
& BMF_AROS_HIDD
))
61 if (HIDD_BM_FLAGS(bm
) & HIDD_BMF_SHARED_PIXTAB
)
63 /* NULL colormap otherwise bitmap killing also kills
64 the colormap object of the bitmap object
65 from which we shared it = to which it belongs */
67 HIDD_BM_SetColorMap(HIDD_BM_OBJ(bm
), NULL
);
69 else if (HIDD_BM_FLAGS(bm
) & HIDD_BMF_SCREEN_BITMAP
) // (bm->Flags & BMF_DISPLAYABLE)
71 FreeVec(HIDD_BM_PIXTAB(bm
));
74 HIDD_Gfx_DisposeBitMap(SDD(GfxBase
)->gfxhidd
, (OOP_Object
*)HIDD_BM_OBJ(bm
));
76 FreeMem(bm
, sizeof (struct BitMap
));
83 width
= bm
->BytesPerRow
* 8;
85 for (plane
=0; plane
< bm
->Depth
; plane
++)
87 /* Take care of two special cases: plane pointers containing NULL or -1
88 * are supported by BltBitMap() as all 0's and all 1's planes
90 if (bm
->Planes
[plane
] && bm
->Planes
[plane
] != (PLANEPTR
)-1)
92 ASSERT_VALID_PTR(bm
->Planes
[plane
]);
93 FreeRaster (bm
->Planes
[plane
], width
, bm
->Rows
);
97 FreeMem (bm
, sizeof(struct BitMap
) +
98 ((bm
->Depth
> 8) ? (bm
->Depth
- 8) * sizeof(PLANEPTR
) : 0));