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 / Crop Image with Memblocks

Author
Message
IronManhood
9
Years of Service
User Offline
Joined: 6th Feb 2015
Location: US
Posted: 25th Jul 2018 20:00 Edited at: 26th Jul 2018 22:52
I've been working on a function to crop an image but I'm stuck at the moment. This is what is happening on screen:



The function:

Attachments

Login to view attachments
Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 25th Jul 2018 20:18 Edited at: 25th Jul 2018 20:18
Why not use the inbuilt function to do this without memblocks???

https://www.appgamekit.com/documentation/Reference/Image/CopyImage.htm

It allows you to crop an image with one line of code
Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 25th Jul 2018 20:22
And you algorithm is wrong...the loop variables are wrong and dont set the destination or start points quite right either
puzzler2018
User Banned
Posted: 25th Jul 2018 20:22 Edited at: 25th Jul 2018 20:24
Maybe Iron was liking to try for himself cause was curious on how its done.

Saying someone is wrong is not helping - guide Iron in the right direction...
Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 25th Jul 2018 20:34 Edited at: 27th Jul 2018 21:36
In that case then....he wont want our help now would he?? Because hes enjoying it so much figuring it out!!.....lol

Letting someone know there is a function to do exactly waht they want is helping. The right direction is to use the function to do it. lol

Ha.... If he does want to know what the errors are (loop variables and destination offsets) then will happily post them up but im thinking its more likely he didnt know that CopyImage also worked as a Cropimage.
Its been asked before on here...

Better to give someone the logical answer then help them learn a long winded overly complex and slower way of doing it.....

EDIT: In case you do want a working version of your function

puzzler2018
User Banned
Posted: 25th Jul 2018 21:16
Your a star lol

Iron - please use the inbuilt function - good work though
puzzler2018
User Banned
Posted: 25th Jul 2018 21:25
But then - what if Paul didnt put the function - then how would you do it.

Better programmers I feel is learning how things are achieved rather than just using a function - i have done that thousands of times.

Some people want easiness and quickness to get things done and some likes to try to achieve something constructive

Anyway

Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 25th Jul 2018 21:40
Puzzler.... how come you didnt post the answer as you have done this 1000's of times?

Constructive.... is posting solutions as I have done....

Thanks for your fantastic input and help this evening though ...
IronManhood
9
Years of Service
User Offline
Joined: 6th Feb 2015
Location: US
Posted: 25th Jul 2018 22:54 Edited at: 25th Jul 2018 23:06
I didn't know CopyImage also cropped an image. I was curious to know how image cropping worked in case I needed to write some method of doing so. Learning is fun isn't it? (kill me) Throwing image cropping in with CopyImage makes sense from the AppGameKit developers perspective but it doesn't from a user perspective because it makes it harder to find the correct function to use. I suggest that those two are separated into their own functions.
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 27th Jul 2018 05:44 Edited at: 27th Jul 2018 05:46
Wrote this up real quick for ya, haven't tested it. I also have DBP code that can crop an image/sprite by UV manipulation. The benefit of that method is the cropping follows the rotation of the sprite.




As far as your code goes, the issues I see are:

for yy = _y to _h
for xx = _x to _w


Should probably be:

for yy = _y to _y+_h
for xx = _x to _x+_w

Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 27th Jul 2018 06:28
Just to make things even more confusing, i made a crop function over in the The Useful Community Functions Project thread
IronManhood
9
Years of Service
User Offline
Joined: 6th Feb 2015
Location: US
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 31st Jul 2018 18:23
Some of these should be stickied, or the search feature on the forums need some serious upgrades.

10/10 Good thread, would read again.

Login to post a reply

Server time is: 2024-11-23 18:04:03
Your offset time is: 2024-11-23 18:04:03