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
2186 Views

Similar Articles

[PageSpeed] 12

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 (3861)
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 (15975)
12/8/2006 6:58:18 PM
Reply:

Similar Artilces:

Enter Key Jump controls
Hello. I have a Dialog and several Edit Box. when i press control Key my program stops. I'd like to press enter key and jump to the next edit box or another control. Any help?? >when i press control Key my program stops I am not sure why this is happening? You could add PreTranslateMessage(MSG* pMsg) to the Dialog Then change the keys, or move to some other control, or do whatever you want to do. I'm not sure if you have to do this to each control, or just the dialog in general. From experience, I would not change the default behavior, such as tab moves to the next control Whe...

Copy a currency value from one control to another
I have a text box (called ExtendedCost), that has a sum statement in it. I want to copy the value on the exit control event to another text box control (called WithdrawlAmount) on the same form and write the value into WithdrawlAmount box on the Enter Event for the control box, so people don't have to input the same number into the control box. Is there an easy way to do this? If it's the same calculated value, just use the same expression. Generally, don't store calculated values. Just perform the calculation as needed. If you need more help with this, describ...

How to transparent editbox control works correctly...
Hi i am working on an application where i have dialog based application. On dialog there is a picture control which displays a picture. Now i want to put an edit box. Text box string is current time which i am getting from OnTimer handler. i want that editbox control should be transparent except text in it. for this i have work with following code and get succeed in OnCtlHandler of dialog if(pWnd->GetDlgCtrlID() == IDC_EDT_Isha) { pDC->SetBkMode(TRANSPARENT); hbr = (HBRUSH)GetStockObject(NULL_BRUSH); } it makes the backgound tranparent but when the value of the edit box change...

Saving a chart as a picture file
Hi everyone. It is possible to save a chart as a picture (*.gif, *.jpg, etc.)? What I've been doing so far is saving the file as a web page, opening the page in internet explorer and then saving the chart as a picture file. However, when I do this the chart is not saved as a large file - this method is also too time consuming, since I am dealing with 70+ charts. Thanks for any help. Fred. I think he wants Walkenbach's chart tools: http://www.j-walk.com/ss/excel/files/charttools.htm Jon Peltier wrote: > Fred - > > You want VBA's Chart.Export method. Here's...

Direct Debit posted control
Currently GP will assume once a customer is marked with bank account details the system will assume all invoices are taken by DD and the only time this can be amended is prior to posting to the ledger. The ability to amend a posted invoice to either be DD payment or remove the DD payment until the invoice is fully paid would be useful ...

Finding the position of a certain picture on the screen
Hi everyone, I need to make a program in c# that will find a certain picture (not a big picture, few pixels in a certain formation, which is not necessarily a rectangle) on the computer screen. I haven't really done something like that before, so I'm not sure how to do it. what I had in mind was taking a screenshot (I found a tutorial that explains how) and then start checking every pixel in the screenshot until I find one that looks like one of the pixels in my picture, and then check if there are pixels next to him that are same to the ones in the picture, and in the same fo...

blinking tabs in an owner drawn tab control
Hi all, I need to blink tab or atleast tab text in an owner drawn CTabCtrl derived Tabcontrol. Please guide me how to do it. Regards Shoeb Implement WM_TIMER (SetTimer/OnTimer...). In OnTimer message handler change something conserning what you want to blink (text- or bk-color or some font parameters or something else what makes sense for you) Victor "shoeb" wrote: > Hi all, > I need to blink tab or atleast tab text in an owner drawn > CTabCtrl derived Tabcontrol. Please guide me how to do it. > > Regards > Shoeb > &g...

Refering to control property on a form in VB
Hi I am trying to simply my code in a application by using a sub routine to amend the control properties of a form but I can't seem to get basic to accept the control property being sent to the routine as a string The code I am using is : Private Sub lSubControlPropertySet(stForm As String, stControl As String, stProperty As string, varValue As Variant) If IsNull(varValue) = True Then Forms(stForm)(stControl)(stProperty) = "" Else Forms(stForm)(stControl)(stProperty) = var...

Adding custom fields to dynamically created controls.
I created a custom Outlook (2003) form that imports data from Access to populate user defined fields and create additional controls based on the number of records in an Access query. Everything works fine except the data the user enters for the dynamically created controls don't hold their value when the form is sent. I am quessing that is because there is no user defined fields bound to them. (how do I do this) I have been looking on the net but cannot find anything close enough. Any help (examples) would be appreciated. Look at http://www.outlookcode.com/d/formcontrols.htm, lots of inf...

How to control graph area
Still running stone age version of excel (97). Att least in this version it is very difficult to control the size of the diagram area when you cetreate a graph with the diagram tool. This problem is dual. On the one hand there is no entry/input (that I can find) to specify an EXACT diagram area (in pixels, cm etc. On the other hand if you use the drawing to to create the exact borders of the desired area and then adjust the diagram (the coordinate system) acrodingly - the d' thing won't remain stable. Now is ther anyone out there how knows what to do. A hidden surface entry for...

How to add Upper/lower control limit lines to a graph (not drawn)
I have several quality charts that I do monthly. How can I get the the upper, lower and center lines to appear at a specific data point (number) as part of hte chart format. In other words, withiout having to use the Draw Line tool each time? Excel 2003. Fake it. In other words, seutp some "dummy" series that are calculated, and plot them on your chart. Format them to look however you like, and remove the original chart gridlines. If you have a legend, single-click twice the legend entry for your dummy series and press delete. If done correctly, the entry will not...

Bug: (MFC 7.1) Paste into CRichEditView copied from other RichEdit control
Recently, I was helping someone figure out a problem in an MFC application recently upgraded to VC 7.1 (MFC 7.1) from VC 6.0 (MFC 6.0). While running on Windows XP, if you copied text from another CRichEditCtrl, CRichEditView, or another application using RichEdit like WordPad or Word, pasting what you've copied into a CRichEditView would paste nothing. When googling to try to find clues, most of the time there was either no response to the question, or the work around was to change the "copy" end that you controlled, and only put CF_TEXT on the clipboard. However, it ...

Looking for control to browse files
Hi, I am pretty new to and unexperienced with access (2007 is the one I amworking with) I have made a database (of 1 table) to record registered mail and such. I have added a hyperlink field which contains the link to a specific transmittal document showing the contents of the mail item. I have added it to the form and it works fine. If I click on the link it opens the (Word) transmittal file). So far so good. What I want is a control that lets me browse for the transmittal file, something like a simple Open dialog Can someone point me to the right documentation, please ...

Set control AfterUpdate event to procedure in another module
Hi, i know i can set a controls AfterUpdate event to a user defined procedure if it is in the same module as the code, however is it possible to set it to a procedure in a different module? i.e. By setting in the OnFormLoad() event: cbo.AfterUpdate = "=Module1.Translate()" I cant get it to work, it just says "the expression you entered has a function name that microsoft office access cannot find". The Translate procedure is public. Any thoughts much appreciated. Thanks in advance, Chris If Module1 is a standard module (not a class module, and not the module of a form...

Statistical Process Control chart
Has anyone drawn SPC Chart in Microsoft Excel? Hi, Maybe have a look here http://peltiertech.com/Excel/Charts/statscharts.html http://www.processtrends.com/pg_charts_control_chart.htm Cheers Andy Tang Leep Boon wrote: > Has anyone drawn SPC Chart in Microsoft Excel? -- Andy Pope, Microsoft MVP - Excel http://www.andypope.info ...

Where do all the pictures get stored?
Hi everyone, I wanted to know where all the pictures get stored in Outlook XP? I wanted easy access the pictures themselves instead of opening the message and then closing, opening then closing. Thank you very much! "Hashem Ouaida" <ouaidahahsem@hotmail.com> wrote in news:413cee2b$1$2161$afc38c87@news.optusnet.com.au: > Hi everyone, > > I wanted to know where all the pictures get stored in Outlook XP? I > wanted easy access the pictures themselves instead of opening the > message and then closing, opening then closing. > > Thank you very much! See y...

format/picture in email
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) just switched from pc to mac. <br><br>very frustrated when trying to embed pic in an email. <br> Outlook would allow edit/resize, text wrap or float and create a hyperlink hotspot over the image. Ent. doesn't seem to support any of that formatting fuctionality... <br><br>help anyone? > This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --B_3346677058_8293240 Content-type: text/plain; charset="U...

Dragging to select multiple rows causes out of control scroll
When I select a number of rows by click and drag method, the rows scroll by too fast to control. Is there a way to slow down this scrolling? "ronlee67" <ronlee67@discussions.microsoft.com> wrote in message news:D2940A38-DDA3-4E4B-B41A-FCEFAA3ADACA@microsoft.com... > When I select a number of rows by click and drag method, the rows scroll > by > too fast to control. Is there a way to slow down this scrolling? Hi Roplee67, You can change the scroll speed of your mouse: Start | Control Panel | Mouse | Wheel | Scrolling Depending on your OS version, access to ...

Displaying stored jpgs as pictures in a report
hello, MS ACCESS 2003 on XP PRO I've never stored jpgs in a table before, but now I apparently need to. I figured out (i think) how to store a jpg in a table using OLE OBJECT data type. But when I try to make a report of that ttable, the picture displays as a box with the file name displayed as text. How can I get the image to display on the report? Thank you, -- BlueWolverine MSE - Mech. Eng. Go BLUE! Try using an UNbound object frame and inserting the jpg in it. -- Milton Purdy ACCESS State of Arkansas "BlueWolverine" wrote: > hel...

Regional Options from control panel not displayed in Format Cells
Please can somone help me. I have searched on this topic but Alas I can not find an answer. So here is my question. When you set your number formats under control panel -> Regional options they are the ones EXCEL should use for formatting. My example is I want Parenthesis around my negative numbers ( ) . I do not want a - sign infront of number or it to be RED. So I have set my negative number symbol to () under the regional options. But if you start Excel and put in a negative number then goto Format cells -> numbers the option STILL show only a - or RED. I.E. it does not give...

How to avoid the Beep when Enter key is pressed in CEdit control
This is a not-multiline CEdit control. I don't want that when I press Enter key, control to beep. I tried by using OnKeyDown event without calling the default handler, but it didn't work. Thanks Jaime "Jaime Stuardo" <jstuardo@softhome.net> wrote in message news:eJCIlEDcDHA.1580@tk2msftngp13.phx.gbl... > This is a not-multiline CEdit control. I don't want that when I press Enter > key, control to beep. I tried by using OnKeyDown event without calling the > default handler, but it didn't work. Try a WM_CHAR handler either instead or in addition... ...

Moving from 2 domain controllers to 1 with exchange 2003 in the m
Help!! I would like to demote one domain controller of two leaving me with only one domain controller. The problem is i have Exchange 2003 in the domain which is not necessarily a problem. I am concerned that by demoting the backup domain server that there will be a problem with connectivity with exchange. Does anyone have any suggestions or solutions? Please let me know. Note: the primary domain controller does the Global cataloging and config so this should be not problem right? Hi Rox, AD doesn't really have PDC and BDC like earlier versions of windows. You can certainly dem...

how to control the gray line on the border?
I copied and pasted data from web and the gray lines disappears at the cells I pasted on. The gray lines like the borders but can't be controlled by applying the styles in "Borders". How can I make them reappear? Also, how can I apply borders setting on multiple cells. If I highlight multiple cells and apply a bottom line, all it does is apply it at teh last row instead of all the rows highlighted. Thanks for the help, liu On Aug 15, 1:48=A0pm, cpliu <spamfree...@yahoo.com> wrote: > I copied and pasted data from web and the gray lines disappears at the > cells I p...

powerpoint 2007 hungs up while inserting pictures on windows 7 x86
hello, i have office 2007 professional installed on a fresh installed windows 7 professional x86. i have sp2 for office 2007 and all windows updates installed. but when i try to insert a picture in powerpoint it hungs up everytime. any ideas? regards, sebastian Do you have a local default printer driver. (Yep I know that sounds crazy but it matters) See http://www.pptfaq.com/FAQ00850.htm "Sebi" <Sebi@discussions.microsoft.com> wrote in message news:9E9F4DBA-4541-4E35-B3C0-6598162B026D@microsoft.com... > hello, i have office 2007 professional inst...

ActiveX control question...
Hi, I'm working on an ActiveX control project (created with the MFC ControlWizard) and I'm encountering a difference I can't understand. I use VB 6.0 to test out my control and I noticed that if I view the control class itself (derived from COleControl) I can view any of the object's properties through the VB 6.0 debugger. However if I create an additional automation object in my control (derived from CCmdTarget) I cannot see any properties through the VB 6.0 debugger, however the object behaves correctly and Intellisense sees them fine when not debugging. When viewing the o...