UnderwareDESIGN

PlayBASIC => Beginners => Topic started by: dexter on September 07, 2005, 01:34:45 AM

Title: Resize/Scale an Image
Post by: dexter on September 07, 2005, 01:34:45 AM
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?  :) )
Title: Resize/Scale an Image
Post by: Draco9898 on September 07, 2005, 04:59:22 AM
turn it into a sprite, and scale accordingly
Title: Resize/Scale an Image
Post by: kevin on September 07, 2005, 07:49:01 AM
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.


[pbcode]

 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

[/pbcode]


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 (http://playbasic.com/help.php?page=IMAGES.SCALEIMAGE)


Title: Resize/Scale an Image
Post by: dexter on September 07, 2005, 10:13:31 AM
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!)
Title: Resize/Scale an Image
Post by: kevin on September 07, 2005, 10:18:49 AM
I hope empty throws in a few popups then :)
Title: Resize/Scale an Image
Post by: empty on September 07, 2005, 12:06:34 PM
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. :)