Still working on Pixcaso. More details on that later. But, I decided to create tiny utility to peice together my 3ds max rendered images into a single sprite sheet. It hasn’t been tested well at all, so download at your own risk.
Here’s most of the code:
using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace MakeSpriteSheet
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
openFileDialog1.ShowDialog();
listBox1.Items.AddRange(openFileDialog1.FileNames);
listBox1.Sorted = true;
}
private void button2_Click(object sender, EventArgs e)
{
label1.Text = "Checking image dimensions";
progressBar1.Visible = true;
if (checkDimensions())
{
label1.Text = "Creating Sprite Sheet";
MakeSpriteSheet();
label1.Text = "Done";
progressBar1.Value = 100;
}
}
public void MakeSpriteSheet()
{
saveFileDialog1.ShowDialog();
Bitmap image = new Bitmap(listBox1.Items[0].ToString());
Bitmap spriteSheet = new Bitmap(image.Height*listBox1.Items.Count, image.Height);
int imageCount=0;
foreach (object filename in listBox1.Items)
{
Bitmap objBitmap = new Bitmap(filename.ToString());
for (int y = 0; y < objBitmap.Height; y++)
{
for (int x = 0 ; x < objBitmap.Width; x++)
{
Color col = objBitmap.GetPixel(x, y);
// Perform an operation on the Color value here.
spriteSheet.SetPixel(x + (imageCount * objBitmap.Width), y, col);
}
}
imageCount++;
progressBar1.Value++;
}
label1.Text = "Saving";
spriteSheet.Save(saveFileDialog1.FileName);
Form ImageForm = new Form();
PictureBox ImageBox = new PictureBox();
ImageForm.Controls.Add(ImageBox);
ImageBox.Image = spriteSheet;
ImageBox.Size = spriteSheet.Size;
ImageBox.Show();
ImageForm.Height = spriteSheet.Height+50;
if (spriteSheet.Width > (Screen.PrimaryScreen.Bounds.Width-100))
{
ImageForm.Width = Screen.PrimaryScreen.Bounds.Width - 100;
}
else
{
ImageForm.Width = spriteSheet.Width;
}
ImageForm.AutoScroll = true;
ImageForm.Show();
}
public bool checkDimensions()
{
Bitmap image = new Bitmap(openFileDialog1.FileNames[0]);
SizeF dimension = image.PhysicalDimension;
foreach (string filename in openFileDialog1.FileNames)
{
Bitmap nextImage = new Bitmap(filename);
if (dimension != nextImage.PhysicalDimension)
return false;
progressBar1.Value++;
}
return true;
}
private void Top_Click(object sender, EventArgs e)
{
}
}
}
Executable (Recommended) (10K)
Installer (500K)