Image chopping
Image chopping
What are the criteria for dividing an image file when loading it into a SPRITE array. It seems to be more intelligent than just chopping the screen into equal divisions. Does it recognise white space and/or objects? SPRITE "cards" LOAD "cards.png",14,4 seems to pick out just the cards.
Thanks
Andy Smith.
Thanks
Andy Smith.
- Mr. Kibernetik
- Site Admin
- Posts: 4786
- Joined: Mon Nov 19, 2012 10:16 pm
- My devices: iPhone, iPad, MacBook
- Location: Russia
- Flag:
Re: Image chopping
No, SPRITE LOAD just splits the sprite sheet into the specified amount of raws and columns.
Re: Image chopping
Thanks Mr K.
So that I can understand this better, can you tell me why;
X=0!Y=0!W=1366!H=129*A
SPRITE n$ SCAN X,Y, W,H
SPRITE n$ SAVE "cards4.png"
SPRITE S$ LOAD "cards4.png",13,A
gives the same result when A=1, a single suit, as when A=4. N$ is a simple image consisting of 13 cards across by 4 suits down. S$ picks up 13 spades but nothing else. I can’t understand this.
Thanks
Andy.
So that I can understand this better, can you tell me why;
X=0!Y=0!W=1366!H=129*A
SPRITE n$ SCAN X,Y, W,H
SPRITE n$ SAVE "cards4.png"
SPRITE S$ LOAD "cards4.png",13,A
gives the same result when A=1, a single suit, as when A=4. N$ is a simple image consisting of 13 cards across by 4 suits down. S$ picks up 13 spades but nothing else. I can’t understand this.
Thanks
Andy.
- Mr. Kibernetik
- Site Admin
- Posts: 4786
- Joined: Mon Nov 19, 2012 10:16 pm
- My devices: iPhone, iPad, MacBook
- Location: Russia
- Flag:
Re: Image chopping
Is card4.png file available?
Re: Image chopping
Attached
- Attachments
-
- BA70939E-4173-4B6D-9C17-7067B2D39D26.png (1.18 MiB) Viewed 5577 times
- Mr. Kibernetik
- Site Admin
- Posts: 4786
- Joined: Mon Nov 19, 2012 10:16 pm
- My devices: iPhone, iPad, MacBook
- Location: Russia
- Flag:
Re: Image chopping
This code:
works exactly as expected: it shows a sequence of 13*4 cards of all 4 suits.
Code: Select all
sprite 0 load "cards4.png",13,4
sprite 0 show
sprite 0 delay 0.5
sprite 0 loop
1 goto 1
Re: Image chopping
Maybe it’s my fault then but:
- you have used 0 which I assume is a single sprite in which case I don’t really understand the significance of the 13,4
- I wanted a named sprite array N$ with 52 separate elements which I could display separately in a FOR loop
I do appreciate the help - I’m learning a lot
- you have used 0 which I assume is a single sprite in which case I don’t really understand the significance of the 13,4
- I wanted a named sprite array N$ with 52 separate elements which I could display separately in a FOR loop
I do appreciate the help - I’m learning a lot
- Mr. Kibernetik
- Site Admin
- Posts: 4786
- Joined: Mon Nov 19, 2012 10:16 pm
- My devices: iPhone, iPad, MacBook
- Location: Russia
- Flag:
Re: Image chopping
In the code above 0 is a sprite name. It could be "MySpriteName" or anything else instead of "0". And 0 was used without quotes because BASIC will convert number 0 into name "0" automatically. So, this is equivalent to
The sprite name does not indicate or affect the number of sprite frames inside the sprite.
You can look at example "Sprites/every frame.txt" to see how multi-frame sprites work.
Code: Select all
sprite "MySpriteName" load "cards4.png",13,4
...
You can look at example "Sprites/every frame.txt" to see how multi-frame sprites work.
Re: Image chopping
Many thanks.
I really appreciate the tuition.
I really appreciate the tuition.
-
- Posts: 814
- Joined: Tue Apr 09, 2013 12:23 pm
- My devices: iPhone,iPad
Windows - Location: Groningen, Netherlands
- Flag:
Re: Image chopping
Look in the programs section for more stuff about cards.