Datatypes picture class with alpha

8 posts / 0 new
Last post
alfkil
alfkil's picture
Offline
Last seen: 4 months 1 week ago
Joined: 2011-05-10 22:02
Datatypes picture class with alpha

Hi all,

I am trying to load an image 128x128 with an alpha channel ilbm format made with sketchblock into a piece of code using datatypes library. I have never done anything before with datatypes, and thus I am at lack of knowledge of how to make it look and work properly. The problem is, if I load an image without alpha channel, it is displayed correctly, but the alpha image I want is displayed with solid alpha and just as a black box. The image is a black to white gradient with alpha corresponding, so that could be the issue here.

I have tried following the example on amigaos wiki on picture class, and it gives the above result. Then I am trying to use the PDTM_READPIXELARRAY method, but I cannot get it to not crash. I can supply my code if anyone wants to barf at it, but I would much rather see an actual working example of how to load an 32-bit image with alpha channel into a BitMap structure using datatypes library, if anyone has it. Thanks.

Hans
Hans's picture
Offline
Last seen: 4 months 3 weeks ago
Joined: 2010-12-09 22:04
Re: Datatypes picture class with alpha

@alfkil

Download the Composite3DDemo source code (http://hdrlab.org.nz/projects/amiga-os-4-projects/c3d/), and have a look in C3D/C3DTexture.cpp.

Hans

Join the Kea Campus - upgrade your skills; support my work; enjoy the Amiga corner.
https://keasigmadelta.com/ - see more of my work

alfkil
alfkil's picture
Offline
Last seen: 4 months 1 week ago
Joined: 2011-05-10 22:02
Thanks Hans, that seems to

Thanks Hans, that seems to have solved it. I was trying something along the same lines but was not properly informed on the details. So, as for the comment in your code on picture class leaving out alpha if you try and just extract the bitmap, wouldn't it be a good idea to implement that comment in the autodocs or wiki? And one last thing: Why do I need to lock the bitmap during extraction with READPIXELARRAY?

alfkil
alfkil's picture
Offline
Last seen: 4 months 1 week ago
Joined: 2011-05-10 22:02
Answered my own question.

Answered my own question. Thanks for the pointer.

alfkil
alfkil's picture
Offline
Last seen: 4 months 1 week ago
Joined: 2011-05-10 22:02
Ok, I was not entirely

Ok, I was not entirely done... How do I extract the alpha channel as an ALPHA8 bitmap to use as COMPTAG_SrcAlphaMask? I have tried BltBitMapTags and Compositing from the truecolor bitmap to an alpha bitmap, but I seem to be stuck.

alfkil
alfkil's picture
Offline
Last seen: 4 months 1 week ago
Joined: 2011-05-10 22:02
Fixed it, but the process is

Fixed it, but the process is rather complicated. I have to use p96Read/WritePixelArray and the alpha bitmap has to be not allocated by p96AllocBitMap for some strange reason but rather by graphics.library with a window bitmap as friend.

jabirulo
jabirulo's picture
Offline
Last seen: 1 month 3 weeks ago
Joined: 2013-05-30 00:53
Don't know if this piece of

Don't know if this piece of source code will help:

  1. ...
  2. struct Screen *scr;
  3.  
  4.  
  5. picObject = IDataTypes->NewDTObject("my_image.ilbm", PDTA_Screen,scr,
  6. PDTA_DestMode,PMODE_V43, DTA_GroupID,GID_PICTURE,
  7. TAG_DONE);
  8. ...
  9. struct BitMap *tempBM = NULL;
  10. LONG lock;
  11. struct RenderInfo ri;
  12. struct RastPort *rp;
  13. float scaleflag;
  14.  
  15. tempBM = IP96->p96AllocBitMap(IMG_W, IMG_H, 32, 0L, NULL, RGBFB_A8R8G8B8);
  16. if( (lock = IP96->p96LockBitMap( tempBM, (UBYTE *)&ri, sizeof(ri) )) )
  17. {// to pass the Alpha info from the DT object to the memory (RenderInfo) of the bitmap
  18. IIntuition->IDoMethod(picObject, PDTM_READPIXELARRAY, ri.Memory,
  19. PBPAFMT_ARGB, ri.BytesPerRow,
  20. 0, 0, IMG_W, IMG_H);
  21.  
  22. IP96->p96UnlockBitMap(tempBM, lock);
  23. }
  24.  
  25. IGraphics->CompositeTags(COMPOSITE_Src_Over_Dest, tempBM, rp->BitMap,
  26. COMPTAG_SrcWidth,IMG_W, COMPTAG_SrcHeight,IMG_H,
  27. COMPTAG_ScaleX,COMP_FLOAT_TO_FIX(scaleflag),
  28. COMPTAG_ScaleY,COMP_FLOAT_TO_FIX(scaleflag),
  29. COMPTAG_Flags,COMPFLAG_SrcFilter,
  30. TAG_DONE);
  31.  
  32. IP96->p96FreeBitMap(tempBM);
  33. ...

AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P

Hans
Hans's picture
Offline
Last seen: 4 months 3 weeks ago
Joined: 2010-12-09 22:04
Re: Datatypes picture class with alpha

@alfkil

Fixed it, but the process is rather complicated. I have to use p96Read/WritePixelArray and the alpha bitmap has to be not allocated by p96AllocBitMap for some strange reason but rather by graphics.library with a window bitmap as friend.

Yes, extracting the alpha channel (or any channel) has to be done manually.

It's very strange that you have to allocate it via the graphics.library wth a window bitmap as friend. That doesn't sound right, as an RGBFB_ALPHA8 bitmap should be the same either way.

Hans

Join the Kea Campus - upgrade your skills; support my work; enjoy the Amiga corner.
https://keasigmadelta.com/ - see more of my work

Log in or register to post comments