?
Solved

DPI Conversion

Posted on 2009-07-09
2
Medium Priority
?
2,435 Views
Last Modified: 2013-12-03
I have a scanned image of a document that is 366dpi

width: 3424
height: 5606

I want to convert the DPI to 300.  I have used the code attached to convert it successfully to 300.  However the physical size of the image has increased and is unacceptable for our needs.  I am looking for a way to change the dpi of a tiff/bitmap and keep the original physical size of the image.  Any ideas would be great.  I am working in C# .net.


Bitmap pages = null;
System.IO.FileStream myStream = new FileStream(strImageFile, System.IO.FileMode.Open);
 pages = (Bitmap)Image.FromStream(myStream);
 pages.SetResolution(newDPI, newDPI);
  pages.Save(outFile, info, ep);

Open in new window

0
Comment
Question by:alpacaman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 15

Accepted Solution

by:
oobayly earned 500 total points
ID: 24823579
You have to work out the physical size of the original first. Then you can create a duplicate of the original with a calculated pixel size based on your new resolution
      // Determine the Physical size of the original
      SizeF physical = new SizeF(
        pages.Width / pages.HorizontalResolution,
        pages.Height / pages.VerticalResolution);
 
      // Determine the required pixel size of the new image
      float newResolution = 300;
      SizeF newPixelSize = new SizeF(
        physical.Width * newResolution,
        physical.Height * newResolution);
 
      Bitmap newImage = new Bitmap(pages, Size.Round(newPixelSize));
      newImage.SetResolution(newResolution, newResolution);

Open in new window

0
 
LVL 1

Author Closing Comment

by:alpacaman
ID: 31601668
thanks for the snippet, helped a lot
0

Featured Post

Basic Security of Your VPC

So, you’ve got this shiny new VPC and a fancy new application configured on your EC2 servers ready to go. This application is only accessible from your computer, which is great for security, but you need your users to be able to access it! So, what’s the easiest way to do this?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
The viewer will learn how to count occurrences of each item in an array.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question