NOGDUS $170.00 has been donated to NOGDUS!
September 10, 2010, 12:20:27 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Sprite cropping Help  (Read 565 times)
0 Members and 1 Guest are viewing this topic.
supra94red
Member
*

Rating: 1
Offline Offline

Posts: 12


« on: March 04, 2010, 08:52:23 PM »

I get stumped on many things, but this is one of the few times Google is not pointing me in the direction I need.
I'm trying to create an app in C++ where you feed it a small bitmap file with plenty of magenta (transparent) and it crops and resizes the image around the smallest bounding box surrounding the artwork and outputs a new smaller image.  If someone can point me in the right direction it would be greatly appreciated.

Thanks,
Dan
Logged
RedSlash
Member
*

Rating: 10
Offline Offline

Posts: 50


« Reply #1 on: March 04, 2010, 10:34:42 PM »

Well first of all, you will need to load a bitmap, similar to:
http://www.gamedev.net/reference/articles/article1966.asp

Next you want to compute the bounding box of the subimage. You can achieve that by looping through every pixel and recording the left-most, top-most, bottom-most and right-most non-transparent pixel. An easy way is to make 4 variables, for ex. xMin, xMax, yMin, yMax, then initialize them with large values such that xMin and yMin will contain a large positive value and xMax and yMax will contain a large negative value. While looping through each pixel, compare the current position with respect to each of the variables and update them accordingly. So, for eg. while looping in the x direction, you can check if the current x position is < xMin, and if so, we can set xMin to the current x, and so on..

Once you got the bounding rectangle, you just extract the pixels and save them to file.

(Also, in case you didn't know, Photoshop's "Trim..." function or GIMP's Auto Crop function does what you want, but perhaps you have a different reason for doing it in code)
Logged
kingthomas
Member
*

Rating: 10
Online Online

Posts: 73



« Reply #2 on: March 04, 2010, 11:45:13 PM »

Here is some code that does it using Allegro: http://paste.ccpssolutions.com/?show=490
Logged
Richard Marks
202192397
Administrator
Member
*

Rating: 69
Offline Offline

Posts: 889


happy


« Reply #3 on: March 05, 2010, 12:43:40 AM »

...this sounds too damn familiar LOL

Dan, is this by chance for Babaroga's programmer test?
Logged

You want to know more about me?
Freelance Game Developer
Katy, TX
supra94red
Member
*

Rating: 1
Offline Offline

Posts: 12


« Reply #4 on: March 05, 2010, 05:38:32 PM »

Thanks for the reply guys.  These links are useful.
Richard, this looks familiar because yes it is the Babaroga test!  It's a rather darn good idea to ask applicants to complete the test before they even bother applying.  I also like the way their questions are very old skool...I haven't seen questions like this since my undergrad years a decade ago.  Does anyone know anything about these guys...such as number of employees or how much revenue they bring in...if they're a shitty place to work?  

LMAO, how old is that link...has this test been up for while now?  Looks like u guys worked thru it.
Logged
kingthomas
Member
*

Rating: 10
Online Online

Posts: 73



« Reply #5 on: March 05, 2010, 05:55:43 PM »

Did you finish the last part yet Richard? If not i can help, I got mine working.
Logged
Richard Marks
202192397
Administrator
Member
*

Rating: 69
Offline Offline

Posts: 889


happy


« Reply #6 on: March 06, 2010, 12:31:03 AM »

I've already sent in my application - I'm waiting on a response.
I'll let you know how it goes.
Logged

You want to know more about me?
Freelance Game Developer
Katy, TX
supra94red
Member
*

Rating: 1
Offline Offline

Posts: 12


« Reply #7 on: March 06, 2010, 11:01:54 AM »

I thought their only office is in Chicago...  Unless you're willing to relocate up here.
Logged
RedSlash
Member
*

Rating: 10
Offline Offline

Posts: 50


« Reply #8 on: March 06, 2010, 03:13:47 PM »

Work from home, maybe?
Logged
Richard Marks
202192397
Administrator
Member
*

Rating: 69
Offline Offline

Posts: 889


happy


« Reply #9 on: March 07, 2010, 07:25:29 PM »

I thought their only office is in Chicago...  Unless you're willing to relocate up here.

If I get the job, I'll move. There are other things that I want that reside there as well. Grin
Logged

You want to know more about me?
Freelance Game Developer
Katy, TX
supra94red
Member
*

Rating: 1
Offline Offline

Posts: 12


« Reply #10 on: March 08, 2010, 11:15:51 AM »

I hope you get the job man!  Let me know if ur in the Chicago neck of the woods, maybe we can hang.
If u get the gig, I would suggest having them change the programmer test...it appears to be the same test from several years ago.  I found this trying to dig up info on the company.

http://www.johnburkert.com/dev/examples.xml
Logged
Tags:
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC
.: Custom SMF Theme by Richard Marks :.
Valid XHTML 1.0! Valid CSS!