abgconsulting
asked on
How to create an image define size, add some pictures and write on it programmatically?
I want to create an image with width 640 and my data length !!!
ASKER
Thks Jatkin for your response,
But how i can fill my image with my data, i have to fill it like a receipt of superMarket?
But how i can fill my image with my data, i have to fill it like a receipt of superMarket?
There of loads of different ways you can directly put info into an image.
Check out this article for some of the ones I use quite frequently...
http://www.codeproject.com/KB/web-image/TextOnImage.aspx
James
Check out this article for some of the ones I use quite frequently...
http://www.codeproject.com/KB/web-image/TextOnImage.aspx
James
You can use the PainEvent and draw the text into it with the e.Graphics.DrawString. It involves some preparation for the font and the color, but it lets you build an image from text. The documentation for the DrawString method has good samples of how to use it.
ASKER
James,
And what about the fact if i want to put an image at the beginning and at the end of my image ?
PMS
And what about the fact if i want to put an image at the beginning and at the end of my image ?
PMS
You can use the DrawImage method for situations like this, for example:
static public Bitmap Copy(Bitmap srcBitmap, Rectangle section)
{
// Create the new bitmap and associated graphics object
Bitmap bmp = new Bitmap(section.Width, section.Height);
Graphics g = Graphics.FromImage(bmp);
// Draw the specified section of the source bitmap to the new one
g.DrawImage(srcBitmap, 0, 0, section, GraphicsUnit.Pixel);
// Clean up
g.Dispose();
// Return the bitmap
return bmp;
}
static public Bitmap Copy(Bitmap srcBitmap, Rectangle section)
{
// Create the new bitmap and associated graphics object
Bitmap bmp = new Bitmap(section.Width, section.Height);
Graphics g = Graphics.FromImage(bmp);
// Draw the specified section of the source bitmap to the new one
g.DrawImage(srcBitmap, 0, 0, section, GraphicsUnit.Pixel);
// Clean up
g.Dispose();
// Return the bitmap
return bmp;
}
ASKER
Hi jatkin
I am a little confused, could you explain me again please.
I try to create an image and the image I want to put a picture at the beginning and another at the end and in between I want to put the string as the receipts of the supermarket.
If I am your thinking so you asked me to create a bitmap like this
System.Drawing.Image = new Bitmap myImage (600, 1000);
and use the method DrawImage
static public Bitmap Copy (Bitmap srcBitmap, Rectangle section)
{
/ / Create the new bitmap and associated graphics object
Bitmap bmp = new Bitmap (section.Width, section.Height);
Graphics g = Graphics.FromImage (bmp);
/ / Draw the specified section of the source bitmap to the new one
g.DrawImage (srcBitmap, 0, 0, section, GraphicsUnit.Pixel);
/ / Clean up
g.Dispose ();
/ / Return the bitmap
return bmp;
}
But where do I pass the pictures I add to my image?
Thanks in advance
PMS
I am a little confused, could you explain me again please.
I try to create an image and the image I want to put a picture at the beginning and another at the end and in between I want to put the string as the receipts of the supermarket.
If I am your thinking so you asked me to create a bitmap like this
System.Drawing.Image = new Bitmap myImage (600, 1000);
and use the method DrawImage
static public Bitmap Copy (Bitmap srcBitmap, Rectangle section)
{
/ / Create the new bitmap and associated graphics object
Bitmap bmp = new Bitmap (section.Width, section.Height);
Graphics g = Graphics.FromImage (bmp);
/ / Draw the specified section of the source bitmap to the new one
g.DrawImage (srcBitmap, 0, 0, section, GraphicsUnit.Pixel);
/ / Clean up
g.Dispose ();
/ / Return the bitmap
return bmp;
}
But where do I pass the pictures I add to my image?
Thanks in advance
PMS
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
System.Drawing.Image myImage = new Bitmap(600, 1000);
where 1000 is your data length?