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;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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

Hrm, did you try using xScale and yScale?

If so, were the results the same?

thanks Peach -- fixed it! :)

for anyone who is interested;

1
2
3
4
5
6
7
8
9
10
11
12
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

Excellent - thanks for sharing updated code for others.

Peach :)

views:1440 update:2012/1/9 8:53:30
corona forums © 2003-2011