FBImage static Win/Lin 32/64-bit
-
- Posts: 993
- Joined: Nov 24, 2011 19:49
- Location: France
- Contact:
Re: FBImage static Win/Lin 32/64-bit
@Joshy
How can I get a (rectangle) part of an image? The image is loaded with LoadRGBAFile().
Thank you.
How can I get a (rectangle) part of an image? The image is loaded with LoadRGBAFile().
Thank you.
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: FBImage static Win/Lin 32/64-bit
Same as before with the GET command :-)Roland Chastain wrote:How can I get a (rectangle) part of an image? The image is loaded with LoadRGBAFile().
https://www.freebasic.net/wiki/wikka.ph ... etgraphics
e.g.
var LoadedImage = LoadRGBAFile("blabla.bla")
var NewImage = ImageCreate(100,100)
Get LoadedImage, (x,y) - STEP(99,99), NewImage
NOTE: !!! STEP(99,99) not STEP(100,100) !!!
Ask if you run in to trouble.
Joshy
-
- Posts: 993
- Joined: Nov 24, 2011 19:49
- Location: France
- Contact:
Re: FBImage static Win/Lin 32/64-bit
@Joshy
Perfect, thank you.
Perfect, thank you.
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: FBImage static Win/Lin 32/64-bit
For advanced use I created PutResize
you can cut a part of Image or Screen
optional scale it and put the result to Image or Screen
viewtopic.php?f=7&t=26672
MultiPut V2 optional scale and rotate Image and put the result on Screen or Image
viewtopic.php?f=7&t=24479&p=220305
Draw perspective correct Image as polygon 2D/3D
viewtopic.php?f=7&t=26090
Of course you can combine them.
Load an Image with FBImage
get a part of the loaded image with PutResize (optional scale it down or up)
put it rotated on the Screen or Image with Multiput V2
...
Joshy
you can cut a part of Image or Screen
optional scale it and put the result to Image or Screen
viewtopic.php?f=7&t=26672
MultiPut V2 optional scale and rotate Image and put the result on Screen or Image
viewtopic.php?f=7&t=24479&p=220305
Draw perspective correct Image as polygon 2D/3D
viewtopic.php?f=7&t=26090
Of course you can combine them.
Load an Image with FBImage
get a part of the loaded image with PutResize (optional scale it down or up)
put it rotated on the Screen or Image with Multiput V2
...
Joshy
Re: FBImage static Win/Lin 32/64-bit
Joshy,
In your code here:
I need the img variable to be 'shared'... but it doesn't work when I change it to:
what am I doing wrong?
Here is the error output (also, am I using the latest FBC?)
In your code here:
Code: Select all
#include once "FBImage.bi"
' load RGBA png (with alpha channel)
chdir exepath()
screenres 640,480,32 ' RGBA
line (0,0)-step(639,479),&HFF0000FF,BF
var img = LoadRGBAFile("lights_alpha.png")
put (0,0),img,ALPHA
sleep
ImageDestroy img
Code: Select all
var shared img = LoadRGBAFile("lights_alpha.png")
Here is the error output (also, am I using the latest FBC?)
Compiler output:
C:\blahblahblah\FBIDETEMP.bas(13) error 11: Expected constant in 'var shared img = LoadRGBAFile("lights_alpha.png".png")'
Results:
Compilation failed
System:
FBIde: 0.4.6
fbc: FreeBASIC Compiler - Version 1.05.0 (01-31-2016), built for win32 (32bit)
OS: Windows NT 6.2 (build 9200)
Re: FBImage static Win/Lin 32/64-bit
Expected constant in 'var shared img = LoadRGBAFile("lights_alpha.png".png")'leopardpm wrote:...
....................................................!................!....!
Re: FBImage static Win/Lin 32/64-bit
if you are pointing out the extra paranthesis... that was just a copy paste error into the forum... this gives same error:
Compiler output:
C:\FBIDETEMP.bas(13) error 11: Expected constant in 'var shared img = LoadRGBAFile("lights_alpha.png")'
Re: FBImage static Win/Lin 32/64-bit
https://www.freebasic.net/wiki/wikka.ph ... eyPgSharedleopardpm wrote:what am I doing wrong?
Shared variables can only be initialized with static values. You need to break it into two lines, meaning you can't use var here. You will need to use Dim.
Re: FBImage static Win/Lin 32/64-bit
You have to create img, then set it to a value in the next line.
I don't know what LoadRGBAFile("lights_alpha.png")' returns (any ptr , fbimage, ...)
I don't know what LoadRGBAFile("lights_alpha.png")' returns (any ptr , fbimage, ...)
Code: Select all
declare function load(s as string) as any ptr
dim shared as typeof(load("")) image 'or if you know the typeof put it in.
image=load("something")
function load(s as string) as any ptr
return imagecreate(200,200)
end function
Re: FBImage static Win/Lin 32/64-bit
sorry Imortis, I missed your reply.
Re: FBImage static Win/Lin 32/64-bit
so, this works... but is it the correct way to use FBimage to load an image? should I be using 'any ptr' as the variable type or something else?
Code: Select all
dim shared as any ptr img
img = LoadRGBAFile("lights_alpha.png")
Re: FBImage static Win/Lin 32/64-bit
Thanks for your help, BTW!
Re: FBImage static Win/Lin 32/64-bit
I just checked, any ptr is the type.
Re: FBImage static Win/Lin 32/64-bit
good
also... I usually take extended breaks from programming and forget how to use things...like libraries. I want to make sure I am doing it correctly:
I put the FBimage.bi file into my 'inc' folder in the Freebasic folder
libFBImage-32-static.a
libFBImage-64-static.a
into the 'win32' folder which is in the 'lib' folder:
also... I usually take extended breaks from programming and forget how to use things...like libraries. I want to make sure I am doing it correctly:
I put the FBimage.bi file into my 'inc' folder in the Freebasic folder
and I put the two weird files:C:\Program Files (x86)\FreeBASIC\inc
libFBImage-32-static.a
libFBImage-64-static.a
into the 'win32' folder which is in the 'lib' folder:
couldn't find help on using libraries... figured there would be a sticky in the library section, but alas, no luck there eitherC:\Program Files (x86)\FreeBASIC\lib\win32
Re: FBImage static Win/Lin 32/64-bit
I had to make a small change in the header to compile with fbc 1.08.0.
Just changed
to
This is very useful BTW.
Thank you again, D.J.Peters.
Just changed
Code: Select all
imageinfo imgDst,,,,dpitch,d
Code: Select all
dim as integer w2,h2
imageinfo imgDst,w2,h2,,dpitch,d
Thank you again, D.J.Peters.