Solved

Image size manipulation

Posted on 2000-05-31
8
272 Views
Last Modified: 2012-05-04
how do you change the size of a given image (of bmp,jpeg,etc )of whatever size to some predefined sizes (eg: passport size,wallet size,A4 paper size) and print it using C++ .
0
Comment
Question by:prashant_bk
[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
8 Comments
 
LVL 7

Expert Comment

by:KangaRoo
ID: 2618972
What OS etc.

The easiest way is to change the relevant info in the header of the image file, ie
an 3000 pixel wide image will be 10 inches wide when the resolution is 300 pixels/inch and only 5 inches when the resolution is 600 pixels/inch(dpi)

If you should do the printing, it's may be possible to tell the printing library how big the image should be. In Win32 you might be using StretchDiBits() to specify the size of the printed image.
0
 

Expert Comment

by:dmatheo
ID: 2872938
Here is something that you can do.
1. change the width and height information in the bmp header info record.
2. you can use some scaling algorithm to scale the image from what it used to be to the size you desired.

that's all. Hope that helps.
0
 
LVL 1

Expert Comment

by:Ik_Khan_Pk
ID: 2873220
IPicture interface provides all about the picture manipulation visit the msdn library
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Accepted Solution

by:
RONSLOW earned 50 total points
ID: 2874495
In Win32, OleLoadPicture will load an image in bmp, jpg or gif format (also metafile).  Once loaded, you get an IPicutre objetc which can then draw itself at whatever size using the Render method.

There is a sample (LoadPic ???) in MS KB that shows how to use OleLoadPicture to read from a named file. Basically, you open the file, read it all into a global and put a stream on the global and pass that to OleLoadPicture.

As far as getting a particular size, you'd query the device you want to print/draw onto for its resolution and size with GetDeviceCaps.  Then you'd set up a mapping mode for your DC so you can specify the actual size of the output.  Then call Render to draw the IPicture onto a rect of the appropriate size.

This solution will not allow you to re-save the image as a jpg/gif as the default IPicture only saves images as BMP format, but if display/print is all you want, then that should do it.
0
 
LVL 7

Expert Comment

by:KangaRoo
ID: 2876503
But does phrasant use MSVC I wonder.
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 2878828
Guess we'll find out when he accepts or rejects on comments on the answer.
0
 

Expert Comment

by:junkyboy
ID: 3313281
Looking........
0
 
LVL 7

Expert Comment

by:KangaRoo
ID: 3356273
My, old Q. Seems that phrasant has forgotten about it and we wont find out whether he uses MS or not ;)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

724 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