Use of DrawImageState

This forum is for general developer support questions.
Post Reply
User avatar
abalaban
Beta Tester
Beta Tester
Posts: 456
Joined: Mon Dec 20, 2010 2:09 pm
Location: France
Contact:

Use of DrawImageState

Post 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?
AmigaOne X1000 running AOS 4 beta
AmigaOne XE/G4
Amiga 1200/PPC 603e + BVision PPC
User avatar
thomasrapp
Posts: 318
Joined: Sun Jun 19, 2011 12:22 am

Re: Use of DrawImageState

Post 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.
User avatar
abalaban
Beta Tester
Beta Tester
Posts: 456
Joined: Mon Dec 20, 2010 2:09 pm
Location: France
Contact:

Re: Use of DrawImageState

Post 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 :?:
AmigaOne X1000 running AOS 4 beta
AmigaOne XE/G4
Amiga 1200/PPC 603e + BVision PPC
User avatar
LyleHaze
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 525
Joined: Sat Jun 18, 2011 5:06 pm
Location: North Florida, near the Big Bend

Re: Use of DrawImageState

Post 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).
User avatar
abalaban
Beta Tester
Beta Tester
Posts: 456
Joined: Mon Dec 20, 2010 2:09 pm
Location: France
Contact:

Re: Use of DrawImageState

Post 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.
AmigaOne X1000 running AOS 4 beta
AmigaOne XE/G4
Amiga 1200/PPC 603e + BVision PPC
Post Reply