Hi all,
I'm looking for an algorithm to slice images up in rectangles.
The result i'm looking for is the same result as using the slice tool in Adobe Fireworks.
So given n rectangles, slice these rectangles and also construct rectangles for the background.
The rectangles do not have the same size.
Does anyone know an algorithm for this?
Greetings Benoist
Loading
Behtash MoradiPosted Jul 26, 2009, 6:15 AM
public static void split(Image img, int portionHeight, int portionWidth, string path, string fileName,string extention)
{
int imageindex = 1;
for (int y = 0; y < img.Height; y += portionHeight)
for (int x = 0; x < img.Width; x += portionWidth)
{
if(x+portionWidth>img.Width)
{
portionWidth = img.Width - x;
}
if(y+portionHeight>img.Height)
{
portionHeight = img.Height - y;
}
Bitmap imgSplitted = new Bitmap(portionWidth, portionHeight);
Graphics gr = Graphics.FromImage(imgSplitted);
gr.Clear(Color.White);
gr.DrawImage(img, new Rectangle(0, 0, imgSplitted.Width, imgSplitted.Height), x, y, portionWidth,
portionHeight, GraphicsUnit.Pixel);
gr.Save();
imgSplitted.Save(Path.Combine(path, fileName + "_" + imageindex.ToString().PadLeft(2,'0') + extention));
imageindex++;
}
}
BEHTASH Moradi
benoistPosted Feb 9, 2009, 2:16 AM
I want to be able to give an image and draw rectangles on that image, and then create the additional slices at the same time.
I've found an algorithm for it, but its not a very good one (it takes too long with more slices).
Joel SequeiraPosted Feb 9, 2009, 1:01 AM
Well i am trying the same just sending the image path through the webservice and then slicing the images. Finding it difficult to code it out in .net C#. www.gasi.ch This is Daniel Gasenica's site...He provides usefull information on doing the same. We also have a deep zoom composer software for it.