Solved

Image size manipulation

Posted on 2000-05-31
8
268 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
Industry Leaders: 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

696 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