2 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
5 Desc: Free the memory occupied by a BitMap.
9 #include <aros/debug.h>
10 #include <exec/memory.h>
11 #include <proto/exec.h>
13 #include "graphics_intern.h"
14 #include "gfxfuncsupport.h"
16 /*****************************************************************************
19 #include <graphics/gfx.h>
20 #include <proto/graphics.h>
22 AROS_LH1(void, FreeBitMap
,
25 AROS_LHA(struct BitMap
*, bm
, A0
),
28 struct GfxBase
*, GfxBase
, 154, Graphics
)
31 Returns the memory occupied by the BitMap to the system.
34 bm - The result of AllocBitMap(). Must be non-NULL.
46 AllocBitMap(), AllocRaster(), FreeRaster()
52 *****************************************************************************/
60 if (bm
->pad
!= 0 || (bm
->Flags
& BMF_SPECIALFMT
))
62 OOP_Object
*bmobj
= HIDD_BM_OBJ(bm
);
64 if (HIDD_BM_FLAGS(bm
) & HIDD_BMF_SHARED_PIXTAB
)
66 /* NULL colormap otherwise bitmap killing also kills
67 the colormap object of the bitmap object
68 from which we shared it = to which it belongs */
70 HIDD_BM_SetColorMap(bmobj
, NULL
);
72 else if (HIDD_BM_FLAGS(bm
) & HIDD_BMF_SCREEN_BITMAP
) // (bm->Flags & BMF_DISPLAYABLE)
74 FreeVec(HIDD_BM_PIXTAB(bm
));
78 HIDD_Gfx_DisposeBitMap(HIDD_BM_DRVDATA(bm
)->gfxhidd
, bmobj
);
80 FreeMem(bm
, sizeof (struct BitMap
));
87 width
= bm
->BytesPerRow
* 8;
89 for (plane
=0; plane
< bm
->Depth
; plane
++)
91 /* Take care of two special cases: plane pointers containing NULL or -1
92 * are supported by BltBitMap() as all 0's and all 1's planes
94 if (bm
->Planes
[plane
] && bm
->Planes
[plane
] != (PLANEPTR
)-1)
96 ASSERT_VALID_PTR(bm
->Planes
[plane
]);
97 FreeRaster (bm
->Planes
[plane
], width
, bm
->Rows
);
101 FreeMem (bm
, sizeof(struct BitMap
) +
102 ((bm
->Depth
> 8) ? (bm
->Depth
- 8) * sizeof(PLANEPTR
) : 0));