Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Suggest about LoadSubImage

Author
Message
emtenteo
11
Years of Service
User Offline
Joined: 22nd Oct 2013
Location:
Posted: 22nd Oct 2013 19:50
Hi Team

I have a question about LoadSubImage function. Why we must create the file xxxsubimages.txt? It not safe, what happen if the player try to modify it.

Can you make other function like
integer LoadSubImage ( iParentIndex, "abc:0:0:32:32")

If we have that function, we can control load sub image by source code. So it safe for our game.

Thanks
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 23rd Oct 2013 09:33 Edited at: 23rd Oct 2013 15:03
its also unsafe if a user remove files.
there also exist id=CopyImage( fromImageid, x, y, width, height ),
maybe it works for you.


(the subimages file is useful for programs that creates this
atlas textures for agk like the bmp font tool.)
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 23rd Oct 2013 11:33
Any user that removes or changes files runs the risk of breaking software. That is their problem in my opinion. If you want you can check files before loading or using them but that is your own decision as a programmer.

oct(31) = dec(25)
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 23rd Oct 2013 14:54
Totally agree with baxslash. Non-issue as far as I'm concerned.

-- Jim - When is there going to be a release?
Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 23rd Oct 2013 15:55
I agree with the others, it's as much issue as a user editing any file. However the transparency of what the file is also concerns me so what I did is encrypt the file and it's name. When I load the atlas image and subimages I decrypt the file then delete it.
This works really well for my font and I only need to decrypt the file when the font image is loaded and can delete it immediately after.
I'm not so sure it works the same way for an image atlas. The file may need to exist whenever you load any subimage, but I've not had to try it since I load all of my subimages at once and really use it lightly.
I would, however, like the ability to set the name of the file so I don't have to store the file's name in the encrypted file. It would just make life easier for me.
Anyway, that was my solution to this little concern.

emtenteo
11
Years of Service
User Offline
Joined: 22nd Oct 2013
Location:
Posted: 23rd Oct 2013 18:33
@Markus: Are you make sure that function will not increase memory and it same as LoadSubImage?

@Baxslash: The user in this case maybe other developer, if we have text file and image file in bundle like ios, they can ripoff all data of you game. I think loading from binary is better than text file

@Naphier: thanks for you info

Once again, i'm newbie with this engine, so i don't know too much all function. I have a question. "How to draw apart of image?" I want do a feature like the picture below

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 23rd Oct 2013 19:47
You can use a checksum to verify the data hasn't been tampered with.

=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 23rd Oct 2013 20:21
@Phaelax:
I'm not sure AppGameKit has the necessary commands to do checksums on media loading.

In DBP, I used to make a memblock from the file, then find the hash of that memblock, and then compare with what it's supposed to be.

As far as I know AppGameKit doesn't have a make memblock from file command; and opening the file for byte by byte check summing takes an eternity. In AppGameKit the best I have managed is to compare the file size against what it's supposed to be.

Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 23rd Oct 2013 20:33
Quote: "As far as I know AppGameKit doesn't have a make memblock from file command; and opening the file for byte by byte check summing takes an eternity."

I read files byte by byte fairly frequently. It's not that bad, but I do imagine if you have a > 5MB file it might be very tough.
I could use checksums to verify file integrity, but I'm not too worried about it. Not worth the overhead IMO.

@emtenteo
You're asking a pretty complex question with how to put that zebra together. But basically how I'd do it is first use photoshop or GIMP to help you determine the atlas entries needed (you need to tell it where each part is pixel by pixel). In photoshop now you'd want to assemble the character and then determine the offset of each part from the center of the body. It will be helpful to make outlining boxes to match up with what you put in the atlas so you can see where each sprite will match up.
Sizing and positioning will be a bit of a bear, but work through it bit by bit and you'll get there.

An alternative approach is to make a sprite sheet with the animations you want. If you want the head to move and the feet to walk I'd make 2 separate sheets. One with the legs walking and another with the body and the head moving. But that's might be a lot of images. So it's up to you which way you want to go. I prefer sprite sheets, but I also don't use very large assets.

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 23rd Oct 2013 20:35 Edited at: 23rd Oct 2013 20:37
@emtenteo
emm, ok, if you copy all images from atlas you can delete the atlas image from memory. but using only one atlas with loadsubimages is better if you useing all images from atlas.

the cebra you can connect with physics engine joints or
just set the spriteoffset with 4 sprites.
SetSpriteOffset
SetSpritePositionByOffset
i would hold the data in a user defined type like
type TCebra
sprHead
sprBody
sprFeed
endtype
cebra as TCebra
cebra.sprHead=LoadSprite("head.png")
...

http://www.appgamekit.com/documentation/Reference/Sprite.htm

http://www.appgamekit.com/documentation/Reference/2DPhysics.htm
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 23rd Oct 2013 23:21
Quote: "The user in this case maybe other developer, if we have text file and image file in bundle like ios, they can ripoff all data of you game. I think loading from binary is better than text file"

You can convert images into memblocks and save the data from a memblock using any form of obfuscation you like. It's not impossible but to be honest any half decent hacker could rip images eventually. It is possible to make it harder for them though.

oct(31) = dec(25)
emtenteo
11
Years of Service
User Offline
Joined: 22nd Oct 2013
Location:
Posted: 24th Oct 2013 06:10
@Naphier: Maybe you misunderstood me, because my english is not good so i can't explain clearly my problem, sorry about that

All that i need is
- I have one atlas, this image have three module (body, head, leg)
- I have a tool, that tool can define the position of each module and order them to frame or animation then export it to binary.
- I want to load and draw it to my game but i don't know how to draw a part of image (Ex: atlas is 512x512, body at position 10, 16, 50, 90 of atlas image, how to draw only the body without split into multi image, because atlas is better than multi image)

@Markus: thanks for your answer, i think you have understand my question. But i have a question for you. If my atlas image have 100 module, is this ok? Is this affect to FPS or Memory?
emtenteo
11
Years of Service
User Offline
Joined: 22nd Oct 2013
Location:
Posted: 24th Oct 2013 06:19
@Naphier: Maybe you misunderstood me, because my english is not good so i can't explain clearly my problem, sorry about that

All that i need is
- I have one atlas, this image have three module (body, head, leg)
- I have a tool, that tool can define the position of each module and order them to frame or animation then export it to binary.
- I want to load and draw it to my game but i don't know how to draw a part of image (Ex: atlas is 512x512, body at position 10, 16, 50, 90 of atlas image, how to draw only the body without split into multi image, because atlas is better than multi image)

@Markus: thanks for your answer, i think you have understand my question. But i have a question for you. If my atlas image have 100 module, is this ok? Is this affect to FPS or Memory?
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 24th Oct 2013 12:22
This page gives you more detail about the loadSubImageCommand. If you create your atlas image using the Image Joiner utility (found in your install directory under "\AGK\IDE\Utilities\ImageJoiner") it will create the subimage text file you need to load the separate images. It looks something like this:


Where "imgName.png" is the name of the image and the numbers represent the top left corner of the image (x=0:y=5) and size of the image (w=64:h=128).

I hope that helps!

oct(31) = dec(25)
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 24th Oct 2013 12:30 Edited at: 24th Oct 2013 12:35
@emtenteo
today, only the max. texture size limit is interesting,
the devices have a lot of ram today and since some years,
i do not need to think about if it fit in memory.
for full hd monitors you need hires images, that do not
really fit in a atlas texture.
for animated images i prefer atlas else single images.
single image files are more handier, you can easy exchange
one with another, without bulding a new atlas image.
about your question, i believe using one texture is faster than
much single textures but this is part of optimization,
optimization i do at last at parts that need optimization.
there are much possibilities to kill time unnecessary in a game loop.
emtenteo
11
Years of Service
User Offline
Joined: 22nd Oct 2013
Location:
Posted: 4th Nov 2013 11:19
@baxslash: I know that and i got problem with that, i don't want to create the file "xxxx subimages.txt" is there any way loadsubimage without use that file?

@Markus: You join this forum at 2004, maybe you are expert with this engine. I have a question for you. How to draw a part of image in sprite.

Ex:
- I have a atlas image (512x512)
- I create sprite with that image
- How to draw a part of that image at x, y?

Thanks
=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 4th Nov 2013 12:27
If you didn't want to use an atlas data sheet, you could always use GetImage() to cut up the first image into smaller sections manually from inside AGK.

In order to display each of the individual images, you would need to use a separate sprite for each one. I don't think you can just show part of a sprite.

e.g. (Using the zebra, without using an atlas data file)

Load the zebra image

Use GetImage() to grab image of head, body, leg, etc

Create new sprite for each body segment, apply relevant image to it and position accordingly

Hope that helps

emtenteo
11
Years of Service
User Offline
Joined: 22nd Oct 2013
Location:
Posted: 4th Nov 2013 14:06
@=PRoF=: that function is get the image from current buffer. It will be make your game increase memory. And after that, the atlas texture is split to multi image. So this solution is not good (it same as CopyImage)

Note: i have use gDEBugger for checked it. It create new image and not same as LoadSubImage because LoadSubImage is not create new image.
Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 4th Nov 2013 19:13
GetImage is very slow too, so you can't use it a lot.
If you really don't want to use subimages.txt then why not just create a separate image file for each?
Your other options are GetImage, SetSPriteScissors (which would be a headache to constantly re-set the scissor every time the sprite moves), or you could use a sprite sheet with the setspriteanimation/frame commands - this will also be a pain as you'd need to have each frame the same size so you'll end up with a lot of empty pixels and just be making your file size bloated.
If you're really opposed to the subimages.txt then I'd have to suggest cutting up the image into its smaller parts and load each separately.

May I ask why you're so opposed to the subimages txt file?

=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 5th Nov 2013 00:04
Quote: " It will be make your game increase memory. And after that, the atlas texture is split to multi image. So this solution is not good "


I know, I was just suggesting alternatives.

If you want to keep atlas image functionality and performance, and your only concern is that a user may edit the atlas data file; then I would consider using a checksum to verify the data file when you're loading it and if it fails delete the data file and re-write it to disk from your code, then try loading again.

Atlas data files are not very large, so you shouldn't have much of a problem with performance when loading.

Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 5th Nov 2013 00:12
You could also store the lines of the subimages.txt file in an include file as a string for each line, write those strings to a properly named file before you load your image, and then delete the file when done loading the image. I do something similar with my font subimages file.

emtenteo
11
Years of Service
User Offline
Joined: 22nd Oct 2013
Location:
Posted: 5th Nov 2013 05:30
@Naphier: I want to use atlas image for increase FPS when render and optimize memory. But i don't want use LoadSubImage function because it is not good. Why?

- It not flexible. For use it, we must create xxxx subimages.txt, no way for LoadSubImage from file or from binary data.

- We can't encrypt and package all texture into one file, so other people can ripoff all data of your game


About write and delete file, i think it only work with window. On iOS you can not write and delete file in bundle file by code. So you can't use this solution for iOS
=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 5th Nov 2013 22:24
Another alternative would be to write your own sprite handling routine using 3D Plains in place of sprites. That way you could UV scroll the texture to the correct place (Assuming the 3D commands in AppGameKit are capable of this as yet, I'm not entirely sure. You may have to wait for v2 before you can do this.)

emtenteo
11
Years of Service
User Offline
Joined: 22nd Oct 2013
Location:
Posted: 6th Nov 2013 03:46
Currently, i still waiting for spine feature. Hope it release soon

Login to post a reply

Server time is: 2024-11-24 21:34:50
Your offset time is: 2024-11-24 21:34:50