Change the resolution of a jpeg image using C# - c#

I need to modify the vertical and horizontal resolutions without changing the image dimensions.

Check out the Bitmap.SetResolution Method.

If all you have is GDI, have a look at this link.
You can save the Bitmap to a JPEG file using this snippet:
bmp.Save("picture.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

The resolution is contained in EXIF tags within the JPEG file.
Here's one article that gives source code for doing similar things in C#:
http://www.codeproject.com/KB/graphics/EXIF_tag_Editor.aspx

Related

ImageResizer best settings for max quality

I'm using image resizer for resizing photos in jpg format. Photos mostly contains people, but I've some problem with quality, even I set quality=100 It's not satisfying. Resized photo Is blurred and looks ugly :). I'm using mode=pad, scale=canvas, trimming and size properties. Which plugins, parameters and setting is best for get max quality resized photos?
You may be expecting more sharpening to be applied during resizing. If you use Imageflow.NET, or the ImageResizer FastScaling plugin, you can apply this using f.sharpen=15&down.filter=mitchell.

Convert two images into a pdf

I want to convert 2 images into a single pdf file.One image is big in size and small image on the top of the big image.
So In generated pdf also I need to show the small image on the top of the big image and also in the same position where it is in case of image.
I use pdfSharp to convert image to pdf.It will convert the images into pdf file but not able to position the second image on the top of the first image.
Can any one help me on that.Thanks in advance.
Check out the sample below and see if it's what you need:
http://pdfsharp.com/PDFsharp/index.php?option=com_content&task=view&id=34&Itemid=45

Dynamically create a picture with some texts and background image as PNG

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.

Convert a jpeg image series into vti image file

I'm using VTK API in my C# application. Please can someone explain how to convert my image series which is in .jpeg format to .vti image file to be able to use it in my application? The image series contains sequential abdomen images. Quick reply will be most appropriated. Thanks in advance!
You can read each image in the series using:
http://www.vtk.org/Wiki/VTK/Examples/Cxx/IO/JPEGReader
Then, you could combine them into a 3D image manually:
http://www.vtk.org/Wiki/VTK/Examples/Cxx/ImageData/IterateImageData
Or more automatically with:
http://www.vtk.org/Wiki/VTK/Examples/Cxx/Images/CombiningRGBChannels

manipulate images at pixel level in C#

I have a ppm file and I figured out how to mirror the image from the middle but I can't figure out how to horizontally flip it.
this is the code for the mirror function:
{R[x][y]=R[WIDTH-x][y];
G[x][y]=G[WIDTH-x][y];
B[x][y]=B[WIDTH-x][y];}}
the horizontal flip function should look almost the same as above. but achieve a flipped image.
Use System.Drawing.Bitmap
GetPixel()
SetPixel()
The MSDN Documentation for System.Drawing.Bitmap

Categories

Resources