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

Share your advanced PureBasic knowledge/code with the community.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4659
Joined: Sun Apr 12, 2009 6:27 am

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

Post 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)
Egypt my love
BarryG
Addict
Addict
Posts: 3318
Joined: Thu Apr 18, 2019 8:17 am

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

Post by BarryG »

Thanks for that RASHAD. So short compared to an old procedure I was using.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4659
Joined: Sun Apr 12, 2009 6:27 am

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

Post by RASHAD »

Hi Barry
Thanks mate
Egypt my love
User avatar
VB6_to_PBx
Enthusiast
Enthusiast
Posts: 625
Joined: Mon May 09, 2011 9:36 am

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

Post 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 ??
 
PureBasic .... making tiny electrons do what you want !

"With every mistake we must surely be learning" - George Harrison
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4659
Joined: Sun Apr 12, 2009 6:27 am

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

Post 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
Egypt my love
User avatar
VB6_to_PBx
Enthusiast
Enthusiast
Posts: 625
Joined: Mon May 09, 2011 9:36 am

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

Post 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
 
PureBasic .... making tiny electrons do what you want !

"With every mistake we must surely be learning" - George Harrison
Post Reply