Solved

Image size manipulation

Posted on 2000-05-31
8
255 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
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
 
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

708 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now