News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

Resize/Scale an Image

Started by dexter, September 07, 2005, 01:34:45 AM

Previous topic - Next topic

dexter

Is there an easy way to resize/scale an Image?
I know I could resize the Image before hand but I need to make a sort of thumbnail preview and I didn't want to double up all my Images.

I've searched the forum and checked the help system and can see how to apply a light source, mirror it, covert it to greyscale etc, but no way to resize.

Do I have to turn the image into a sprite and then scale the sprite or use the TextureQuad command?

If there isn't already a single line command would it be possible to add;
DrawImageScale ImageNumber,xpos,ypos,xSize,ySize,SolidFlag or something similar?

If there is already a command and I've missed it, I apologise, I have looked for it honest!  :blink:
(in which case would it be possible to add that search function to the help system soon please?  :) )

Draco9898

turn it into a sprite, and scale accordingly
DualCore Intel Core 2 processor @ 2.3 ghz, Geforce 8600 GT (latest forceware drivers), 2 gigs of ram, WIN XP home edition sp2, FireFox 2.

"You'll no doubt be horrified to discover that PlayBasic is a Programming Language." -Kevin

kevin

#2
There's no image resize command atm.  You can use TextureQuad though, this is pretty much how a resize image command would work anyway.  

This example bellow pretty much does what your asking for, although i've just noticed the transparent parameters are not available with TextureTri/TextureQuad.  Will have to hook those up later.


PlayBASIC Code: [Select]
  Setfps 10

Cls Rgb(30,40,50)
For Lp=0 to 100
circlec rnd(100),rnd(100),rnd(10),1,rndrgb()
Next
GetImage 1,0,0,64,64

Preparefximage 1

Do
Cls 0
DrawImage 1,100,100,0

For lp =0 to 10
Xpos=rnd(GetScreenWidth())
Ypos=rnd(GetScreenHeight())
ScaleX#=rndrange(50,1000)/100.0
ScaleY#=rndrange(50,1000)/100.0
DrawScaledImage(1,Xpos,Ypos,ScaleX#,scaley#)
next

Sync
loop


Function DrawScaledImage(ImageIndex,xpos,ypos,ScaleX#,ScaleY#)
if GetImageStatus(imageindex)
W=GetImageWidth(imageindex)
H=GetImageHeight(imageindex)

nw=w*scalex#
nh=h*scaley#
x1=xpos
y1=ypos
u1=0 * $10000
v1=0 * $10000
x2=xpos+nw
y2=ypos
u2=(w-1)*$10000
v2=0 * $10000
x3=xpos+nw
y3=ypos+nh
u3=(w-1)*$10000
v3=(h-1)*$10000
x4=xpos
y4=ypos+nh
u4=0 * $10000
v4=(h-1)* $10000

TextureQuad imageindex,x1,y1,u1,v1,x2,y2,u2,v2,x3,y3,u3,v3,x4,y4,u4,v4
endif
EndFunction





Quote(in which case would it be possible to add that search function to the help system soon please?

 on it's way.

See: PlayBASIC Documentation  Scale Image



dexter

Thanks Draco9898 & Kevin,

I thought I was on the right lines, the lack of transparent parameters shouldn't be a problem for what I require.

Looking forward to that searchable help. Like search engines, I'll start off searching for one thing and find out loads of other things in the process. (except it will all be useful and minus popups!)

kevin

#4
I hope empty throws in a few popups then :)

empty

#5
The next version will have an alphabetically sorted command index. A full text search option will come later.

QuoteI hope empty throws in a few popups then
Yep, negotiating with some companies re. ad space. :)