dineshbajaj,
Here is a function that splits an image into an array of smaller images. In you pass in rows = 2 and columns = 2 you will get back four images, each a quarter of the original image, each representing a different quadrant of the image.
Private Function SplitImage(ByVa l wholeImage As Image, ByVal rows As Integer, _
ByVal columns As Integer) As Image()
Dim cellWidth As Single = CType(wholeImag e.Width / columns, Single)
Dim cellHeight As Single = CType(wholeImag e.Height / rows, Single)
' Create an array of RectangleF to hold the RectangleFs
' that define parts (cells) of the wholeImage.
Dim rectangleFs((ro ws * columns) - 1) As 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 - 1
Dim newRectangleF As New RectangleF()
newRectangleF.X = currentColumn * cellWidth
newRectangleF.Y = currentRow * cellHeight
newRectangleF.W idth = cellWidth
newRectangleF.H eight = cellHeight
rectangleFs(rec tangleFIndex) = newRectangleF
rectangleFIndex += 1
Next
Next
' Create an array of Images to contain the images
' that will be created from the wholeImage.
Dim images(rectangl eFs.GetLength(0 )) As Image
' Fill images array with Images.
Dim i As Integer = 0
For i = 0 To rectangleFs.Get UpperBound(0)
Dim newBitMap As New Bitmap(CType(ce llWidth, Integer), _
CType(cellHeigh t, Integer))
Dim bitMapGraphics As Graphics = Graphics.FromIm age(newBitMap)
bitMapGraphics. Clear(Color.Blu e)
bitMapGraphics. DrawImage(whole Image, newBitMap.GetBo unds(GraphicsUn it.Pixel), _
rectangleFs(i), GraphicsUnit.Pi xel)
images(i) = newBitMap
Next
Return images
End Function
--
Mike
Mike McIntyre
Visual Basic MVP
www.getdotnetcode.com
"Peter Proost" <pp*****@nospam .hotmail.com> wrote in message news:Ok******** *****@TK2MSFTNG P10.phx.gbl...
first calculate the different x,y positions you want to get from the source
image, then the height and with of every piece and use g.drawimage
Dim g As Graphics
Dim x(8) As Bitmap
for i as integer = 0 to 8
x(i) = New Bitmap(90, 90)
g = Graphics.FromIm age(x(i))
g.DrawImage(Pic tureBox1.Image, New Rectangle(0, 0, 90, 90), x, y, 90, 90, _
GraphicsUnit.Pi xel)
next
hth
"dineshbaja j" <di****@palew ar-dot-com.no-spam.invalid> wrote in message
news:41******** @Usenet.com... Hi Everybody,
I need to split an image file(*.jpeg) programmaticall y to nine or more
equal parts.
Since, the code is meant to run on Windows Pocket PC 2002, I can only
use methods supported by the .Net Compact Framework.
Thanks in Advance,
*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*