|
sashoalm wrote: g->DrawImage(img, 0, 0);
This will draw the image from 0,0 to actual image size. May be you want to use some other version of DrawImage() where you can specify destination rectangle. I hope it makes sense.
Regards,
Sandip.
|
|
|
|
|
I'm trying to avoid any rescaling done with GDI+ because it might affect image quality.
Anyway I've come to a partial solution. This code
SIZE paper_size = { GetDeviceCaps(hPrinterDC, HORZRES), GetDeviceCaps(hPrinterDC, VERTRES) };
SIZE image_size = { img->GetWidth(), img->GetHeight() };
SetMapMode(hPrinterDC, MM_ANISOTROPIC);
SetWindowExtEx(hPrinterDC, image_size.cx, image_size.cy, NULL);
SetViewportExtEx(hPrinterDC, paper_size.cx, paper_size.cy, NULL);
SetWindowOrgEx(hPrinterDC, 0, 0, NULL);
seems to make it fit the page, but it doesn't preserve aspect ration. I did it with some sample code and trial and error.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
modified on Tuesday, August 5, 2008 5:34 AM
|
|
|
|
|
If
sashoalm wrote: SIZE paper_size = { GetDeviceCaps(hPrinterDC, HORZRES), GetDeviceCaps(hPrinterDC, VERTRES) };
Is less than
sashoalm wrote: SIZE image_size = { img->GetWidth(), img->GetHeight() };
You are going to rescale your image anyway. So what you trying to achieve may be i am not following your problem properly.
Regards,
Sandip.
|
|
|
|
|
SandipG wrote: You are going to rescale your image anyway. So what you trying to achieve may be i am not following your problem properly.
Yes, i was saying that it's an alternative solution to what you suggested. this code is there to make the rescaling instead of calling GDI+ functions. but it doesn't preserve aspect ratio, so there's more to be done here...
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
sashoalm wrote: but it doesn't preserve aspect ratio, so there's more to be done here...
For all these issues i think you should try GDI+ rescaling and check the quality. If you still dont want to use GDI+ resampling then there are some good articles on CP regarding it. Here is one by great CPallini http://www.codeproject.com/KB/GDI/plain_c_resampling_dll.aspx[^]
Regards,
Sandip.
|
|
|
|
|
Hello Friends.
I want to made an exe file in c++/MFC that reads from an autorun.inf file. Now if the format of autorun.inf is ASCII, then it can't be read correctly by our exe. if its format is unicode, then it displays the correct information.
Now generally the format of autorun.inf/autorun.ini is ASCII. My problem is that i want to convert the format of "autorun.inf" from ASCII to Unicode manually. i search for this on different forums but i can't get any help.
Can any body help me. I shall be very thankful to all of You.
Thanx in Advance.
|
|
|
|
|
|
Since you say you want to do it manually, you could just open it in notepad and then SaveAs (choosing Unicode).
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
Thanks a lot dear friend for your reply.
But i want to ask you one question i.s. what is notepad, and where can i find it?
|
|
|
|
|
From the Start menu (Windows), choose Run, then type in "notepad" (without the quotes) and press return.
You can also find an enhanced version by using google to search for Notepad++.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
Hi all,
I am working on TFTP server application.
When A client is requested for a file, My OnReceive() function is called.
In the OnReceive(),I am unable to get the data requested. I used the function like
CListenSocket::OnReceive(int nErrorCode)
{
char buff[100];
memset(buff,0,sizeof(buff));
CAsyncSocket::OnReceive(nErrorCode);
if (nErrorCode)
{
Message.Format("OnReceive nErrorCode: %i", nErrorCode);
AfxMessageBox(Message);
return;
}
int Size = ReceiveFrom(buff, 100,IPAddress,Port);
}
Here I am able to get the IPAddress and Port correctly.
But Unable to get data in the buff variable.But Size value is not zero.
So what could be the problem?
Please help me.
Regards,
Sunil Kumar
|
|
|
|
|
Make sure that the value returned by the function "ReceiveFrom" is a positive number less than 100.
Remember that the buffer ( buff[100]) you used to receive the data is sitting in the stack and will go out of scope when the function returns.
|
|
|
|
|
Yeah I have checked the value itis returned. it is less than 100 only and Im checking the
buffer just after the Receivefrom function.i.e it is not out of the scope.
Regards,
Sunil Kumar
|
|
|
|
|
CListenSocket::OnReceive(int nErrorCode)
{
char buff[100];
memset(buff,0,sizeof(buff));
if (nErrorCode)
{
Message.Format("OnReceive nErrorCode: %i", nErrorCode);
AfxMessageBox(Message);
return;
}
int Size = ReceiveFrom(buff, 100,IPAddress,Port);
CAsyncSocket::OnReceive(nErrorCode);
}
Just try this way.
-@SuDhIrKuMaR@-
|
|
|
|
|
Thanks for the reply,
but still there is no data in buff.
I think atleast it must have the filename I am requesting from tftp client.!
Regards,
Sunil Kumar
|
|
|
|
|
Why you are using ReciveFrom not Revice?
-@SuDhIrKuMaR@-
|
|
|
|
|
I need to know the host address and port.
Even i tried receive() but no use.
Regards,
Sunil Kumar
|
|
|
|
|
First, there's no need to call CAsyncSocket::OnReceive().
It does nothing.
If Size is > 0, then you received a datagram. If the data you expect
isn't in the datagram, you need to look at the sender to see why.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I am getting the compiler error :
"error C2440: '=' : cannot convert from 'LPWSTR' to 'LPCSTR'"
and error line is
cmi.lpVerb = MAKEINTRESOURCE (uiCommand);
And my Code is :
CMINVOKECOMMANDINFO cmi;
ZeroMemory(&cmi, sizeof(CMINVOKECOMMANDINFO));
cmi.cbSize = sizeof(CMINVOKECOMMANDINFO);
cmi.fMask = CMIC_MASK_FLAG_NO_UI;
cmi.hwnd = m_hWnd;
cmi.lpParameters = NULL;
cmi.lpDirectory = NULL;
cmi.lpVerb = MAKEINTRESOURCE (uiCommand);
cmi.nShow = SW_SHOWNORMAL;
cmi.dwHotKey = NULL;
cmi.hIcon = NULL;
hr = pCtxMenu->InvokeCommand(&cmi);
How to do it?
|
|
|
|
|
In the Project Settings, Select Configuration Properties->General->Character Set. Set this value to "Use Multi-Byte Character Set".
|
|
|
|
|
You don't have to change your compiler settings.
Just use MAKEINTRESOURCEA instead of MAKEINTRESOURCE.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi friends,
I am using VFW to display the video stream in my application.
I want to connect two or more than two cameras and same no of
display windows. I want to select a camera to display in particular window.
So is there any way to find the camera name so that i choose from a list.
So help me in this issue.
Reagards
Shiva
|
|
|
|
|
|
I am somewhat familiar with a try-catch block and that it automatically destructs objects on exception. However, I'm curious if it automatically frees dynamically allocated memory from the "new" operator?
void failfunc()
{
throw 1;
}
void main()
{
try
{
char *mystr = new char[512];
failfunc();
delete [] mystr;
}
catch (int ierr)
{
if (mystr != NULL) delete [] mystr;
}
}
|
|
|
|
|
You have allocated memory in a heap by using new.
And after that you are executing the next statement which is failing.
As i Know you should delete the memory which is created dynamically.
So in catch statement the deletion part is must.
But if
failfunc();
char *mystr = new char[512];
be allocated in the try block
Statement 1.....
delete [] mystr;
then as function failed it will not try to execute the next statment so there it will skip the creation of memory .so you need not to delete ....
|
|
|
|