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:
01046622
Vues:
24
>Herman!
>
>You also have been in the Thread "File association icons" (Starting with Message#1045284) and possibly do know what is coming now ;-) But for the others who might like to join and help us, here the status.
>
>We (Naomi to be precise) needs to get the associated Icons for different file types. However as she's working with Grids instead of ListViews, she'd be better off with Bitmaps instead of Icons.
>Using my IconBuddy-Class as well as Alexander Golovlev's gpImage-Class this can be achieved with a few lines of code. This is how it goes:
>
>
>ogpInit    = newobject("gpinit", "gpImage.prg")  && <-- needed as a basis for gpImage
>ogpImage   = newobject("gpimage", "gpImage.prg")
>oIconBuddy = newobject("iconbuddy", "iconbuddy")
>
>*-- vars for the Icons
>oSmall     = null
>oLarge     = null
>
>*-- get the icons for an Excel-File
>? oIconBuddy.GetAssocIconPairObjects(getfile("xls"),@oLarge, @oSmall)
>
>*-- load the large Icon into the gpImage-Class
>? ogpImage.FromPicture(oLarge)
>
>*-- And save it as a bitmap
>? ogpImage.SaveAsBMP("XL_Large.bmp")
>
>*-- the small one too
>? ogpImage.FromPicture(oSmall)
>? ogpImage.SaveAsBMP("XL_Small.bmp")
>
>*-- And we're  D O N E ! !
>
>
>
>Problem however:
>The transparent color of the Icon is converted to black. Unfortnately I was not able to convince her that black-backgrounded icons really *are* cool, and so this is my task now to find a solution how to change the icon's transparent area to a color of choice (preferrably white) *before* converting them to a bitmap.
>
>Could You or any of the other GDI+/API - gurus please give us (me) a hand on that? I also invited Alexander Golovlev. I think he could be of great help.
>
>THX


Hi Frank,

No offense, but I think it is best if you address the question to ALL rather than directly to me (or one person only). The others might get lazy to help you!

Anyway, I'm not really fond with GDI+, I haven't play with it til today. So, I don't know much about it. So if it is okay for you to use GDI, then here is the step:

- Get the HICON (hLarge & hSmall) from your iconbuddy class.
- Use GetIconInfo() API to get the HBITMAP from each HICON. There are two HBITMAP on return, hBitmapColor and hBitmapMask.
- Copy the hBitmapColor to temporary DC (BitBlt using SRCCOPY)
- XOR the hBitmapMask to temporary DC (BitBlt using SRCPAINT / SRCINVERT)

After that you can read this article:

Storing an Image
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_7zfp.asp

Regards
Herman
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform