Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Member
656 Points
102 Posts
Apr 12, 2008 06:25 AM|LINK
Hi,Friends i want to slice an image in multiple parts.Like http://www.html-kit.com/e/is.cgi.
SplitImage Function as below
Dim cellWidth As Single = CType(wholeImage.Width / columns, Single) Dim cellHeight As Single = CType(wholeImage.Height / rows, Single) ' Create an array of RectangleF to hold the RectangleFs ' that define parts (cells) of the wholeImage. Dim rectangleFs((rows * columns) - 1) As Drawing.RectangleF ' Fill RectangleFs array with RectangleF objects. Dim currentRow As Single = 0 Dim currentColumn As Single = 0 Dim rectangleFIndex As Integer = 0 For currentRow = 0 To rows - 1 For currentColumn = 0 To columns - 1Dim newRectangleF As New Drawing.RectangleF() newRectangleF.X = currentColumn * cellWidth newRectangleF.Y = currentRow * cellHeight newRectangleF.Width = cellWidth newRectangleF.Height = cellHeight rectangleFs(rectangleFIndex) = newRectangleF rectangleFIndex += 1 Next Next ' Create an array of Images to contain the images ' that will be created from the wholeImage. Dim images(rectangleFs.GetLength(0)) As Image ' Fill images array with Images. Dim i As Integer = 0 For i = 0 To rectangleFs.GetUpperBound(0) Dim newBitMap As New Drawing.Bitmap(CType(cellWidth, Integer), _ CType(cellHeight, Integer)) Dim bitMapGraphics As Drawing.Graphics = Graphics.FromImage(newBitMap) bitMapGraphics.Clear(Color.Blue) bitMapGraphics.DrawImage(wholeImage, newBitMap.GetBounds(GraphicsUnit.Pixel), _ rectangleFs(i), GraphicsUnit.Pixel) images(i) = newBitMap ' wholeImage.Save("D:/Temp/" + i.ToString() + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg) Next Return images
Dim cellWidth As Single = CType(wholeImage.Width / columns, Single)
' Create an array of RectangleF to hold the RectangleFs
' that define parts (cells) of the wholeImage.
' Fill RectangleFs array with RectangleF objects.
Dim currentColumn As Single = 0
For currentRow = 0 To rows - 1
newRectangleF.X = currentColumn * cellWidth
newRectangleF.Y = currentRow * cellHeight
newRectangleF.Width = cellWidth
newRectangleF.Height = cellHeight
rectangleFs(rectangleFIndex) = newRectangleF
rectangleFIndex += 1
Next
' Create an array of Images to contain the images
' that will be created from the wholeImage.
' Fill images array with Images.
For i = 0 To rectangleFs.GetUpperBound(0)
CType(cellHeight, Integer))
bitMapGraphics.Clear(Color.Blue)
bitMapGraphics.DrawImage(wholeImage, newBitMap.GetBounds(GraphicsUnit.Pixel), _
rectangleFs(i), GraphicsUnit.Pixel)
images(i) = newBitMap
' wholeImage.Save("D:/Temp/" + i.ToString() + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
End Function
In this Function WholeImage is an image to be Splitted as System.Drawing.Image
integer rows & columns are into how many rows & cols to split the image.
May this helps you
Thanks
Jignesh
Split an Image into Multiple parts
jignesh_logi...
Member
656 Points
102 Posts
split an Image into Multiple Parts
Apr 12, 2008 06:25 AM|LINK
Hi,Friends i want to slice an image in multiple parts.Like http://www.html-kit.com/e/is.cgi.
I done it Like this.I writeSplitImage Function as below
Private Function SplitImage(ByVal wholeImage As Image, ByVal rows As Integer, ByVal columns As Integer) As Image()End Function
In this Function WholeImage is an image to be Splitted as System.Drawing.Image
integer rows & columns are into how many rows & cols to split the image.
May this helps you
Thanks
Jignesh
~ Remember To Mark The Post(s) That Helped You As The ANSWER ~Split an Image into Multiple parts
Arise, awake; and stop not till the goal is reached