Hi,
I am looking for comments on the following code fragments that I am
using for the drawing of datatype image objects. It's not 100% MUI
related since it is independent of MUI but since there are some good
experts present on this list I thought I ask here. I would like the
code to work with current and previous versions of datatypes.library
and also supporting transparent colors where possible.
I devided the code into 4 sections: loading of an image, performing
display related stuff, drawing, and freeing of the object.
1. Loading a datatypes object is done prior to having any information
about the display environment. I am using the following:
Object *dto = (Object *)NewDTObject((char *)filename,
DTA_GroupID, GID_PICTURE,
PDTA_DestMode, PMODE_V43,
OBP_Precision, PRECISION_EXACT,
PDTA_Remap, FALSE,
TAG_DONE);
I am unsure here about OBP_Precision and PDTA_Remap. From the NDK3.9
autodocs I find that their applicability are both [I..] so I can only
place them here but I don't know what these tags really do. The
meaning of OBP_Precision seems relatively clear but the docs for
PDTA_Remap are somewhat unclear to me. Anybody knows more?
2. Once we know the display environment (e.g. in MUIM_Setup) I am
continuing like this (obj is my custom-class MUI object):
SetAttrs(dto,
PDTA_Screen, _screen(obj),
PDTA_UseFriendBitMap , TRUE,
TAG_DONE);
I am wondering if SetAttrs is the correct way to do this since there
is also SetDTAttrs but the latter also requires a window and a
requester parameter. Any idea?
The next steps from here are copied from some source that was posted
on this list a long time ago by Stefan (if I remember correctly, they
seem not to be in the mailing list archive):
struct FrameInfo fri = { 0 };
struct BitMapHeader *bmh = NULL;
struct BitMap *bm = NULL;
DoMethod(dto, DTM_FRAMEBOX, NULL,
&fri, &fri, sizeof(struct FrameInfo), 0);
if (fri.fri_Dimensions.Depth > 0) {
if (DoMethod(data->d_Object, DTM_PROCLAYOUT, NULL, 1)) {
bmh = pget(data->d_Object, PDTA_BitMapHeader);
if (bmh) {
GetDTAttrs(dto, PDTA_DestBitMap, &bm, TAG_DONE);
if (!bm) {
GetDTAttrs(dto, PDTA_BitMap, &bm, TAG_DONE);
}
}
}
}
I am not sure what all these functions do as the autodocs on them are
quite too short. E.g. for DTM_PROCLAYOUT you only find: "Layout
(remap) the picture on the application's process." I also don't know
what is the difference between GetAttrs (from intuition.library and
used in the pget call above) and GetDTAttrs?
3. Now we can draw the object. Starting with V44 there is a method
that we can use directly. So I continue in the following way:
BOOL success = FALSE;
if (DataTypesBase->lib_Version >= 44) {
APTR handle = ObtainDTDrawInfoA(dto, TAG_DONE);
if (handle) {
success = DrawDTObjectA(_rp(obj), dto,
x, y, w, h, 0, 0, TAG_DONE);
ReleaseDTDrawInfo(dto, handle);
}
}
if (!success) { /* draw with pre V44 functions */
APTR mask = NULL;
GetDTAttrs(dto, PDTA_MaskPlane, &mask, TAG_DONE);
if (mask) {
BltMaskBitMapRastPort(bm, 0, 0, _rp(obj),
x, y, w, h, 0xc0, mask);
} else {
BltBitMapRastPort(bm, 0, 0, _rp(obj), x, y, w, h, 0xc0);
}
}
I am wondering if there is any difference in using the new V44 method
and the one I am using for pre V44. It might be that V44 has some
capabilities for alpha blending. Is it worth checking for V44 or
would the fallback code work equally well?
Last but not least I would like to know from which version of
datatypes.library on transparent colors (the mask plane) are
supported. V40 seems to always give me a NULL mask, so I guess one
needs V43 or better?
4. The last step is too free the datatypes object once we don't need
it anymore. I simply call DisposeDTObject(dto) and assume that all
pointer I got the the object (BitMapHeader, BitMap, Mask) are freed by
the datatypes object itself.
Thanks for any comments,
Steffen
Visit http://www.amiga.dk/tumult for MUI-related
information, especially about MUI custom classes.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/MUI/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/MUI/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/