Resize a picture

Post

Posted
Rating:
#1 (In Topic #939)
Avatar
Guru
cogier is in the usergroup ‘Guru’
Can anybody tell me how to resize a picture without using a Shell command?

Code (gambas)

  1.  Shell "convert pict.png -resize 100x100 /tmp/pict.png" Wait
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Enthusiast
PJBlack is in the usergroup ‘Enthusiast’
 picturebox with stretch = true ???

otherwise … the image class has a function called stretch
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Guru
cogier is in the usergroup ‘Guru’
I am aware of 'Stretch'. Much better to use Mode than stretch.

What I am doing gets a picture to line up with a GridView when being dragged. Below you can see it works. This allows me to resize the form and the image still lines up, so it needs to be exact. So sorry, 'Stretch' doesn't cut it!  

<IMG src="https://www.cogier.com/gambas/dragged1.png"> </IMG><IMG src="https://www.cogier.com/gambas/dragged2.png"> </IMG>
Online now: No Back to the top

Post

Posted
Rating:
#4
Avatar
Regular
Cedron is in the usergroup ‘Regular’
Does this "stretch" work for you?  It seems to do what your shell command intends.  (I just noticed PJBlack's second line, so here is an example.)

Ced

Code (gambas)

  1. '=============================================================================
  2. Public Sub Main()
  3.  
  4.         Dim P As Image = Image.Load("~/Pictures/Wallpaper1920/DogOnDock.JPG")
  5.        
  6.         Dim I As Image = P.Stretch(200, 200)
  7.  
  8.         I.Save("DoD.jpg")      
  9.  
  10. '=============================================================================
  11.  

.... and carry a big stick!
Online now: No Back to the top

Post

Posted
Rating:
#5
Guru
BruceSteers is in the usergroup ‘Guru’

cogier said

Can anybody tell me how to resize a picture without using a Shell command?

Code (gambas)

  1.  Shell "convert pict.png -resize 100x100 /tmp/pict.png" Wait

Image.Stretch

Code (gambas)

  1.  
  2. Dim hPic as Picture = Picture.Load(sMyPic)  ' original size
  3.  
  4. Dim hPicStretched As Picture = hPic.Image.Stretch(100,100).Picture ' resized picture
  5.  
  6.  
  7.  
Online now: No Back to the top

Post

Posted
Rating:
#6
Avatar
Guru
cogier is in the usergroup ‘Guru’
Opps, sorry PJBlack. You were right, as is everybody else as well. It works like a charm.

Reminder, I must read posts more carefully! :?
Online now: No Back to the top
1 guest and 0 members have just viewed this.