Page 1 of 1

Use of DrawImageState

Posted: Thu May 09, 2013 3:24 pm
by abalaban
I'm willing to draw an image from AISS into a rastport. To do so I've created a Bitmap_ic object with the following code

Code: Select all

IIntuition->NewObject(pCtx->BitmapClass, NULL,
    BITMAP_SourceFile, "TBImages:list_ledred_s",
    BITMAP_DisabledSourceFile, "TBImages:list_ledred",
    BITMAP_Screen, pCtxt->Screen,
    BITMAP_Masking, TRUE,
TAG_END);
This call returns a non null object thus I'm assuming the call succeeded.

Then I'm trying to do

Code: Select all

IIntuition->DrawImageState(pCtxt->rp, (struct Image*)pCtxt->ledImage, 10, 10, IDS_NORMAL, pCtxt->dri);
Unfortunately nothing is displayed. Am I wrongly using DrawImageState? Am I wrongly assuming the NewObject call succeeded? Anything else?

Re: Use of DrawImageState

Posted: Thu May 09, 2013 6:16 pm
by thomasrapp
These two statements should work as expected, given that all variables contain the values which their names let believe. Like so often there is by far not enough code to see a mistake.

Re: Use of DrawImageState

Posted: Fri May 10, 2013 12:14 am
by abalaban
Thank you Thomas for your answer.

I'm trying to write a Docky which should display a led on or off.
Upon reception of DOCKYSET_Screen I'm executing the following statements:

Code: Select all

pCtxt->Screen = (struct Screen*)msgData;
pCtxt->dri = IIntuition->GetScreenDrawInfo(pCtxt->Screen);
pCtxt->ledImage = IIntuition->NewObject(pCtxt->BitmapClass, NULL,
    BITMAP_SourceFile, "TBImages:list_ledred_s",
    BITMAP_DisabledSourceFile, "TBImages:list_ledred",
    BITMAP_Screen, pCtxt->Screen,
    BITMAP_Masking, TRUE,
TAG_END);
Note that pCtxt->BitmapClass is obtained at docky initialization by the following

Code: Select all

pCtxt->BitmapClassLib = IIntuition->OpenClass("images/bitmap.image", 52, &(pCtxt->BitmapClass);
Then upon DOCKYSET_RedrawNow I'm doing:

Code: Select all

IGraphics->Move(pCtxt->rp, 10,10);
IIntuition->DrawImageState(pCtxt->rp, (struct Image*)pCtxt->ledImage, 0, 0, pCtxt->Activated?IDS_NORMAL:IDS_DISABLED, pCtxt->dri);
EDIT: Okay the problem was caused by the 'BITMAP_Masking', if I remove it everything works as expected. Now I'm trying to figure out how I can draw this bitmap without seeing this dark background... Probably something to do with the DOCKYGET_RenderMode but as soon as I put something different from DOCKYRENDERMODE_RPPA the AmiDock refuses to load it :?:

Re: Use of DrawImageState

Posted: Fri May 10, 2013 1:05 am
by LyleHaze
I have never played down at the Dockys, but I use LEDs a lot in some of my other projects..
In a recent project I load a 3 state red LED

myled = IIntuition->NewObject(
BitmapClass, NULL,
BITMAP_Transparent, TRUE,
BITMAP_Masking, TRUE,
BITMAP_Screen, scrn,
BITMAP_SourceFile, "tbimages:list_ledred_h", // one note
BITMAP_SelectSourceFile, "tbimages:list_ledred_s", // multinote
BITMAP_DisabledSourceFile, "tbimages:list_ledred", // no notes
TAG_END);

This works well with the following

IIntuition->DrawImageState(
rp,
(struct Image *)myled,
LeftEdge,
TopEdge,
draw_state,
di);

As Thomas pointed out, the devil may be in the details not shown.
This assumes that BitmapClass has been opened,
Draw_state is a value from 0 to 2,
rp is a nice RastPort to draw into, and
di is the result of a successful GetScreenDrawInfo(screen).

Re: Use of DrawImageState

Posted: Fri May 10, 2013 11:41 am
by abalaban
@Lyle,

thank you for your answer, I was probably editing my message when you were redacting your.
I think the problem may be caused by the Docky environment and the fact I was requesting a BITMAP_Masking. I'm investigating if it's not related to the DOCKYRENDERMODE_RPPA render mode.