Solved

Image size manipulation

Posted on 2000-05-31
8
263 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Handle Exceptions during instantiation 28 416
VS2015 compilation and missing DLLs 9 147
c++ syntax question 9 49
operator overload: incompatible type and too many params 5 77
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…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
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.

809 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