Page 1 of 1

Convert any Icon to BMP,JPG or PNG using PB [Windows]

Posted: Mon Sep 23, 2019 10:57 am
by RASHAD
Hi
- Use size 32x32-64x64-128x128-256x256

Code: Select all

LoadImage(0,"g:\mmedia\icons\About.ico")
Size = 128
imgH = CopyImage_(ImageID(0),#IMAGE_ICON,128,128,0)
CreateImage(1,128,128)
StartDrawing(ImageOutput(1))
  DrawImage(imgH,0,0)
StopDrawing()

SaveImage(1,GetHomeDirectory()+"icon.bmp")
OR using Transparent PNG

Code: Select all

UsePNGImageEncoder()

imgH = LoadImage_(GetModuleHandle_(0),"g:\mmedia\icons\About.ico",#IMAGE_ICON,128,128,#LR_LOADFROMFILE | #LR_LOADTRANSPARENT)

CreateImage(1,128,128 ,32, #PB_Image_Transparent)
StartDrawing(ImageOutput(1))
  DrawImage(imgH,0,0)
StopDrawing()

SaveImage(1,GetHomeDirectory()+"icon.png", #PB_ImagePlugin_PNG)

Re: Convert any Icon to BMP,JPG or PNG using PB [Windows]

Posted: Tue Sep 24, 2019 8:23 am
by BarryG
Thanks for that RASHAD. So short compared to an old procedure I was using.

Re: Convert any Icon to BMP,JPG or PNG using PB [Windows]

Posted: Tue Sep 24, 2019 4:44 pm
by RASHAD
Hi Barry
Thanks mate

Re: Convert any Icon to BMP,JPG or PNG using PB [Windows]

Posted: Tue Sep 24, 2019 7:32 pm
by VB6_to_PBx
RASHAD , thanks for these examples !

is there any PB Code to create a transparent Icon from a transparent .PNG picture ??

or even create a Icon from a .BMP picture ??

Re: Convert any Icon to BMP,JPG or PNG using PB [Windows]

Posted: Tue Sep 24, 2019 7:55 pm
by RASHAD
Hi VB6_to_PBx
viewtopic.php?f=12&t=59815&hilit=icon

Of course I did advanced version after that but no need to post it as long as the the posted one do the job

Re: Convert any Icon to BMP,JPG or PNG using PB [Windows]

Posted: Wed Sep 25, 2019 5:33 pm
by VB6_to_PBx
RASHAD wrote:Hi VB6_to_PBx
viewtopic.php?f=12&t=59815&hilit=icon

Of course I did advanced version after that but no need to post it as long as the the posted one do the job

thanks RASHAD for that Link ,

i had good results converting Pics to Icons in quick tryout of your Code