1/*
2 * LegacyClonk
3 *
4 * Copyright (c) 1998-2000, Matthes Bender (RedWolf Design)
5 * Copyright (c) 2017-2019, The LegacyClonk Team and contributors
6 *
7 * Distributed under the terms of the ISC license; see accompanying file
8 * "COPYING" for details.
9 *
10 * "Clonk" is a registered trademark of Matthes Bender, used with permission.
11 * See accompanying file "TRADEMARK" for details.
12 *
13 * To redistribute this file separately, substitute the full license texts
14 * for the above references.
15 */
16
17/* Another C4Group bitmap-to-surface loader and saver */
18
19#include <C4SurfaceFile.h>
20
21#include <C4Surface.h>
22#include <C4Group.h>
23#include "StdSurface8.h"
24
25C4Surface *GroupReadSurface(C4Group &hGroup, uint8_t *bpPalette)
26{
27 // create surface
28 C4Surface *pSfc = new C4Surface();
29 if (!pSfc->Read(hGroup, fOwnPal: !!bpPalette))
30 {
31 delete pSfc; return nullptr;
32 }
33 return pSfc;
34}
35
36CSurface8 *GroupReadSurface8(C4Group &hGroup)
37{
38 // create surface
39 CSurface8 *pSfc = new CSurface8();
40 if (!pSfc->Read(hGroup, fOwnPal: false))
41 {
42 delete pSfc; return nullptr;
43 }
44 return pSfc;
45}
46
47CSurface8 *GroupReadSurfaceOwnPal8(C4Group &hGroup)
48{
49 // create surface
50 CSurface8 *pSfc = new CSurface8();
51 if (!pSfc->Read(hGroup, fOwnPal: true))
52 {
53 delete pSfc; return nullptr;
54 }
55 return pSfc;
56}
57
58C4Surface *GroupReadSurfacePNG(C4Group &hGroup)
59{
60 // create surface
61 C4Surface *pSfc = new C4Surface();
62 pSfc->ReadPNG(hGroup);
63 return pSfc;
64}
65