473,657 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

split an image programmaticall y

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
*-----------------------*
Nov 21 '05 #1
2 6997
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
*-----------------------*

Nov 21 '05 #2
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
*-----------------------*


Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
20193
by: DanS | last post by:
Does anyone know how to change an image from color to black and white / greyscale programmatically in c#? Nothing in the image or bitmap objects looked promising? thanks!
4
2997
by: murrayatuptowngallery | last post by:
I have looked at some mouseover/ sound object scripts and can't get them to work. Most were more complex than needed and introduced several new parameters for me. I found a simple pair of html code segments that accomplish display of an image and automatic 'display' (playback) of a .wav file, and apparently are usable for both IE and NS, " <object height="100%" width="100%"
2
5520
by: sandman | last post by:
Is this a one-time deal? Or something you want to do programmatically? If it's a one-time thing (e.g. to create a bitmap that you can then use in your program), just press Print-Screen, then load Microsoft PaintBrush and paste. Then you can select/cut/paste what you want and create little control bitmaps. If it's something you want to do in code, sorry, can't help. >-----Original Message----- >
3
2092
by: Rob Meade | last post by:
Hi all, I want to add an Image programmatically, but it needs to be a hyperlink - so do I add a Hyperlink object and then set its 'text' to be the "<img src=" etc or do I add a hyperlink and add a control to that which is the image?? Any info appreciated, Regards
3
1721
by: Kristof Thys | last post by:
Hello, I'm writing a ASP.net webservice wich will visualize an image, generated by another application. The generated image is a char*. I can transform this to a String*, but I want to view it as an image in my browser. Is this possible, and how should I do this? thx,
2
2624
by: UJ | last post by:
I have need to convert a text string (with formatting) to an image. This is so that I can resize the image to different sizes and the formatting stays exactly the same regardless of the size. I actually want the font size to increase/decrease as the image grows/shrinks much the way text does in a flash object. Is there an easy way to do this programmatically? It needs to be done behind the scenes on my web site - user enters some text - I...
1
3794
by: Rico | last post by:
Hello, I have an ole object field (Access XP/2002) which I store images in. I have a couple of questions regarding this; is it possible to determine the image dimensions? Secondly, is there any way to determine what application is associated with the stored OLE Object and is there a way to associate that object programmatically with another application? Thanks!
1
5124
by: ree321 | last post by:
When there is a long image in the HTML it is being split over two pages in the Print Preview rather than moving the image down to the next page. Is there a way to get around this so the image will not be split?
3
2469
by: najimou | last post by:
Hi everyone I will be having a split database, running on 2 computers via mapped drive. computer "A" will have one front end and the back end located in c: \mydatabse 2 tables have links to many images stored as c:\mydatabse\images \images.jpg so computer A has no problem accessing the picture
0
8425
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8326
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8845
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8522
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8622
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7355
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5647
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4333
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2745
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.