Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Image size manipulation

Posted on 2000-05-31
8
Medium Priority
?
281 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 10

Accepted Solution

by:
RONSLOW earned 100 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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 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.

609 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