2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
6 /****************************************************************************************/
8 #define USE_BOOPSI_STUBS
10 #include <exec/execbase.h>
11 #include <exec/memory.h>
12 #include <intuition/intuition.h>
13 #include <intuition/classes.h>
14 #include <intuition/classusr.h>
15 #include <intuition/imageclass.h>
16 #include <graphics/gfx.h>
17 #include <cybergraphx/cybergraphics.h>
18 #include <proto/exec.h>
19 #include <proto/intuition.h>
20 #include <proto/graphics.h>
21 #include <proto/cybergraphics.h>
22 #include <proto/utility.h>
23 #include <aros/asmcall.h>
24 #include <clib/boopsistubs.h>
26 #include "coolimages.h"
28 /****************************************************************************************/
32 struct CoolImage
*image
;
37 /****************************************************************************************/
39 extern struct IntuitionBase
*IntuitionBase
;
40 extern struct GfxBase
*GfxBase
;
41 extern struct UtilityBase
*UtilityBase
;
43 struct IClass
*cool_imageclass
;
45 /****************************************************************************************/
47 #define CyberGfxBase cool_cybergfxbase
48 #define IM(x) ((struct Image *)(x))
50 /****************************************************************************************/
52 static struct Library
*cool_cybergfxbase
;
54 /****************************************************************************************/
56 static IPTR
coolimage_new(Class
* cl
, Object
* o
, struct opSet
* msg
)
59 struct CoolImageData
*data
;
61 o
= (Object
*)DoSuperMethodA(cl
, o
, (Msg
)msg
);
65 data
= INST_DATA(cl
, o
);
67 data
->image
= (struct CoolImage
*)GetTagData(COOLIM_CoolImage
, 0, msg
->ops_AttrList
);
71 CoerceMethod(cl
, o
, OM_DISPOSE
);
74 data
->bgcol
= GetTagData(COOLIM_BgColor
,
75 (data
->image
->pal
[0] << 16) | (data
->image
->pal
[1] << 8) | data
->image
->pal
[2],
79 if ((data
->pal
= AllocVec(data
->image
->numcolors
* sizeof(ULONG
), MEMF_PUBLIC
)))
84 for(i
= 0; i
< data
->image
->numcolors
; i
++)
86 *p
++ = (data
->image
->pal
[i
* 3] << 16) |
87 (data
->image
->pal
[i
* 3 + 1] << 8) |
88 (data
->image
->pal
[i
* 3 + 2]);
102 /****************************************************************************************/
104 static IPTR
coolimage_dispose(Class
* cl
, Object
* o
, Msg msg
)
107 struct CoolImageData
*data
;
109 data
= INST_DATA(cl
, o
);
111 if (data
->pal
) FreeVec(data
->pal
);
113 return DoSuperMethodA(cl
, o
, msg
);
116 /****************************************************************************************/
118 static IPTR
coolimage_draw(Class
*cl
, Object
*o
, struct impDraw
*msg
)
120 struct CoolImageData
*data
;
123 data
= INST_DATA(cl
, o
);
125 x
= IM(o
)->LeftEdge
+ msg
->imp_Offset
.X
;
126 y
= IM(o
)->TopEdge
+ msg
->imp_Offset
.Y
;
128 if (CyberGfxBase
&& (GetBitMapAttr(msg
->imp_RPort
->BitMap
, BMA_DEPTH
) >= 15))
130 data
->pal
[0] = data
->bgcol
;
132 WriteLUTPixelArray((APTR
)data
->image
->data
,
149 /****************************************************************************************/
150 /****************************************************************************************/
151 /****************************************************************************************/
153 AROS_UFH3S(IPTR
, cool_imageclass_dispatcher
,
154 AROS_UFHA(Class
*, cl
, A0
),
155 AROS_UFHA(Object
*, obj
, A2
),
156 AROS_UFHA(Msg
, msg
, A1
))
162 switch (msg
->MethodID
)
165 retval
= coolimage_new(cl
, obj
, (struct opSet
*)msg
);
169 retval
= coolimage_dispose(cl
, obj
, msg
);
173 retval
= coolimage_draw(cl
, obj
, (struct impDraw
*)msg
);
177 retval
= DoSuperMethodA(cl
, obj
, msg
);
180 } /* switch (msg->MethodID) */
187 /****************************************************************************************/
191 /****************************************************************************************/
193 BOOL
InitCoolImageClass(struct Library
*CyberGfxBase
)
198 cool_cybergfxbase
= CyberGfxBase
;
200 if (IntuitionBase
&& GfxBase
&& UtilityBase
&& SysBase
)
202 if (!cool_imageclass
)
204 cool_imageclass
= MakeClass(NULL
, IMAGECLASS
, NULL
, sizeof(struct CoolImageData
), 0UL);
209 cool_imageclass
->cl_Dispatcher
.h_Entry
= (HOOKFUNC
)cool_imageclass_dispatcher
;
217 /****************************************************************************************/
219 void CleanupCoolImageClass(void)
223 FreeClass(cool_imageclass
);
224 cool_imageclass
= NULL
;
228 /****************************************************************************************/