In my project user will upload an image and the logo of project will be attached(Embeded) to the bottom of the image.
Is it possible to implement?
If yes then how to implement that?
Please help.
Yes it is possible to implement.
Look at the System.Drawing namespace.
You can use the Bitmap class - it will allow you to load images from files.
Create two bitmaps, one from each image then you should be able to impose the logo image onto the other one.
This is one fun example of how to do it:
Image backImg = Image.FromFile("bg.jpg");
Image mrkImg = Image.FromFile("watermark.png");
Graphics g = Graphics.FromImage(backImg);
g.DrawImage(mrkImg, backImg.Width/2, 10);
backImg.Save("result.jpg");
Some people call this watermarking, I would search around for that.
Have a look at http://www.codeproject.com/KB/GDI-plus/watermark.aspx
Related
This is a C# winforms question.
The process I am trying to achieve is the following:
Using AxAcroPDFLib I'm loading a pdf file to the form
I want the user to be able to specify a square on that PDF and create a bmp from it
That bmp will then be loaded to a OCR to become text
What is my issue:
Step 1 and 3 are easy to do, the problem is how to allow the user to draw a square on top of the AxAcroPDFLib for a screenshot.
I already got different ways to draw squares on native winform components, but AxAcroPDFLib does not support mouse down, up, move, etc and paint events.
There is the option to convert the PDF to bitmap and display it on a picturebox and deal with events for drawing the square. Problem with that approach is that my PDF's are usually more than two pages, and I would like to avoid the conversion pdf to bmp due to changes to image quality that will impact on OCR.
I came to think that maybe something that works as the windows snippingtool would do the the job. My application would get the screenshot, temporarily save the image on disk (must be a file for OCR), I would then pass it to the OCR and done. Hard part, I could not think on how to take the screenshot of part of the PDF.
Do anyone here have any suggestion to different components or workarounds to deal with the requirement above? I am using Adobe just because it is simple, but maybe there are other components better suited to handle my requirements? I googled but haven't found any free ones, trying to avoid paid options.
Thanks
At some point in this process, the PDF is going to have to be rasterized in order to be passed to the OCR, so I don't totally understand your objection to converting it to a bitmap. If you're okay with Snipping Tool's behavior, then you must be OK with the quality of the PDF control's PDF->screen rasterization. If that resolution is acceptable, why not just capture the control's content to a Bitmap and let the user draw the selection marquee over that Bitmap?
Here is code I'm using to capture a control's contents to a Bitmap in Windows Forms. One caveat is that this is really a screen capture, so any windows or controls that overlap the control's visible area will be captured in the image.
using (Bitmap b = new Bitmap(width, height))
{
using (Graphics g = Graphics.FromImage(b))
{
Point p1 = myControl.PointToScreen(new Point(0, 0));
g.CopyFromScreen(p1.X, p1.Y, 0, 0, size);
}
// do stuff here with your Bitmap
}
I have Panel on windows form containing labels for displaying information and 2 PictureBox controls. One for Company logo & other for captured photo. When i print them either on Printer or just save in PDF format, both images looking very blur. I want to improve quality of images. So they will appear clear even after zoom.
Any suggestion.
You can set this property of the Graphics object.
// g is type of Graphics.
g.InterpolationMode = InterpolationMode.High;
I don't know which technique you are using for printing but if you are using print form it is not good for decent picture or text. Therefore when you send form/PictureBox to the print object it would lose quality.The Solution is to use PrintDocument.
Share your code for more help.
Your printer has better resolution than your monitor. That bitmap won't work. You will have to recreate the print items directly on the e.Graphics of the PrintPageEventArgs.
Other work around is the technique that guy explain in his article.
http://www.dahuatu.com/3vy2K5z5mr.html
I have the following:
A headline (text)
A tagline (text)
A background image (url to this image)
I need to set these dynamically together in an image, and then store it as a PNG file. All of this happens in a web service which sends some kind of stream back.
I would love to be able to style this with CSS, as it would be nice to add some CSS effects to the picture. If that is not possible, it is fine as well.
So far I've thought about using the Bitmap class, and then insert my things dynamically. This is definetely one way to go, but I would really prefer some more design-friendly way like CSS.
What is the prefered way to do this? Any experiences?
Check out System.Drawing.Graphics.
Bitmap bmp = new Bitmap(500, 500);
using (Graphics g = Graphics.FromImage(bmp)) {
g.Clear(Color.Black);
// ...
}
You can then call Image.Save (bmp.Save(...)) to save the image to disk or even to a MemoryStream.
The answer from Angelo Geels will let you create a dynamic bitmap in your code. If you need more flexibility then you might want to use the SVG format instead, and possibly render it as a PNG file if you absolutely need that format.
SVG is an XML based image format where you define a viewport and shapes that should be drawn into it. It is vector based so the images can be scaled up and down to any size.
It should be quite easy to write an ASP.Net Http Handler that outputs an SVG xml file with some dynamic content based on user input. An even easier option would be to serve static SVG files that your designers create, but then you might as well serve static PNG files.
If you want to use the SVG approach for its flexibility but still need to output PNG's then you can use the SVG.Net library to read the SVG file and then use the SvgDocument.Draw method to draw the image to a Bitmap object that can then be written out as a PNG file.
My goal is to display a large rectangular image in a section of a webpage that will act as a background for other, smaller images to be laid on top of. The smaller rectangular images will be dynamically selected based upon database entries. I was able to create a java applet that drew the larger base rectangular image and then drew the smaller images over the base image. This worked very well.
I am attempting to recreate the functionality using C# in Microsoft Visual Web Developer 2010. I have found system.drawing functionally that may work, but haven’t found a web based solution yet. Any help would be appreciated.
If I understand correctly, you want to overlay smaller images on top of another image. At the end you'll end up with one image to display. This is easy to do in C#:
string image1 = #"c:\image.jpg";
string image2 = #"c:\image2.jpg";
System.Drawing.Image canvas = Bitmap.FromFile( image1 );
Graphics gra = Graphics.FromImage( canvas );
Bitmap smallImg = new Bitmap(image2);
gra.DrawImage( smallImg, new Point( 70, 70 ) );
canvas.Save( #"c:\newimage.jpg", System.Drawing.Imaging.ImageFormat.Jpeg );
My two cents here... Another thing which helped me on .NET 2.0 and 3.0 was explicitly deleting the Image, Graphics and Bitmap objects after you are done, specially when you would be accessing any of the image sources (image1, image2 and smallImg above) within the same routine.
Deleting these objects will instantly release the file locks. I experienced that the garbage collector wouldn't necessarily clean these up for me at the desired time, even if I made a separate sub-routine for my image manipulation.
I am wondering how to do the following ( couldn't get google to help me here ):
I got a .jpg file of about 250px*250px in scale..
I want this image on a DIN-A4 page as often as possible
I need an "overlay" for every image on the page with a unique code ( lets say a unique barcode for example )
How would i start here? I have really no idea which classes or methods to use for this...
Also it'd be interesting to know which "formats" i can create the documents in...
Thanks for any help!
Well, you know how big the image is, and how big the paper is, so it's easy to work out how many you can fit on a page.
Then you'll want to create an instance if the Bitmap class from your jpg, then get a Graphics object from the bitmap, call the Graphics object's DrawString method with your text (plus a font, a brush, and a point). Remember to release the Graphics object or, ideally, wrap it in a using statement.Then, as Henk says, use a PrintDocument to print it - there's an example here of that - and write your images in as required to fill the page using the PrintPageEventArgs' Graphics object.