zoom bitmap in CStatic Picture Control

Hello NG,

I show an image with SetBitmap of my CStatic Picture Control in a dialog. My
CStatic window's size is unsizable, so I let the image be shown centred. But
each image is dimensioned differently. How can I zoom the image in my
CStatic?


CRect rect;
m_stcPic.GetWindowRect(rect);  // mein CStatic Picture Control

double fx = (double)image.GetWidth() / (double)rect.Width();
double fy = (double)image.GetHeight() / (double)rect.Height();

HBITMAP m_bitmap = image.MakeBitmap();

if (fx > fy)
{
    // use fx to zoom
}
else
{
    // use fy to zoom
}

m_stcPic.SetBitmap(m_bitmap);


In my CStatic rect (160x160) could be shown a big image (320x190) with zoom
fx=2.
Thanks for help,
Guido



0
guidof73 (128)
12/8/2006 3:35:48 PM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
1167 Views

Similar Articles

[PageSpeed] 50

You could use GDI+ to do this sort of thing:

http://www.codeproject.com/useritems/GDI_.asp

Tom

"Guido Franzke" <guidof73@yahoo.de> wrote in message 
news:u0CjM6tGHHA.1080@TK2MSFTNGP05.phx.gbl...
> Hello NG,
>
> I show an image with SetBitmap of my CStatic Picture Control in a dialog. 
> My
> CStatic window's size is unsizable, so I let the image be shown centred. 
> But
> each image is dimensioned differently. How can I zoom the image in my
> CStatic?
>
>
> CRect rect;
> m_stcPic.GetWindowRect(rect);  // mein CStatic Picture Control
>
> double fx = (double)image.GetWidth() / (double)rect.Width();
> double fy = (double)image.GetHeight() / (double)rect.Height();
>
> HBITMAP m_bitmap = image.MakeBitmap();
>
> if (fx > fy)
> {
>    // use fx to zoom
> }
> else
> {
>    // use fy to zoom
> }
>
> m_stcPic.SetBitmap(m_bitmap);
>
>
> In my CStatic rect (160x160) could be shown a big image (320x190) with 
> zoom
> fx=2.
> Thanks for help,
> Guido
>
>
> 


0
tserface (3860)
12/8/2006 3:44:33 PM
You can stretch it the way you want it. Here is a sample which shows various
stretchings:

http://www.codeproject.com/dialog/bmpdlg01.asp

-- 
Ajay Kalra [MVP - VC++]
ajaykalra@yahoo.com


"Guido Franzke" <guidof73@yahoo.de> wrote in message
news:u0CjM6tGHHA.1080@TK2MSFTNGP05.phx.gbl...
> Hello NG,
>
> I show an image with SetBitmap of my CStatic Picture Control in a dialog.
My
> CStatic window's size is unsizable, so I let the image be shown centred.
But
> each image is dimensioned differently. How can I zoom the image in my
> CStatic?
>
>
> CRect rect;
> m_stcPic.GetWindowRect(rect);  // mein CStatic Picture Control
>
> double fx = (double)image.GetWidth() / (double)rect.Width();
> double fy = (double)image.GetHeight() / (double)rect.Height();
>
> HBITMAP m_bitmap = image.MakeBitmap();
>
> if (fx > fy)
> {
>     // use fx to zoom
> }
> else
> {
>     // use fy to zoom
> }
>
> m_stcPic.SetBitmap(m_bitmap);
>
>
> In my CStatic rect (160x160) could be shown a big image (320x190) with
zoom
> fx=2.
> Thanks for help,
> Guido
>
>
>


0
ajaykalra (6842)
12/8/2006 3:49:34 PM
You can use mapping modes.  You can also use SetWindowOrg/SetViewportOrg to allow the user
to pan the image.  Download my Viewport Explorer for examples of doing this.
					joe

On Fri, 8 Dec 2006 16:35:48 +0100, "Guido Franzke" <guidof73@yahoo.de> wrote:

>Hello NG,
>
>I show an image with SetBitmap of my CStatic Picture Control in a dialog. My
>CStatic window's size is unsizable, so I let the image be shown centred. But
>each image is dimensioned differently. How can I zoom the image in my
>CStatic?
>
>
>CRect rect;
>m_stcPic.GetWindowRect(rect);  // mein CStatic Picture Control
>
>double fx = (double)image.GetWidth() / (double)rect.Width();
>double fy = (double)image.GetHeight() / (double)rect.Height();
>
>HBITMAP m_bitmap = image.MakeBitmap();
>
>if (fx > fy)
>{
>    // use fx to zoom
>}
>else
>{
>    // use fy to zoom
>}
>
>m_stcPic.SetBitmap(m_bitmap);
>
>
>In my CStatic rect (160x160) could be shown a big image (320x190) with zoom
>fx=2.
>Thanks for help,
>Guido
>
>
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15973)
12/8/2006 6:58:18 PM
Reply:

Similar Artilces:

calculated control in access subform
Hi there. I need some help with a calculated control for a subform. when i return to the main i get #error or name. I don't understand what i am doing wrong. I have to have sum of the contract amt. this is hard to explain. here are some that i have been using. =ContractSubform.Form!txtContractAmtSum =sum(contractAmt) both of these will not work. the first one i thought would work but dont know why it wont please help jwb Where did you place this control? Open the subform in design view. Move the text box into the Form Footer section (not Page Footer.) If you don't see any Fo...

Sending pictures to mobile
Hi We have a staff database app that also stores staff pictures with each staff record. I have been asked to design something so we can send pictures of staff to people's mobiles when they need it for ID purposes. I have no idea where to start on this. Has anyone has any experience of such an application (sending pictures to mobiles from access)? Any pointers would be appreciated. Thanks Regards "John" <John@nospam.infovis.co.uk> wrote in message news:eohOMSc5HHA.5160@TK2MSFTNGP05.phx.gbl... > Hi > > We have a staff database app that also stores staff...

Lost picture and graphics problem
Earlier I asked about losing embedded graphics in Publisher 2003 files. The frames were there and the thumbnails showed up on the Graphics manager screen, but the images would not display on screen. From an earlier exchange I found a reference to changing the acceleration speed on the video card and that solved the problem. All my embedded images are back. Now I need some luck in getting an updated video driver from Intel. Thanks! The Intel web site has an option to search for your chip set automatically... http://downloadfinder.intel.com/scripts-df-external/Support_Intel.aspx -- Mary ...

Filter XML to pass to XSL and import into my control?
I'm still struggling to figure out the big-picture concept of how to go about building a web site menu from an xml file. The XML file contains the full site structure (the site map, so-to-speak). Based on the current page of the site, I want to be able to do the following: get node that pertains to current page get node's siblings get node's parents get node's parents siblings repeat until top node... Pass this filtered XML to an XSLT file import xhtml result into my usercontrol to display on page I asked this yesterday but was a bit too wordy I think. Does the above sound l...

Cutomize the zoom to 80%
Dear all I have to open a lot of excel files one day, but the view size is not the same. How can do that the view size will always change to 80% when I open each file. -- wuwu Hi you have to put this code into the workbook_open event of these files. AFAIK there's no other option to achieve this -- Regards Frank Kabel Frankfurt, Germany "wuwu" <wuwu@discussions.microsoft.com> schrieb im Newsbeitrag news:DB0A8875-19A3-4113-A19F-0D642A9E02F3@microsoft.com... > Dear all > > I have to open a lot of excel files one day, but the view size is not the > same. Ho...

Handling pictures with VBA in a worksheet
How do I code the pasting of pictures in a worksheet to ensure they don't overlap? Is there a way to find out the edge of a picture then paste after it (or something like that)? Thanks! I don't see anything wrong with using the cells as my grid for my pictures: Option Explicit Sub testme01() Dim myPict As Picture Dim myAddresses As Variant Dim iCtr As Long Dim wks As Worksheet Dim myPictures As Variant Set wks = ActiveSheet myAddresses = Array("a1:c3", "d1:f3", "g1:i3") myPictures = Array("C:\mypict.j...

Zoom-in and Zoom Out
I am relatively new to charting so I am hoping this is a feature I am just ignorant of, Can anyone fill me in ? I am use to programs that produce maps. these programs allow you to start at country may and zoom into a state and resize, then zoom into a city and resize, zoom into a street and resize, and the same in reverse if you want. I thought I could do the same with a chart. Start with a 100 year chart, using the mouse select an X, Y range and it would zoom into that range. But it does not do anything like that. Is there anyway to get excel to do this ? If not does anyone know of an add-...

Pictures
I recently installed Office 2000 professional and now I'm unable to open pictures in Outlook when I receive them an email. Any idea on how to fix this problem? Thank you Lily ...

Insert picture quaz for click time
i don't no. thank.. -- kongkla ...

Problem in Zoom in and Zoom out
hi all, I have created project in SDI. I have a class MyZoomView derived from CScrollView. i have some rectangular shaped box in the View window of SDI.... when i press zoom button in toolbar the rectangular shaped box is getting zoomed in and out. I have added two button's in the View window of SDI... Now when i click the zoom button in toolbar my rectangular shaped box is getting zoomed but the buttons are in same size.... i want the buttons also to get zoomed along with the rectangular shaped boxes.... Can anyone plz help to solve this problem..... If possable get me the sou...

Picture Tools
In Picture Effects, reflection variations have options for reflections "touching", reflections with a "4 pt offset", and reflections with an "8 pt offset". How can the offset be changed/increased to a larger offset amount? This formatting is needed to position the reflection further away from the actual picture than the largest option provided of 8 pt offset. Avid Gardener wrote: > In Picture Effects, reflection variations have options for reflections > "touching", reflections with a "4 pt offset", and reflections with an &...

Zoom in/ Zoom out images
hi , I am creating dialog box apllication where i have to laod images in Picture control which will be from a file. After the image has been loaded I have to make two buttons for Zoom in/ out . The problem I am facing is that i am sucessfully loading the image but at the time of zoom i cant able to select that image from picture control(CStatic ). I am getting a null handle for HBITMAP hBmp = m_ctlImage.GetBitmap(); where m_ctlImage is my static picture control style - frame I am displaying image by StretchBlt. Plz tell me the approach. klic > I am ...

control panel applet with Windows XP theme
I have added a .manifest file with a value of 1 to my resource. When the control panel opens it, the applet still shows the old style buttons, etc. What else might I have to do to make the UI render properly? >I have added a .manifest file with a value of 1 to my resource. When the >control panel opens it, the applet still shows the old style buttons, etc. David, See the MSDN topic titled "Using Windows XP Visual Styles" - "Using ComCtl32 Version 6 in Control Panel or a DLL That Is Run by RunDll32.exe". Dave Lowndes -- MVP VC++ FAQ: http://www.mvps.org/vcf...

Customer Zoom
Somehow I messed up my customer zoom feature and cannot zoom to my advancerd lookups anymore. My zoom display is completely different than the Vendor zoom display. How can I get the default zoom feature back? ...

Domain controler for exchange?
Does the server running Microsoft Exchange 2003 standard edition need to be a domain controller as well? I have an windows 2000 Domain controler and the Exchange server is on that domain, but it is not currently a domain controller. i wanted to verify this before i switched the MX record and began testing. Nope. It's "supported" to run Exchange on a Domain Controller, but not recommended. -- Ben Winzenz Exchange MVP MessageOne Read my blog! http://winzenz.blogspot.com http://feeds.feedburner.com/winzenz (RSS Feed) "Vintage" <Vintage@discussions.microsoft.c...

Bitmap-Icons in Resource
Hello NG, I have drawn some icons in the correct sizes and color depth as bitmap files. Now I want to overwrite the existing programme icons in Visual Studio ..NET 2003. I only can copy and paste one into the existing opened icon. But some color definitions are not copied (e.g. white gets yellow). Is there another way to include my bitmaps as icons into the project resource? Or how can I keep the original color table? Thanx for help, Guido Franzke It's better to replace the icon file, instead of coping and pasting every single image type into the icon file using the Resource editor. ...

Purchasing Invoice Enquiry Zoom isn't able to drill to POP Enquiry
At present when you view a Purchasing Invoice you don't appear to be able to Drill down on the POP Number to be able to view the Purchase Order Details. This is very frustrating as you have to go into a seperate enquiry. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree" in the message pa...

Alter zoom text default font
We use replication and so are required to have memo fields unbound. That means text cannot be entered directly into them. Instead, we have a command button that brings up the "zoom" window, which is not a control with editable properties. The zoom window (as in "Zoom" to view/edit a property field) has a built in font command button, but that is what we are trying to get around using. It is time consuming to adjust it to a readable size everytime the window is opened. How can the default font of that "zoom" window be adjusted? While it is possible t...

Word Freezes when inserting pictures
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel My word freezes every time I try to insert a picture into the document. I checked to make sure the program had enough virtual memory, also changed savings settings. I also tried shrinking the picture file to a smaller size but word still freezes when i insert. Please advise. Make sure Office is fully updated, then repair disk permissions & restart. If the situation doesn't improve please reply in detail about how you are inserting the picture, what the file format & file size of the image is...

zoom
How can you zoom in outlook without changing screen resolution? ...

Insert Picture from dropdown selection
I'm working at a Marina and trying to make a comparison chart for different types of boats. I am trying to make a list, and based upon the users selection of a boat, insert a corresponding picture to match the boat selected from that list. I've researched other thread discussions, and tried to approach it this way, as reccommended by Ron Coderre: Select Sheet2 and turn off Grid Lines (Tools>Options>View tab:Uncheck Grid Lines) 1)For each picture to be displayed: 1a. Insert>Picture from file. (select picture, put it in the sheet and resize it). 1b. Select the range of cel...

Limiting the number of selections in a List Box Control
Hi Folks, I have a list box (multiselect = simple) that is dynamically populated by a query. I want the user to select only two items from the list and then i want to use these two items to run another quesry which will be the source data for a report. How do i force the List Box to allow only two selections? Regards, John Dumay On Sun, 30 Dec 2007 20:44:01 -0800, John Dumay wrote: > Hi Folks, > > I have a list box (multiselect = simple) that is dynamically populated by a > query. I want the user to select only two items from the list and then i want > to use these ...

How to insert a realplayer G2 control into a rich edit control?
I try to insert a realplayer G2 control into a rich edit control but failed. There is only a blank rectangle. Please help here. +++++++++++++++code begin+++++++++++++++ CTestEmbedActiveXView *pView=(CTestEmbedActiveXView *)GetActiveView(); pView->GetRichEditCtrl().ReplaceSel(_T("begin insert a realplayer activex control.\n")); LPSTORAGE lpStorage=NULL; LPOLEOBJECT lpObject=NULL; LPVIEWOBJECT2 lpViewObject=NULL; LPDATAOBJECT lpDataObject=NULL; RECT rc; rc.left=0; rc.right=300; rc.top=0; rc.bottom=100; BOOL bResult=m_realplayer.Create(NULL,_T("realplayer wnd&...

Zoom
I have vision problems. Excel's Zoom feature, although not perfect, is of great help. My basic problem is that Zoom only affects the spreadsheet itself. It does not change the size of menus or tool bars. In particular, I have problems using the Formula Bar for working out formulas. On the Mac, I can expand a portion of the entire screen using Universal Access. My guess is that there is an equivalent for Windows. While that can be helpful, I prefer having the spreadsheet stationary on the screen so I do not have to chase motion with my mouse. My question is: Is there a way of zoomi...

Picture in header not printing
Currently use Office 2003 and having a problem in Word. Have created a Header with both text and also a picture file of a logo. On this PC both display in the normal view but in print preview and when the doc is printed the logo does not display or print. Have tried shrinking the logo/pic and also increasing the margins so the header is huge but the logo never displays or prints but the text does. This is also happening to objects that are not texts that are on other Word docs. Regular texts is fine but anything else that's an object or pic inserted in does not display in pri...