wip prep commit in lieu of gfx subsystem update changes.
[AROS.git] / test / hidds / gfx / obsolete / BitMapNewDispose.c
blob0d044187903a8576d84f48a5ca4a23527f5417a7
1 /*
2 Copyright © 1998, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Test for graphics.hidd
6 Lang: english
7 */
9 /*****************************************************************************
11 NAME
13 BitMapNewDispose
15 SYNOPSIS
17 BitMapNewDispose HIDD/K,WIDTH/N/K,HEIGHT/N/K,DEPTH/N/K,CHUNKY/S/,DISPLAYABLE=DP/S
19 LOCATION
21 test/HiddGraphics
23 FUNCTION
25 Creates a bitmap, prints the attributes of the bitmap and dispose
26 the bitmap.
28 INPUTS
29 HIDD - name of the hidd to use e.g. "graphics-X11.hidd"
30 (default: graphics.hidd)
31 WIDTH - width of bitmap (default: 320)
32 HEIGHT - height of bitmap (default: 200)
33 DEPTH - depth of bitmap (default: 8)
34 CHUNKY - create bitmap in chunky-mode (default: planar)
35 DISPLAYABLE - show bitmap (default: FALSE)
37 RESULT
38 RETURN_OK - hidd works
39 RETURN_ERROR - hidd produce errors
40 RETURN_FAIL - could not test hidd i.e. OpenLibrary() fails
42 NOTES
44 EXAMPLE
46 BUGS
48 SEE ALSO
50 INTERNALS
52 HISTORY
54 ******************************************************************************/
56 #define AROS_USE_OOP
58 #include <stdlib.h>
59 #include <stdio.h>
60 #include <strings.h>
62 #include <aros/config.h>
64 #include <exec/types.h>
66 #include <proto/exec.h>
67 #include <proto/dos.h>
68 #include <proto/oop.h>
69 #include <proto/utility.h>
71 #include <utility/tagitem.h>
72 #include <dos/dos.h>
73 #include <dos/rdargs.h>
75 #include <oop/oop.h>
76 #include <hidd/graphics.h>
78 #include "gfxhiddtool.h"
80 #undef SDEBUG
81 #undef DEBUG
82 #define DEBUG 1
83 #include <aros/debug.h>
85 struct DosLibrary *DOSBase;
86 struct Library *OOPBase;
87 struct Library *HIDDGraphicsBase;
89 struct ght_OpenLibs LibsArray[] =
91 GHT_LIB("dos.library" , 37, &DOSBase),
92 GHT_LIB(AROSOOP_NAME , 0, &OOPBase),
93 GHT_LIB(NULL , 0, NULL)
95 /***************************************************************/
97 int main(int argc, char **argv)
99 ULONG ret = RETURN_FAIL;
101 OOP_AttrBase HiddGfxAttrBase;
102 OOP_AttrBase HiddBitMapAttrBase;
104 OOP_Object *gfxHidd;
105 OOP_Object *bitMap;
107 STRPTR hiddName = "graphics.hidd";
108 ULONG width = 320;
109 ULONG height = 200;
110 ULONG depth = 8;
111 ULONG format = vHidd_BitMap_Format_Planar;
113 struct Args
115 STRPTR hiddName;
116 IPTR *width;
117 IPTR *height;
118 IPTR *depth;
119 ULONG chunky;
120 ULONG displayable;
123 struct Args args = {hiddName, &width, &height, &depth, 0, 0};
124 struct RDArgs *rda;
126 if(ght_OpenLibs(LibsArray))
128 rda = ReadArgs("HIDD/K,WIDTH/N/K,HEIGHT/N/K,DEPTH/N/K,CHUNKY/S,DISPLAYABLE=DP/S", (IPTR *)&args, NULL);
129 if (rda != NULL)
131 if(args.chunky != 0) format = vHidd_BitMap_Format_Chunky;
132 if(args.displayable != 0) args.displayable = (ULONG) TRUE;
134 HIDDGraphicsBase = OpenLibrary(args.hiddName, 0);
135 if(HIDDGraphicsBase)
137 ret = RETURN_ERROR;
138 HiddGfxAttrBase = OOP_ObtainAttrBase(IID_Hidd_Gfx);
139 HiddBitMapAttrBase = OOP_ObtainAttrBase(IID_Hidd_BitMap);
141 if(HiddGfxAttrBase && HiddBitMapAttrBase)
143 gfxHidd = OOP_NewObject(NULL, args.hiddName, NULL);
144 if(gfxHidd)
146 struct TagItem bm_tags[] =
148 {aHidd_BitMap_Width, (IPTR) *args.width},
149 {aHidd_BitMap_Height, (IPTR) *args.height},
150 {aHidd_BitMap_Depth, (IPTR) *args.depth},
151 {aHidd_BitMap_Format, (IPTR) format},
152 {aHidd_BitMap_Displayable, (IPTR) args.displayable},
153 {TAG_DONE, 0UL}
156 bitMap = HIDD_Gfx_NewBitMap(gfxHidd, bm_tags);
157 if(bitMap)
159 printf("BitMap created:\n");
160 printf(" width : %li\n", ght_GetAttr(bitMap, aHidd_BitMap_Width));
161 printf(" height : %li\n", ght_GetAttr(bitMap, aHidd_BitMap_Height));
162 printf(" depth : %li\n", ght_GetAttr(bitMap, aHidd_BitMap_Depth));
163 printf(" format : %li\n", ght_GetAttr(bitMap, aHidd_BitMap_Format));
164 printf(" displayable: %li\n", ght_GetAttr(bitMap, aHidd_BitMap_Displayable));
166 HIDD_Gfx_DisposeBitMap(gfxHidd, bitMap);
168 ret = RETURN_OK;
171 if(gfxHidd) OOP_DisposeObject(gfxHidd);
173 } /* if(gfxHidd) */
176 } /* if(HiddGfxAttrBase && HiddBitMapAttrBase) */
178 if(HiddBitMapAttrBase) OOP_ReleaseAttrBase(IID_Hidd_BitMap);
179 if(HiddGfxAttrBase) OOP_ReleaseAttrBase(IID_Hidd_Gfx);
181 CloseLibrary(HIDDGraphicsBase);
182 } /* if(HIDDGraphicsBase) */
184 FreeArgs(rda);
186 else
188 PrintFault(IoErr(), "");
189 } /* if (rda != NULL) */
191 } /* if OpenLibs() */
193 ght_CloseLibs(LibsArray);
195 return(ret);