I am the Forgotten Coder and after searching this forum i couldn't find a simple sub that loads a png file into an image. Maybe i didn't search enough ...
So my challenge to this community of coders is to "Make a sub with the name LoadPNG to load PNG files to an image".
Made some starting code for this challenge to avoid people saying "We do the work and this guy does nothing" LOL.
I think this challenge will benefit everyone is this community. I am doing this not just for me. :)
Code: Select all
'*******************************************************
'filename: pngtoimage.bas
'
'function: LoadPNG
'
'Description: loads a png image to an freebasic image
'
'Syntax: LoadPNG(file,imageid)
'
'parameters:
'
'> file: filepath to png image
'> imageid: id of image
'*******************************************************
#include "fbgfx.bi"
#if __FB_LANG__ = "fb"
Using FB '' Screen mode flags are in the FB namespace in lang FB
#endif
'************************************************
' HIDE CONSOLE
'************************************************
#If Defined(__FB_WIN32__)
declare function hideConsoleWindow alias "FreeConsole"() as long
hideConsoleWindow
#EndIf
declare sub loadPNG(file as string, image as any pointer)
windowtitle("LoadPNG")
screen 20,32 '1024x768
dim image as any pointer
dim file as string
dim as integer x, y
x=100
y=100
image=imagecreate(32,32, rgba(255,255,255,255)) 'white background
file="test.png" 'make 32 x 32 png file called test.png
do
loadPNG(file,image)
put (x,y), image 'position image in screen
sleep
imagedestroy image
loop until inkey=chr$(27)
sub loadPNG(file as string,image as any pointer)
'in here i am lost
'in here i am lost
'in here i am lost
'in here i am lost
end sub