2 Copyright © 1995-2007, 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 *****************************************************************************/
58 if (bm
->pad
!= 0 || (bm
->Flags
& BMF_AROS_HIDD
))
60 if (HIDD_BM_FLAGS(bm
) & HIDD_BMF_SHARED_PIXTAB
)
62 /* NULL colormap otherwise bitmap killing also kills
63 the colormap object of the bitmap object
64 from which we shared it = to which it belongs */
66 HIDD_BM_SetColorMap(HIDD_BM_OBJ(bm
), NULL
);
68 else if (HIDD_BM_FLAGS(bm
) & HIDD_BMF_SCREEN_BITMAP
) // (bm->Flags & BMF_DISPLAYABLE)
70 FreeVec(HIDD_BM_PIXTAB(bm
));
73 HIDD_Gfx_DisposeBitMap(SDD(GfxBase
)->gfxhidd
, (OOP_Object
*)HIDD_BM_OBJ(bm
));
75 FreeMem(bm
, sizeof (struct BitMap
));
82 width
= bm
->BytesPerRow
* 8;
84 for (plane
=0; plane
< bm
->Depth
; plane
++)
86 /* Take care of two special cases: plane pointers containing NULL or -1
87 * are supported by BltBitMap() as all 0's and all 1's planes
89 if (bm
->Planes
[plane
] && bm
->Planes
[plane
] != (PLANEPTR
)-1)
91 ASSERT_VALID_PTR(bm
->Planes
[plane
]);
92 FreeRaster (bm
->Planes
[plane
], width
, bm
->Rows
);
96 FreeMem (bm
, sizeof(struct BitMap
) +
97 ((bm
->Depth
> 8) ? (bm
->Depth
- 8) * sizeof(PLANEPTR
) : 0));