2 Copyright © 1995-2007, 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
)
58 struct CoolImageData
*data
;
60 o
= (Object
*)DoSuperMethodA(cl
, o
, (Msg
)msg
);
64 data
= INST_DATA(cl
, o
);
66 data
->image
= (struct CoolImage
*)GetTagData(COOLIM_CoolImage
, 0, msg
->ops_AttrList
);
70 CoerceMethod(cl
, o
, OM_DISPOSE
);
73 data
->bgcol
= GetTagData(COOLIM_BgColor
,
74 (data
->image
->pal
[0] << 16) | (data
->image
->pal
[1] << 8) | data
->image
->pal
[2],
78 if ((data
->pal
= AllocVec(data
->image
->numcolors
* sizeof(ULONG
), MEMF_PUBLIC
)))
83 for(i
= 0; i
< data
->image
->numcolors
; i
++)
85 *p
++ = (data
->image
->pal
[i
* 3] << 16) |
86 (data
->image
->pal
[i
* 3 + 1] << 8) |
87 (data
->image
->pal
[i
* 3 + 2]);
101 /****************************************************************************************/
103 static IPTR
coolimage_dispose(Class
* cl
, Object
* o
, Msg msg
)
105 struct CoolImageData
*data
;
107 data
= INST_DATA(cl
, o
);
109 if (data
->pal
) FreeVec(data
->pal
);
111 return DoSuperMethodA(cl
, o
, msg
);
114 /****************************************************************************************/
116 static IPTR
coolimage_draw(Class
*cl
, Object
*o
, struct impDraw
*msg
)
118 struct CoolImageData
*data
;
121 data
= INST_DATA(cl
, o
);
123 x
= IM(o
)->LeftEdge
+ msg
->imp_Offset
.X
;
124 y
= IM(o
)->TopEdge
+ msg
->imp_Offset
.Y
;
126 if (CyberGfxBase
&& (GetBitMapAttr(msg
->imp_RPort
->BitMap
, BMA_DEPTH
) >= 15))
128 data
->pal
[0] = data
->bgcol
;
130 WriteLUTPixelArray((APTR
)data
->image
->data
,
147 /****************************************************************************************/
148 /****************************************************************************************/
149 /****************************************************************************************/
151 AROS_UFH3S(IPTR
, cool_imageclass_dispatcher
,
152 AROS_UFHA(Class
*, cl
, A0
),
153 AROS_UFHA(Object
*, obj
, A2
),
154 AROS_UFHA(Msg
, msg
, A1
))
160 switch (msg
->MethodID
)
163 retval
= coolimage_new(cl
, obj
, (struct opSet
*)msg
);
167 retval
= coolimage_dispose(cl
, obj
, msg
);
171 retval
= coolimage_draw(cl
, obj
, (struct impDraw
*)msg
);
175 retval
= DoSuperMethodA(cl
, obj
, msg
);
178 } /* switch (msg->MethodID) */
185 /****************************************************************************************/
189 /****************************************************************************************/
191 BOOL
InitCoolImageClass(struct Library
*CyberGfxBase
)
195 cool_cybergfxbase
= CyberGfxBase
;
197 if (IntuitionBase
&& GfxBase
&& UtilityBase
) // && SysBase)
199 if (!cool_imageclass
)
201 cool_imageclass
= MakeClass(NULL
, IMAGECLASS
, NULL
, sizeof(struct CoolImageData
), 0UL);
206 cool_imageclass
->cl_Dispatcher
.h_Entry
= (HOOKFUNC
)cool_imageclass_dispatcher
;
214 /****************************************************************************************/
216 void CleanupCoolImageClass(void)
220 FreeClass(cool_imageclass
);
221 cool_imageclass
= NULL
;
225 /****************************************************************************************/