Plugin Cafe Homepage
Forum Home Forum Home > Plugin Cafe > SDK Help
  New Posts New Posts
  FAQ FAQ  Forum Search   Register Register  Login Login

DrawBitmap and AllowAlpha

 Post Reply Post Reply
Author
Message
peterakos View Drop Down
Member
Member


Joined: 2015 Jul 13
Online Status: Offline
Posts: 304
Post Options Post Options   Quote peterakos Quote  Post ReplyReply Direct Link To This Post Topic: DrawBitmap and AllowAlpha
    Posted: 2017 Jun 29 at 3:03am

User Information:

Cinema 4D Version:   R18 
Platform:   Windows  ;   
Language(s):     C++  ;   

---------

Hello.

I have a GeUserArea and I inherit its DrawMsg to draw 2 bitmaps on top of each other.
First, I use DrawBitmap to draw the background image and then I draw the topmost bitmap which requires BMP_ALLOWALPHA .

The problem is that using BMP_ALLOWALPHA shows the background color DrawSetPen(COLOR_BG) instead of the background image. 

How can I fix that ?

Thank you.


Edited by peterakos - 2017 Jun 29 at 3:08am
Back to Top
NiklasR View Drop Down
Member
Member


Joined: 2010 Dec 13
Location: Germany
Online Status: Offline
Posts: 2550
Post Options Post Options   Quote NiklasR Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Jun 29 at 11:30am
As far as I know, the only solution is to use a GeClipMap. However, that class does only support direct
blitting, without scaling.. Doing the scaling in C++ is pretty darn slow on bigger images and causes my
dialog to lag horribly when the user area is resized.

I'd love to know if there was actually a way to use DrawBitmap() with proper alpha support, too.


Edited by NiklasR - 2017 Jun 29 at 11:32am
Back to Top
peterakos View Drop Down
Member
Member


Joined: 2015 Jul 13
Online Status: Offline
Posts: 304
Post Options Post Options   Quote peterakos Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Jun 30 at 3:11am
Hello and thank you very much for your answer.

So basically, I will set the bitmap to a GeClipMap and draw the stored bitmap, correct ?
Inside DrawMsg:
BeginDraw();
BaseBitmap* base_bitmap = clip_map->GetBitmap();
DrawBitmap(base_bitmap, ........);
EndDraw();

I couldn't find any reference in the examples.

Thank you.
Back to Top
NiklasR View Drop Down
Member
Member


Joined: 2010 Dec 13
Location: Germany
Online Status: Offline
Posts: 2550
Post Options Post Options   Quote NiklasR Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Jun 30 at 3:29am
You would need to create a GeClipMap on which you combine the two BaseBitmaps to get your
final "image" that you want to draw on the GeUserArea. Something like

AutoAlloc<GeClipMap> map;  // cache that somewhere maybe
map->BeginDraw();
map->Blit(image1, ...);
map->Blit(image2, ...);
map->EndDraw();
BaseBitmap* final = map->GetBitmap();
userArea->DrawBitmap(final, ...);

Back to Top
peterakos View Drop Down
Member
Member


Joined: 2015 Jul 13
Online Status: Offline
Posts: 304
Post Options Post Options   Quote peterakos Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Jun 30 at 3:56am
I don't think this is going to work because my background image is scaled since it is drawn in a GeUserArea with DrawBitmap.

I have tried using Init (BaseBitmap *bm, BaseBitmap *alpha_channel) passing the image and a black/white image indicating the transparent regiong but it didn't work :(

So it appears that my only solution is to use a fixed background and use GeClipMap's blit, right ?

Thank you.


Edited by peterakos - 2017 Jul 07 at 12:31am
Back to Top
Andreas Block View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1540
Post Options Post Options   Quote Andreas Block Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Jul 06 at 9:27am
I'm sorry, we haven't come up with any other idea here.

Cheers,
Andreas
SDK Support Engineer
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.61 [Free Express Edition]
Copyright ©2001-2009 Web Wiz

This page was generated in 0.094 seconds.