Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Convert Icon to Bitmap
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Versions des environnements
Visual FoxPro:
VFP 8 SP1
Divers
Thread ID:
01046527
Message ID:
01046668
Vues:
23
Frank!

>You are absolutely right. However when You start a new Thread over the weekend and adress it to ALL no one gets it directly and chances are high that no one sees it at all as on monday morning.
>Additionally in this case I wanted to address You, as I knew, You could be of help. ;-)

Okay, I can understand that. But there are many VFP'ers here that know GDI+ far beyond me! <g>


>"XOR the hBitmapMask to temporary DC", Yes sure. Yes, throw me on the floor and dance on my back - hey, I am a VFP - idiot from Germany. We need plain and simple words, examples, something like that.

Ouch..no need to be upset though <lol>, I'm a VFP'er too. And you're not an idiot, that's for real! :)

>OK, I know what You mean. I am not sure if I can make it on my own (all this DeviceContext stuff etc. I have done it, but I never really *understand* it as I do VFP) I already had found articles about the two bitmaps in the Icon and the IconInfo etc. But was not sure witch to pick for what - hope I'm not destroying my harddisk.
>

Ok, here is the sample:
#Define c0             chr(0)
#Define WORD_Size      2
#Define DWORD_Size     4
#Define HWND_DESKTOP   0
#Define SRCCOPY        0x00CC0020  &&  dest = source
#Define SRCINVERT      0x00660046  &&  dest = source XOR dest
#Define BITMAP_Size    (DWORD_Size*4) + (WORD_Size*2) + DWORD_Size

ls_IconInfo = DWord( 1 ) + replicate( c0, 16 )
GetIconInfo( th_Icon, @ls_IconInfo )
lh_BitmapMask = Buff2Num( ls_IconInfo, (DWORD_Size*3)+1, .T. )
lh_BitmapColor = Buff2Num( ls_IconInfo, (DWORD_Size*4)+1, .T. )

ls_Bitmap = replicate( c0, BITMAP_Size )
GetObject( lh_BitmapColor, BITMAP_Size, @ls_Bitmap )
ln_Width = Buff2Num( ls_Bitmap, (DWORD_Size*1)+1, .T. )
ln_Height = Buff2Num( ls_Bitmap, (DWORD_Size*2)+1, .T. )

lh_DC = GetDC( HWND_DESKTOP )

** Create compatible DC & Bitmap for the destination
lh_DestDC = CreateCompatibleDC( lh_DC )
lh_Bitmap = CreateCompatibleBitmap( lh_DC, ln_Width, lh_Height )
lh_OldBitmap = SelectObject( lh_DestDC, lh_Bitmap )

** Create a working (temporary) compatible DC
lh_TempDC = CreateCompatibleDC( lh_DC )

* Select hBitmapColor from IconInfo to temp DC
lh_OldTempBitmap = SelectObject( lh_TempDC, lh_BitmapColor )
* Copy to destination DC
BitBlt( lh_DestDC, 0,0, ln_Width, ln_Height, lh_TempDC, 0,0, SRCCOPY )

* Select hBitmapMask from IconInfo to temp DC
SelectObject( lh_TempDC, lh_BitmapMask )
* XOR to destination DC
BitBlt( lh_DestDC, 0,0, ln_Width, ln_Height, lh_TempDC, 0,0, SRCINVERT )

***
*** Here... lh_Bitmap is contained the new bitmap with white background
***
Now you can use that code in the article to save the bitmap or you can use GDI+ CreateFromHBitmap (???)


>Have a wonderful weekend

Thanks, and have a nice weekend for you too
Regards
Herman
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform