Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Cutting up a (large) picture
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Badsniper




PostPosted: Fri Jun 03, 2011 2:57 pm   Post subject: Cutting up a (large) picture

I am trying to make my program take a picture (4000 x 8000 pixels) and cut it into 16 smaller parts.

But it's not working!

When I tried it yesterday with a 4000 x 6000 picture it worked, but not with the pictures I'm using now...


Turing:

View.Set ("graphics:4001;8001")

var pic : int := Pic.FileNew ("FullLevel1.jpg")
var sp : int
var count : int := 0
var height : int := Pic.Height (pic)
var width : int := Pic.Width (pic)

Pic.Draw (pic, 0, 0, 0)

for x : 0 .. width - width div 4 by width div 4
    for y : 0 .. height - height div 4 by height div 4
        count += 1
        sp := Pic.New (x, y, x + width div 4, y + height div 4)
        Pic.Save (sp, "level1(" + intstr (count) + ").bmp")
    end for
end for
Sponsor
Sponsor
Sponsor
sponsor
DemonWasp




PostPosted: Fri Jun 03, 2011 3:44 pm   Post subject: RE:Cutting up a (large) picture

You cut out most of the helpful questions from the posting template. What fails? What error message do you get? What have you tried to do to fix this?

Also, that image is 32M pixels, or about 96MB of data, if saved as a BMP. I seem to recall Turing not liking HUGE images.

There is a much more efficient way of expressing your level data than such a huge image.
Badsniper




PostPosted: Fri Jun 03, 2011 4:03 pm   Post subject: Re: Cutting up a (large) picture

Sorry about not mentioning that...

Well It can cut up the first 8 images, and it saves them, but the next 8 are just blank white pictures.

The file that is cut up is a JPG, and it's about 1.5 megabytes.

I think it's because when i draw the picture it only draws half. I've tried changing the "View.Set" part to like 10000 by 10000, but it still doesn't work.
DemonWasp




PostPosted: Fri Jun 03, 2011 7:45 pm   Post subject: RE:Cutting up a (large) picture

This probably has to do with some undocumented behaviour in the way the Windows OS draws oversized windows, the way Turing allocates windows, the way Turing loads and draws images, and so forth. It may be (very) difficult to solve definitively.


The other distinct possibility is that since you're saving as .BMP, you may be running out of space on whatever you're saving to, if it doesn't have much (an older USB drive, for example). Subdivided, the image will still be 96MB, just spread around a bunch of different files.


If that isn't the case, then (as a very hack-ish solution) I would suggest that you make the window the size of the section you want to cut out, and re-draw the large picture in a different position before each "cut".

You could also throw in an Input.Pause() so that it waits for you to press Enter (or any other key) before proceeding, so that you can see what's drawn at each stage.
Badsniper




PostPosted: Fri Jun 03, 2011 11:31 pm   Post subject: Re: Cutting up a (large) picture

Thanks for giving me the Idea of redrawing the picture. I got it.

Turing:

View.Set ("graphics:2001;1001")

var pic : int := Pic.FileNew ("FullLevel1.jpg")
var sp : int
var count : int := 0
var height : int := Pic.Height (pic)
var width : int := Pic.Width (pic)

for x : 0 .. width - width div 4 by width div 4
    for y : 0 .. height - height div 4 by height div 4
        Pic.Draw (pic, -1 * x, -1 * y, 0)
        count += 1
        sp := Pic.New (0, 0, maxx, maxy)
        Pic.Save (sp, "level1(" + intstr (count) + ").bmp")
        Pic.Free (sp)
    end for
end for


basically, I draw the picture at different places and save the selection that is on the screen. Thanks!
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: