display.save errors

Hi there,

I am trying to display an image which the user loads from their device. I have that bit all sorted, the problem comes when I try to resize it – here is my code;

  
local function sessionComplete ( event )  
 t = event.target  
  
 if t == nil then  
 print("t == nil")  
 else  
 local baseDir = system.DocumentsDirectory  
 t.width = t.width\*0.5;  
 t.height = t.height\*0.5;  
 display.save( t, "picture.jpg", baseDir )  
 t.alpha=0;  
 -- t.width = 198;   
 -- t.height = 283;  
 -- Outright changing of the width & height did not work, so I tried saving and reloading  
 end  
 r = display.newImageRect("picture.jpg", system.DocumentsDirectory, 198,283 )  
 r.x=100;  
end  
  

Instead of the image being resized to 198 x 283, it takes that portion from the image, essentially cropping it instead of resizing

What am I doing wrong?

Thanks,

Max [import]uid: 24641 topic_id: 20034 reply_id: 320034[/import]

Hrm, did you try using xScale and yScale?

If so, were the results the same? [import]uid: 52491 topic_id: 20034 reply_id: 78243[/import]

thanks Peach – fixed it! :slight_smile:

for anyone who is interested;

[code]

local function sessionComplete ( event )
t = event.target

if t == nil then
print(“t == nil”)
else
local baseDir = system.DocumentsDirectory
t.xScale = ( 198 / t.width )
t.yScale = ( 283 / t.height )
– ( 198 & 283 were the dimensions I wanted… )

end [import]uid: 24641 topic_id: 20034 reply_id: 78311[/import]

Excellent - thanks for sharing updated code for others.

Peach :slight_smile: [import]uid: 52491 topic_id: 20034 reply_id: 78333[/import]