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 6531369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:52:12+00:00 2026-05-25T09:52:12+00:00

I have 2 exporter methods (planning to have more) that essentially take my sprite

  • 0

I have 2 exporter methods (planning to have more) that essentially take my sprite definition from my sprite maker, and export that into a PNG file and an XML file that describes the PNG. Right now, I have stuffed these two methods into my Sprite class for testing, but they don’t really belong there. So I thought it would be good if I made an interface for exporters and importers, then have one class for each type of importer/exporter, right?

Now the problem is that my two methods don’t have the same parameters, so I can’t use an Interface very easily.

The first exporter is a an “organized” exporter, and it exports the frames in a manner that humans can easily follow, no restrictions. It would just take the sprite definition, and a file name (with no extension) then produce the pair of files.

The second exporter is an optimally packed exporter and would take the same parameters plus a maximum width and height. Right now it’s not optimal, it doesn’t re-size the frames and it just picks the next slot that fits. Maybe there are additional options (parameters) that I have not thought of yet for this method.

The XML is identical for the existing exporters, but the PNG differs. Some time down the road, I might like to have other types of meta-data exporters, like JSON.

For the existing exporters, they both follow this pattern:

  • Determine size of output PNG (Different for each method)
  • Make a Bitmap object with that size
  • Set up, and start writing to my XML file
  • Write out a bunch of meta-data that doesn’t relate to the frames just yet
  • Iterate through each sequence (a little more involved than it seems)
    • For each frame:
      • Figure out where the frame will go (Different for each method)
      • Write information about this frame including sprite-sheet location & size from above
      • Draw the frame to the output bitmap at the location & size calculated above
  • Save and close files

I can provide a link to the code on request.

(I added “Importer” to the question because I will want to add importers to these exporters one day)

Any suggestions on how I might pull these exporters out of my Sprite class and how to keep them related?

  • 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. Editorial Team
    Editorial Team
    2026-05-25T09:52:13+00:00Added an answer on May 25, 2026 at 9:52 am

    I guess it would be best if you create some base export class that has only some basic features shared between all export classes like addSprite or saveToFile. after that you can create some other classes which inherit this one plus they have specific functions to add saving parameters, something like this:

    class baseExported
    {
        public abstract void addSprite(Bitmap texture);
        public abstract bool export(String target);
    };
    
    class ExporterA : baseExporter
    {
        public override void addSprite(...) {...};
        public override bool export(...) {...};
    }
    
    class ExporterB : baseExporter
    {
        public override void addSprite(...) {...};
        public override void setMaxDimentions(int maxHeight,int maxWidth) {...};
        public override bool export(...) {...};
    }
    
    class ExporterC : baseExporter
    {
        public override void addSprite(...) {...};
        public override void setMaxDimentions(int maxHeight,int maxWidth) {...};
        public override void addMetaData(String someData) {...};
        public override bool export(...) {...};
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Cocoa-based universal dynamic library that also includes more static libraries, from
I have an Excel spreadsheet that I have exported from some other program. It
We have some stuff that may be exported into various formats. Currently we have
I have two classes called Person and Animal that have a lot of methods
I have a project in Eclipse that I use as a library (I export
I have an app that is built from Flash CS5.5, exported using AIR3.1 and
I have several WCF services that I have imported into a .Net4 Class Library.
i am writing a magento product exporter, that writes a couple of attributes into
So I have some code that can read the methods out of a .coverage
I have exported many times tables from Hive to SQL Server. I never face

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.