Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 143657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:07:48+00:00 2026-05-11T08:07:48+00:00

I have this sprite sheet: How can I read this image file to extract

  • 0

I have this sprite sheet:

Pacman sprites

How can I read this image file to extract part of it to be used as a sprite ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T08:07:49+00:00Added an answer on May 11, 2026 at 8:07 am

    If the sprites area read into a BufferedImage, the getSubimage method can be used to get a subimage of the sprite sheet.

    The getSubimage method will take the x, y, and the width and height of the desired subimage, so the desired sprite can be obtained. Since most of the sprites seem to be the same size, I would think most of them can be retrieved by a nested for loop to iterate through the large image.

    For example, if the sprite image is loaded using the ImageIO class (such as the read method), and each sprite is 10 pixels by 10 pixels in size, where are 5 rows by 5 columns of sprites, the sprites can be obtained by the following:

    BufferedImage bigImg = ImageIO.read(new File('sheet.png')); // The above line throws an checked IOException which must be caught.  final int width = 10; final int height = 10; final int rows = 5; final int cols = 5; BufferedImage[] sprites = new BufferedImage[rows * cols];  for (int i = 0; i < rows; i++) {     for (int j = 0; j < cols; j++)     {         sprites[(i * cols) + j] = bigImg.getSubimage(             j * width,             i * height,             width,             height         );     } } 

    The catch is, of course, the above code will only work if all the sprites are the same size, so there will need to be some adjustment performed in order to work for the given sprite sheet. (As the top right-hand corner seems to be different in size from the others.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So i have this sprite that is say arbitrarily 100 x 100 which is
Let's Say I Have This Class: package{ import flash.display.Sprite; public class Main extends Sprite{
I have a CSS-sprite-based Apple-themed navigation bar, which you can view here: http://www.marioplanet.com/index.asp Now,
I have some code where I display a sprite for N number of seconds.
I have created a sprite as below: var arrowHeadRight:Sprite = new Sprite(); with(arrowHeadRight.graphics){ beginFill(0xDDDDDD,
i have a few filters on a sprite. on mouse over i would like
Okay so I have two import pieces of code involved in this. This first
Friends i am new to cocos2d programming and Mac in general! I have noticed
Kind of a dilemma here. I am making a mobile version of a website,
I am writing a game in which there are thumbnails of mini games displayed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.