Meaningless Drivel is fun!
The moose likes Beginning Java and the fly likes Seperating an Image. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Seperating an Image." Watch "Seperating an Image." New topic

Seperating an Image.

Terry Stehle

Joined: Mar 24, 2001
Posts: 24
Im currently working on a chess program. The pieces are all in one gif file, and I want to be able to seperate the pieces after I load the file in. I was hoping I could use some kind of function like,
Image GetPiece(int Type, int Color)
//Code to seperate piece
return //Return image of the piece
I would appriciate any help. Thanks You
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4351

I'm not certain, but I think you will have to make each piece a seperate gif.
Dont blindly believe everything I say.

Visit my download page
Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

Well, you either have to do as Randall said and make each piece a seperate image, or you can save it as one big image of all the pieces and then write a function to cut it into smaller images... This saves alot of download time.
Here's a quick and dirty ( and untested, though it was cobbled together from things I had lying around that do work... ) example of the function you would write to rip a smaller image out of a larger one...


Write once, run anywhere, because there's nowhere to hide! - /. A.C.
I agree. Here's the link:
subject: Seperating an Image.
It's not a secret anymore!