2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
5 Desc: Graphics function AllocSpriteDataA()
8 #include <proto/exec.h>
9 #include <proto/graphics.h>
10 #include <proto/utility.h>
11 #include <aros/debug.h>
12 #include <graphics/gfx.h>
13 #include <graphics/sprite.h>
14 #include <graphics/scale.h>
15 #include <utility/tagitem.h>
16 #include <exec/exec.h>
18 #include "graphics_intern.h"
20 /*****************************************************************************
23 #include <proto/graphics.h>
25 AROS_LH2(struct ExtSprite
*, AllocSpriteDataA
,
28 AROS_LHA(struct BitMap
*, bitmap
, A2
),
29 AROS_LHA(struct TagItem
*, tagList
, A1
),
32 struct GfxBase
*, GfxBase
, 170, Graphics
)
37 bitmap - pointer to a bitmap. This bitmap provides the source data
39 tags - pointer to a taglist
42 SPRITEA_Width (ULONG) - Width of the sprite. If bitmap is smaller it will
43 be filled on the right side with transparent
44 pixels. Defaults to 16.
45 SPRITEA_XReplication (LONG) - 0 - perform a 1 to 1 conversion
46 1 - each pixel from the source is replicated twice
47 2 - each pixel is replicated 4 times.
48 -1 - skip every 2nc pixel in the source bitmap
49 -2 - only include every fourth pixel from the source.
50 SPRITEA_YReplication (LONG) - like SPRITEA_YReplication, but for vertical direction.
51 SPRITEA_OutputHeight (ULONG) - Output height of the sprite. Must be at least as high
52 as the bitmap. Defaults to bitmap height.
53 SPRITEA_Attach - (Not implemented)
56 SpritePtr - pointer to a ExtSprite structure,
57 or NULL if there is a failure.
58 You should pass this pointer to FreeSpriteData()
59 when this sprite is not needed anymore.
74 ******************************************************************************/
78 struct ExtSprite
*sprite
= NULL
;
81 #define SCALE_NORMAL 16
82 ULONG height
= (ULONG
)GetBitMapAttr(bitmap
, BMA_HEIGHT
);
84 struct TagItem
* tstate
= tagList
;
86 struct BitScaleArgs bsa
;
87 LONG xrep
= 0, yrep
= 0;
89 memset(&bsa
, 0, sizeof(bsa
));
91 while (NULL
!= (tag
= NextTagItem(&tstate
))) {
92 switch (tag
->ti_Tag
) {
97 case SPRITEA_XReplication
:
101 case SPRITEA_YReplication
:
105 case SPRITEA_OutputHeight
:
106 if (tag
->ti_Data
> (ULONG
)GetBitMapAttr(bitmap
, BMA_HEIGHT
)) {
109 height
= tag
->ti_Data
;
112 case SPRITEA_Attached
:
119 sprite
= AllocVec(sizeof(*sprite
), MEMF_PUBLIC
| MEMF_CLEAR
);
120 if (NULL
!= sprite
) {
122 bsa
.bsa_SrcWidth
= GetBitMapAttr(bitmap
, BMA_WIDTH
);
123 bsa
.bsa_SrcHeight
= GetBitMapAttr(bitmap
, BMA_HEIGHT
);
126 bsa
.bsa_XDestFactor
= SCALE_NORMAL
<< xrep
;
128 bsa
.bsa_XDestFactor
= SCALE_NORMAL
>> (-xrep
);
132 bsa
.bsa_YDestFactor
= SCALE_NORMAL
<< yrep
;
134 bsa
.bsa_YDestFactor
= SCALE_NORMAL
>> (-yrep
);
137 bsa
.bsa_XSrcFactor
= SCALE_NORMAL
;
138 bsa
.bsa_YSrcFactor
= SCALE_NORMAL
;
139 bsa
.bsa_SrcBitMap
= bitmap
;
140 bsa
.bsa_DestBitMap
= AllocBitMap(width
,
143 BMF_CLEAR
|BMF_DISPLAYABLE
,
147 sprite
->es_SimpleSprite
.height
= height
;
148 sprite
->es_SimpleSprite
.x
= 0;
149 sprite
->es_SimpleSprite
.y
= 0;
150 sprite
->es_SimpleSprite
.num
= 0;
151 sprite
->es_wordwidth
= width
>> 4;
152 sprite
->es_flags
= 0;
153 sprite
->es_BitMap
= bsa
.bsa_DestBitMap
;
160 } /* AllocSpriteDataA */