Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Spritesheet Maker v0.2

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming -> Binaries
View previous topic :: View next topic  
Author Message
Odecey
Master Cheater
Reputation: 1

Joined: 19 Apr 2007
Posts: 259
Location: Scandinavia

PostPosted: Sat Oct 10, 2009 8:38 pm    Post subject: Spritesheet Maker v0.2 Reply with quote

I've been working on and off on two pretty similiar projects for some time now, and the first finally got to a working state so I'm releasing it here for feedback.

What it is:
This is an image merger aimed at creating spritesheets as effortlessly as possible.

How to use it:
Open the program, and get your sprite files by clicking "Open" and browsing to them. Then drag them from the list they appear in onto the image surface in the desired place. Adjust the properties of the sheet as necessary. If you want to clear a single cell, select it by clicking on it, and press delete. When you are done, click save and choose a destination folder and filename for your new spritesheet.

Things of interest:
Version: 0.2 beta
Coded in: C#
Coded by: Odecey
Licence:Creative Commons Attributions Licence 3.0

Update Log:
0.1b- Original post
0.2b- Fixed a bug with resizing of the form, where the picturebox would not render the grid correctly. Also added basic cell removal functionality.

Image:


Downloads:
Project files(v0.2b)
Binaries(v0.1b)

Any comments are as always appreciated! Smile

_________________
Never confuse activity with productivity. You can be busy without a purpose, but what's the point?- Rick Warren


Last edited by Odecey on Sun Oct 25, 2009 1:39 pm; edited 5 times in total
Back to top
View user's profile Send private message MSN Messenger
&Vage
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Jul 2008
Posts: 1053

PostPosted: Sat Oct 10, 2009 8:45 pm    Post subject: Reply with quote

http://forum.cheatengine.org/viewforum.php?f=65
Back to top
View user's profile Send private message
Odecey
Master Cheater
Reputation: 1

Joined: 19 Apr 2007
Posts: 259
Location: Scandinavia

PostPosted: Sat Oct 10, 2009 8:48 pm    Post subject: Reply with quote

void:] wrote:
http://forum.cheatengine.org/viewforum.php?f=65

The project files are included in one of the downloads, in case you didn't notice. That said, I'd be more than happy to post the source in the post itself.

_________________
Never confuse activity with productivity. You can be busy without a purpose, but what's the point?- Rick Warren
Back to top
View user's profile Send private message MSN Messenger
&Vage
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Jul 2008
Posts: 1053

PostPosted: Sat Oct 10, 2009 8:51 pm    Post subject: Reply with quote

This forum is for questions in programming general. Do you have any questions? No. http://forum.cheatengine.org/viewforum.php?f=65
Back to top
View user's profile Send private message
Odecey
Master Cheater
Reputation: 1

Joined: 19 Apr 2007
Posts: 259
Location: Scandinavia

PostPosted: Sat Oct 10, 2009 8:56 pm    Post subject: Reply with quote

void:] wrote:
This forum is for questions in programming general. Do you have any questions? No. http://forum.cheatengine.org/viewforum.php?f=65
I was under the impression that this section could be used to release and discuss source code. If I am mistaken, I'm sure a moderator will be kind enough to move it.
_________________
Never confuse activity with productivity. You can be busy without a purpose, but what's the point?- Rick Warren
Back to top
View user's profile Send private message MSN Messenger
&Vage
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Jul 2008
Posts: 1053

PostPosted: Sat Oct 10, 2009 9:02 pm    Post subject: Reply with quote



General programming
Forum for posting questions and answers about programming. Delphi, C, Java, Assembler, BF, Cobol, whatever...

Binaries
For those that just want to show of their programs, post your binaries here. (With or without sourcecode if you like)
Back to top
View user's profile Send private message
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Sat Oct 10, 2009 10:10 pm    Post subject: Reply with quote

ITT: void pretends he is a moderator.

Also, why do people insist on coding monoliths? Break up the mainform into more than one class or I will STAB YOU MULTIPLE TIMES SO YOU NEVER TOUCH A COMPILER AGAIN*.

* Not really, but I felt this was the most appropriate way to get my point across.
Back to top
View user's profile Send private message
Odecey
Master Cheater
Reputation: 1

Joined: 19 Apr 2007
Posts: 259
Location: Scandinavia

PostPosted: Sun Oct 11, 2009 6:58 am    Post subject: Reply with quote

Athaem wrote:
ITT: void pretends he is a moderator.

Also, why do people insist on coding monoliths? Break up the mainform into more than one class or I will STAB YOU MULTIPLE TIMES SO YOU NEVER TOUCH A COMPILER AGAIN*.

* Not really, but I felt this was the most appropriate way to get my point across.

Here you go:
Code:

 class SpritesheetPictureBox : System.Windows.Forms.PictureBox
    {
        #region Private variables
        Dictionary<string, Bitmap> _sprites = new Dictionary<string, Bitmap>();
        Dictionary<Point, string> _spriteGrid = new Dictionary<Point, string>();
        Graphics surface;
        Color _gridColor = Color.Red;
        private SpriteFormat _spriteFormat = SpriteFormat.Cropped;
        private int _cellHeight = 50;
        private int _cellWidth = 50;
        private int _gridRows = 5;
        private int _gridColumns = 5;
        #endregion
        #region Constructors
        public SpritesheetPictureBox()
        {
            surface = Graphics.FromHwnd(this.Handle);
        }
        #endregion
        #region Properties
        public int CellWidth { get { return _cellWidth; } set { _cellWidth = value; RefreshSheet(); } }
        public int CellHeight { get { return _cellHeight; } set { _cellHeight = value; RefreshSheet(); } }
        public int GridRows { get { return _gridRows; } set { _gridRows = value; RemoveRows(_gridRows - 1); RefreshSheet(); } }
        public int GridColumns { get { return _gridColumns; } set { _gridColumns = value; RemoveColumns(_gridColumns - 1); RefreshSheet(); } }
        public Color GridColor { get { return _gridColor; } set { _gridColor = value; RefreshSheet(); } }
        public SpriteFormat CellSpriteFormat { get { return _spriteFormat; } set { _spriteFormat = value; RefreshSheet(); } }
        public Dictionary<string, Bitmap> Sprites { get { return _sprites; } set { _sprites = value; RefreshSheet(); } }
        public Dictionary<Point, string> SpriteGrid { get { return _spriteGrid; } set { _spriteGrid = value; RefreshSheet(); } }
        #endregion
        #region Methods
        private void RemoveColumns(int maxColumnIndex)
        {
            List<Point> indexesToRemove = new List<Point>();
            foreach (Point index in _spriteGrid.Keys)
                if (index.Y > maxColumnIndex)
                    indexesToRemove.Add(index);
            foreach (Point index in indexesToRemove)
                _spriteGrid.Remove(index);
        }
        private void RemoveRows(int maxRowIndex)
        {
            List<Point> indexesToRemove = new List<Point>();
            foreach (Point index in _spriteGrid.Keys)
                if (index.X > maxRowIndex)
                    indexesToRemove.Add(index);
            foreach (Point index in indexesToRemove)
                _spriteGrid.Remove(index);
        }
        private void DrawGrid(Graphics surface, Color color, int rows, int columns, int width, int height)
        {
            for (int i = 0; i < rows; i++)
            {
                for (int j = 0; j < columns; j++)
                {
                    surface.DrawRectangle(new Pen(new SolidBrush(color), 1.0f), new Rectangle(i * width, j * height, width, height));
                }
            }
        }
        private void DrawSprites(Graphics surface)
        {
            for (int i = 0; i < _gridRows; i++)
            {
                for (int j = 0; j < _gridColumns; j++)
                {
                    if (_spriteGrid.ContainsKey(new Point(i, j)))
                    {
                        if (_spriteFormat == SpriteFormat.Resized)
                            surface.DrawImage(_sprites[_spriteGrid[new Point(i, j)]], new Rectangle(_cellWidth * i, _cellHeight * j, _cellWidth, _cellHeight));
                        else
                            surface.DrawImage(_sprites[_spriteGrid[new Point(i, j)]], new Rectangle(_cellWidth * i, _cellHeight * j, _cellWidth, _cellHeight), new Rectangle(0, 0, (int)_cellWidth, (int)_cellHeight), GraphicsUnit.Pixel);
                    }
                }
            }
        }
        public void RefreshSheet()
        {
            this.Refresh();
            this.OnPaint(null);
        }
        #endregion
        #region Overrides
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs pe)
        {
            DrawSprites(surface);
            DrawGrid(surface, _gridColor, _gridRows, _gridColumns, _cellWidth, _cellHeight);
            base.OnPaint(pe);
        }
        protected override void OnResize(EventArgs e)
        {
            base.OnResize(e);
            surface = Graphics.FromHwnd(this.Handle);
        }
        #endregion
        #region Structs and Enums
        public enum SpriteFormat
        {
            Cropped = 0,
            Resized
        }
        #endregion
    }

Satisfied? Razz

_________________
Never confuse activity with productivity. You can be busy without a purpose, but what's the point?- Rick Warren
Back to top
View user's profile Send private message MSN Messenger
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Sun Oct 11, 2009 5:03 pm    Post subject: Reply with quote

Looks good, could make a tile atlas with it as well

Moving.
Back to top
View user's profile Send private message
Odecey
Master Cheater
Reputation: 1

Joined: 19 Apr 2007
Posts: 259
Location: Scandinavia

PostPosted: Sun Oct 25, 2009 1:36 pm    Post subject: Reply with quote

I haven't really been working on this since I released it, but have tweaked it slightly. Info on what's new can be found in the original post.

Offtopic: Could anyone suggest a diffrent forum for discussion of programming(C# in particular)? It seems this forum's active userbase is slowly crawling towards zero.

_________________
Never confuse activity with productivity. You can be busy without a purpose, but what's the point?- Rick Warren
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming -> Binaries All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites