this time i'm trying to understand how a picture can be loaded and displayed on amigaos4.
I'm talking about 32 bit png image with alpha channel.
the following code (WINDOW_BackFillName, "Sys:Prefs/Presets/Patterns/Chalk/ChalkBlue.brush) can load directly an image at window creation time, but i'm not sure if this image can be 32 bit png with alpha channel...
if ((winobj = IIntuition->NewObject (WindowClass,NULL,
WA_Flags, WFLG_CLOSEGADGET | WFLG_DRAGBAR | WFLG_DEPTHGADGET | WFLG_SIZEBBOTTOM | WFLG_SIZEGADGET | WFLG_ACTIVATE,
WA_IDCMP, IDCMP_VANILLAKEY | IDCMP_INTUITICKS,
WA_Width, scr->Width * 6 / 10,
WA_Height, scr->Height * 4 / 10,
What do you want to know ?
How to display an alpha picture on a Reaction window ?
Like these 2 littles alpha png pictures?
this would be interesting to know too.
I would like to know how to load an image from disk and display it on a window.
The image should be 32 bit with alpha, for future usage with blitting functions
Edit : post removed
It was not that I pasted here !
Nice! Thank you salass!
The returned bitmap could be blitted on a window?
I got some error:
passing argument 3 of 'IIntuition->IDoMethodA' from incompatible pointer type
'struct P96IFace' has no member named 'UnlockBitMap'
should this "IP96->UnlockBitMap(bm, lock);" be "IP96->p96UnlockBitMap(bm, lock)" ?
Is this line missing a semicolon? pbpa.pbpa_PixelFormat = PBPAFMT_ARGB
Just add a cast like so:
Yes to both questions.
Incredible! I corrected my teacher the Gran coder Master :P
Can you please add the little example of how to blit to a window?
Sorry, double post.
I made a simple example with a bouncing ARGB boing ball (boing ball PNG image found with google image search):
In a real program you should rather use timer.device than IDCMP_INTUITICKS but it works well enough here for this rather simple example.
Thank you again, salass. It works!
I get 2 times a warning for the line:
boing_bm = LoadBitMapARGB("PROGDIR:boing.png", &boing_width, &boing_height);
warning: pointer targets in passing argument 2 of 'LoadBitMapARGB' differ in signedness
Now, it is possible to blit beetween two bitmap? A sort of composing image in memory, then blit to a window?
Shouldn't happen unless you went and changed something.
I compiled with -Wall and -Werror which means if there was a warning it would be treated as an error and the compile would fail.
Prototype of function is (I changed the 2nd and 3rd parameters from "uint32 *" to "int32 *"):
struct BitMap *LoadBitMapARGB(CONST_STRPTR, int32 *, int32 *);
The boing_width and boing_height variables are both defined as int32.
Yes, just set BLITA_DestType to BLITT_BITMAP instead of BLITT_RASTPORT and pass a bitmap pointer to BLITA_Dest. BltBitMapTagList/Tags() is the new one size fits all replacement for the now deprecated BltBitMap(), BltBitMapRastPort(), BltMaskBitMapRastPort(), etc. functions.
struct BitMap *LoadBitMapARGB(CONST_STRPTR, uint32 *, uint32 *);
struct BitMap *LoadBitMapARGB(CONST_STRPTR, int32 *, int32 *);
and the warning disappeared.
Btw, if i resize the window, the loaded image disappear
two things remains to be done with the image:
1) i would like to make permanent the image (if i resize a window the image disappear)
2) i would like to use hardware accelerate functions (compositing) to blit the image
How can i do this?
If you explain what exactly you want to do and why you need the window to be resizable I could write a more appropriate example code.
No need a resizable window. It's just to learn in this case.
About the other way to blit (via compositing) is cause i want to use hw acceleration where possible and, also in this case, to learn.
i tried to use the composite tags instead of using regular blitting methods, but i don't get any image on screen.
Btw, i get this warning too:
warning: passing argument 4 of 'IGraphics->CompositeTags' from incompatible pointer type
That's because you need a bitmap as the destination for CompositeTags() so you need to composite blit into an off-screen bitmap first and then blit that into your window using BltBitMapTags().
This is what I do in my CDXL player, CDXLPlay (source code included).
So i should create a secondary bitmap where to blit via composite tags, then using again BltBitMapTags to blit to the window->Rport?
What's the benefit of this?
I mean, using the composite tags implies one more operation than regular blitting.
Proper graphics handling in a multitasking enviroment.
As you've been told, the destination of Composite is a bitmap. But your window does not own a bitmap, it only has a rastport which shares the screen's bitmap with all other windows on this screen.
If you blit into window->RPort->BitMap no clipping will be done and you most likely overwrite areas of the screen which do not belong to your application. Not to mention that coordinates will be all wrong.
If you need proper clipping (and you always need it) you have to blit into the window's rastport, not into the screen's bitmap.
I added an additional example (boing2) which uses CompositeTags(), an offscreen bitmap and a simple refresh window:
Using an offscreen bitmap the drawing and blitting functions (apart from the one that blits to the window) don't need to care about clipping so it may pay off in the end if you have more than one graphic to blit. Also it makes implementing IDCMP_REFRESHWINDOW pretty easy for a simple refresh window.
Using ILayers->DoHookClipRects() and COMPTAG_DestX/DestY/DestWidth/DestHeight tags you could do a clipped composite blit but it might be more trouble than it's worth with the above in mind.
I just want to thank you all of you for all these explainations.
Coming from Windows world, having forgot all of amiga programming world, it's really hard for me to step in to the reaction/intuition/ macro, not macro and so on...
Btw, thanks to all of you, i'm slowly learning how to manage things on the amiga way.
Thank you to Hans de Ruiter to for his precious infos
I used your example and now i can load 32 bit png image into a window, using simple bitblit or composite tag.
Btw, i have some problems.
I created a secondary off screen bitmap just like in your example.
Now, if i load a secondary bitmap (a png) and try to blit this into another window, i get some graphics errors (glitch) in the destination window. it could be the result of a non standard 32 bit png image? I created this image with PhotoShop, btw.
Another thing i noticed is that if i blit the image into a window with a backfill, the blitted image is not clipped.
Not knowing what exactly you're doing it's hard to tell what you're doing wrong.
What do you mean by not being clipped? Do you mean that it draws outside your window or just that it overdraws your window's border graphics? If it's the latter you can fix it by using a Gimme-Zero-Zero (GZZ) window.
Note that GZZ windows use more resources than regular windows as they have two layers (one for the borders and one for the window contents). Also when using a GZZ window you do not need to offset rendering coordinates with window->BorderLeft and window->BorderTop as you would otherwise.
i solved the glitches problem: wrong width and height blit values.
Maybe i used the wrong term using "clipping", sorry.
What i'm not able to do is "transparent blitting".
I thought so cause i have an hold code with two function (make_alpha_clip) and (allocate_alpha_bitmap) that get me confused. Sorry for this.
Solved the transparent blit too using Hans suggestions about compositing.
With the Picasso96 functions now deprecated, what is the new V54 graphics version of this? All I get now, without the pdtBlitPixelArrayBuffer lines, is a blank box the size of the image.
The LoadBitMapARGB() function rewritten using graphics.library functions:
Thank you. I was close, but I was supplying the tag values for LockBitMapTags() instead of "setting/getting" them for the lines below.