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 / paste small image into big image using memblocks

Author
Message
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 1st Dec 2015 23:21
Does anyone have a function that will let you paste a small image into a larger image with an x/y offset using memblocks to allow for really big atlas textures to be created? I have hit the device dimension barrier using the GetImage method.

I'll start working on a solution and will post my function here unless someone beats me to it

Thanks!
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 2nd Dec 2015 00:35
Okay! I have come up with the following 2 functions which fulfill my needs:

newimage = createblankimage(width,height)
newimage = pastetoimage(source, destination, x offset, y offset)



These will probably need a little optimisation and some checks to make sure we don't paste an image outside the area of the destination image. Feel free to use/change these if they are of any use to you.
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 24th Feb 2016 20:09
That's great CJB

do you have to do anything else to get it to update with a background sprite with the new pasted images attached



//functions same as yours above
fubar
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 24th Feb 2016 21:45
Oh I got that working now CJB thanks
Quote: "(4 am coding is bad for you lol that's why I do it)"


but I'm trying to convert some old dbpro code of mine that pastes allot of different images to the background (ie cards)
now I don't want sprites for everyone hence why I went looking for pasting abilities

but the problem is when I use your great pasttoimage function it only seems to show the first newimage and not the other pasted images

thinking it might be a syncing issue but when I went crazy with syncing it never seemed to help

there must be something I'm missing


fubar
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 24th Feb 2016 22:38
I''m guessing it's something to do with the pastetoimage function creating a new image rather than updating the image passed to it... Try using a new newimage later down the code (i.e. newimage2 = etc... then SetSpriteImage(10,newimage2)).

V2 T1 (Mostly)
Phone Tap!
Uzmadesign
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 25th Feb 2016 13:23
Thanks CJB you are a legend
I seriously have to learn to use memblocks



it was an update thing, I'm using sync() way too much but il fix that later if I can
but just wanted to post its working and my program is pretty much done aswell
but I need to do some resizing as its quite small just cosmetics, I am working in the
virtual resolution 800 * 600 as that's the resolution I used to use in old dbpro programs
and the c version for compatability but my other phone apps I did I used 480 by 320

fubar
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 26th Feb 2016 08:45
nice snippet, thanks!
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 27th Feb 2016 20:05
When pasting an image onto another, remember to preserve transparency. If you copy it over bit by bit, you could erase potentially visible data.

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 28th Feb 2016 10:27
Quote: "When pasting an image onto another, remember to preserve transparency. If you copy it over bit by bit, you could erase potentially visible data."
Agreed. There's probably lots of tweaks and improvements to be made to those functions. I only built them for one purpose: to paste tiles of images into a larger image in order create an atlas image. If you make any improvements, please post 'em here
V2 T1 (Mostly)
Phone Tap!
Uzmadesign

Login to post a reply

Server time is: 2024-05-02 05:54:41
Your offset time is: 2024-05-02 05:54:41