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 *****************************************************************************/
62 OOP_Object
*bmobj
= HIDD_BM_OBJ(bm
);
64 D(bug("%s: Free HIDD bitmap %p (obj %p)\n", __func__
, bm
, bmobj
));
66 if (HIDD_BM_FLAGS(bm
) & HIDD_BMF_SHARED_PIXTAB
)
68 /* NULL colormap otherwise bitmap killing also kills
69 the colormap object of the bitmap object
70 from which we shared it = to which it belongs */
72 HIDD_BM_SetColorMap(bmobj
, NULL
);
74 else if (HIDD_BM_FLAGS(bm
) & HIDD_BMF_SCREEN_BITMAP
) // (bm->Flags & BMF_DISPLAYABLE)
76 FreeVec(HIDD_BM_PIXTAB(bm
));
80 HIDD_Gfx_DisposeBitMap(HIDD_BM_DRVDATA(bm
)->gfxhidd
, bmobj
);
82 FreeMem(bm
, sizeof (struct BitMap
) + sizeof(PLANEPTR
) * HIDD_BM_EXTRAPLANES
);
89 D(bug("%s: Free plain bitmap %p\n", __func__
, bm
));
91 width
= bm
->BytesPerRow
* 8;
93 for (plane
=0; plane
< bm
->Depth
; plane
++)
95 /* Take care of two special cases: plane pointers containing NULL or -1
96 * are supported by BltBitMap() as all 0's and all 1's planes
98 if (bm
->Planes
[plane
] && bm
->Planes
[plane
] != (PLANEPTR
)-1)
100 ASSERT_VALID_PTR(bm
->Planes
[plane
]);
101 FreeRaster (bm
->Planes
[plane
], width
, bm
->Rows
);
105 FreeMem (bm
, sizeof(struct BitMap
) +
106 ((bm
->Depth
> 8) ? (bm
->Depth
- 8) * sizeof(PLANEPTR
) : 0));