How do I zoom into a picture by a percentage without loosing its quality?

I am implementing an MFC static library module in C language with Visual Studio 6.0 and i want to implement a function that makes zoom into a picture by a percent given. (For 0< percent < 1 make it smaller and for percent > 1 make it bigger. ) The picture is of a face and is grayscale and I dont want to miss any information out of it.
The reason why i want to do this, is because i have a bounding box of random pixel dimensions (eg 300x300 or 350x162 or 400x400 or 100x110 or what ever smaller than 500x500) and i want it to be resized to (100x150).
Thank you
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

>> The picture is of a face and is grayscale and I dont want to miss any information out of it.

What do you mean by "not missing any information" ? If you make the image smaller, certain pixels will be lost ... If you make it bigger, you'll have to fill in (guess, extrapolate) ceryain pixels. In any case, the data will not be exactly the same.
evilrixSenior Software Engineer (Avast)Commented:
You'll find a number of image manipulation libraries at the site below

Specifically, try looking at ImageMagick

"ImageMagick┬« is a software suite to create, edit, and compose bitmap images. It can read, convert and write images in a variety of formats (over 100) including DPX, EXR, GIF, JPEG, JPEG-2000, PDF, PhotoCD, PNG, Postscript, SVG, and TIFF. Use ImageMagick to translate, flip, mirror, rotate, scale, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and B├ęzier curves.

The functionality of ImageMagick is typically utilized from the command line or you can use the features from programs written in your favorite programming language. Choose from these interfaces: G2F (Ada), MagickCore (C), MagickWand (C), ChMagick (Ch), ImageMagickObject (COM+), Magick++ (C++), JMagick (Java), L-Magick (Lisp), NMagick (Neko/haXe), MagickNet (.NET), PascalMagick (Pascal), PerlMagick (Perl), MagickWand for PHP (PHP), IMagick (PHP), PythonMagick (Python), RMagick (Ruby), or TclMagick (Tcl/TK). With a language interface, use ImageMagick to modify or create images dynamically and automagically.

ImageMagick is free software delivered as a ready-to-run binary distribution or as source code that you may freely use, copy, modify, and distribute. Its license is compatible with the GPL. It runs on all major operating systems."

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
The fundamental procedire is:

1) Create a new bitmap that has the desired size
2) Use this GDI function to copy the data, stretching or shrinking as needed:

I must also echo what Infinity08 said:  If you make an image larger (to "zoom in" on it) then you do not get more detail... you just get bigger pixels (unlike what you see in crime-drama TV shows where they magnify a blurry image of somebody's wristwatch to get the reflection of somebody's eyeglasses in order to view the words on a scrap of paper across the street).  All you get is bigger dots.  Likewise, if you shrink an image, you *must* lose detail by thowing out some pixels.  Images shrunk that way usually look fine, but data is inevitably lost (so you must always keep a copy of the original image).

Do you need help in figuring out how to apply a percentage growth or shrinkage in order to calcuate the new size?
You can use IPicture interface:
>>>> The picture is of a face and is grayscale and I dont want to miss any information out of it.
The only way to 'miss' no information is to provide a own picture for each resolution you want to display. All other methods will give poor to bad results, especially if the 'source' you operate on already is *reduced* to screen resolutions. If you have photo resolution your picture may have a hundred times more pixels than with the desired 300 x 300 screen resolution. With the photo as source you may get acceptable images on screen when using professional tools. But if you already have reduced information you were lost, especially if there is any text inside.

You easily can see what I mean if you would call the StretchBlt function (which actually would do what you were requesting). If the new resolution was smaller, the StretchBlt simply cuts some columns or rows what rarely gives accepable results.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.