Image chopping

Post Reply
benfield
Posts: 5
Joined: Tue Feb 08, 2022 12:50 pm
Flag: Great Britain

Image chopping

Post by benfield »

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.

User avatar
Mr. Kibernetik
Site Admin
Posts: 4782
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Image chopping

Post by Mr. Kibernetik »

No, SPRITE LOAD just splits the sprite sheet into the specified amount of raws and columns.

benfield
Posts: 5
Joined: Tue Feb 08, 2022 12:50 pm
Flag: Great Britain

Re: Image chopping

Post by benfield »

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.

User avatar
Mr. Kibernetik
Site Admin
Posts: 4782
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Image chopping

Post by Mr. Kibernetik »

Is card4.png file available?

benfield
Posts: 5
Joined: Tue Feb 08, 2022 12:50 pm
Flag: Great Britain

Re: Image chopping

Post by benfield »

Attached
Attachments
BA70939E-4173-4B6D-9C17-7067B2D39D26.png
BA70939E-4173-4B6D-9C17-7067B2D39D26.png (1.18 MiB) Viewed 5357 times

User avatar
Mr. Kibernetik
Site Admin
Posts: 4782
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Image chopping

Post by Mr. Kibernetik »

This code:

Code: Select all

sprite 0 load "cards4.png",13,4
sprite 0 show
sprite 0 delay 0.5
sprite 0 loop
1 goto 1
works exactly as expected: it shows a sequence of 13*4 cards of all 4 suits.

benfield
Posts: 5
Joined: Tue Feb 08, 2022 12:50 pm
Flag: Great Britain

Re: Image chopping

Post by benfield »

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

User avatar
Mr. Kibernetik
Site Admin
Posts: 4782
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Image chopping

Post by Mr. Kibernetik »

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

Code: Select all

sprite "MySpriteName" load "cards4.png",13,4
...
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.

benfield
Posts: 5
Joined: Tue Feb 08, 2022 12:50 pm
Flag: Great Britain

Re: Image chopping

Post by benfield »

Many thanks.

I really appreciate the tuition.

Henko
Posts: 814
Joined: Tue Apr 09, 2013 12:23 pm
My devices: iPhone,iPad
Windows
Location: Groningen, Netherlands
Flag: Netherlands

Re: Image chopping

Post by Henko »

Look in the programs section for more stuff about cards.

Post Reply