|
Hi Guys, I've managed to track down the "leak". The application uses a mailslot to send some frequent statistical data to another process for display. The receiving program was receiving the data a lot slower than the sender was transmitting it, so eventually the Mailslot IPC ran out of shared memory and from there all the problems started.
|
|
|
|
|
Hi,
I want to scale and rotate a bitmap (loaded using GDI+) and save the rotated and scaled bitmap to a file using GDI+.
How can I do it?
Thanks,
|
|
|
|
|
|
Hi
Thank you very much for reply.
The Graphics::RotateTransform Method[^] only rotate the graphics object. not the bitmap.
How can I rotate the bitmap?
Or How can I get bitmap from Graphics?
Thank you very much,
|
|
|
|
|
transoft wrote: The Graphics::RotateTransform Method[^] only rotate the graphics object. not the bitmap.
I would suggest researching the classes you are working with. The Graphics Class[^] accepts a an Image object[^] in the constructor.
transoft wrote: How can I rotate the bitmap?
Or How can I get bitmap from Graphics?
See if something like this works:
Graphics g(hdc);
Image i(L"HelloWorld.bmp");
g.DrawImage(&i,0,1024);
g.TranslateTransform(100.0f, 50.0f);
g.RotateTransform(45.0f);
g.DrawImage(&image,0,0);
CLSID jpgClsid;
GetEncoderClsid(L"image/jpeg", &jpgClsid);
i.Save(pIStream1, &jpgClsid);
heh, I have not tested the above code, it was written here in the reply box. Let me know if it works.
Best Wishes,
-David Delaune
|
|
|
|
|
Hi David
I thought that "Graphics.Drawimage" only rotates and scales in the memory and would not affect bitmap.
I will test the code and let you know it works or not.
Best regards,
|
|
|
|
|
transoft wrote: I thought that "Graphics.Drawimage" only rotates and scales in the memory and would not affect bitmap.
It does scale/rotate the bitmap in memory. All GDI/GDI+ bitmap operations occur in memory. Then you draw the Graphics object in the Image object and save to disk.
Best Wishes,
-David Delaune
|
|
|
|
|
Dear David
Thank you very much for your code? I tried and had no luck. Do you know what happen?
Best regards,
|
|
|
|
|
transoft wrote: Do you know what happen?
Well, my sample probably was not quite correct as I wrote it in the reply box. I did this one inside my compiler and tested it:
Gdiplus::Image image(L"HelloWorld.bmp");
Bitmap bmp(1024,1024);
Graphics g(&bmp);
g.TranslateTransform(260.0f,80.0f);
g.RotateTransform(45.0f);
g.DrawImage(&image,0,0);
CLSID encoderClsid;
GetEncoderClsid(L"image/png", &encoderClsid);
bmp.Save(L"HelloWorld2.png",&encoderClsid);
I confirmed this sample actually works.
Best Wishes,
-David Delaune
|
|
|
|
|
Dear David,
Your code works perfect. Thank you so much for helping me. I spent so much on it.
Best regards,
|
|
|
|
|
hello,
i want to make a game trainer using mfc. please guide me and tell me is it good to write a tainer in mfc ??
sorry, but here it is.
i have a game "Fallout 3". there are several trainers available for it on internet but i want to develop my own trainer for this game. so i want to say that is there any tutorial available for writing a game trainer in mfc for any game ?
btw thanks
rahul
modified on Saturday, August 1, 2009 12:59 AM
|
|
|
|
|
Kindly read the guidelines. It's the sticky post, saying "How to get an answer to your question" and is located at the top of this forum.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
|
Hi,
I'm using Michael Chourdakis's very nice SSL package from here:
http://www.codeproject.com/KB/IP/ssl_sockets.aspx
I used the code as a base for a test app and its working very well, however, I'm having a strange issue.
On one remote test machine, when I run as a server in NON SSL mode, sending a few hundred bytes back and forwards, its lightening fast. I switch to SSL mode and its a little slower (due, I suppose to the encryption) but it's still fast.
However, on a second remote test machine at a different location the results vary. The NON SSL mode works lightening fast, however the SSL mode takes 30-40 seconds to complete. It connects and then there is a long period until the data is transferred back and forth, but once it starts its fast.
Is it possible that on this second machine the Certificate is being re-negotiated every time? If so, do you know if there is an app or an OS fix?
Thanks for your help,
Phil
|
|
|
|
|
I'd like to be able to put content into the clipboard so it could be pasted into Excel... but I also want some formatting information (font, color, ...) so the CF_TEXT is not good enough. Any idea, pointer?
Regards,
Jerry
|
|
|
|
|
hi all,
i am writing content into a notepad file using _wfopen function and saving it in unicode format by giving cc = unicode as one of the arguments..
its saving the file in unicode encoding too.. but when i tried to read the file, its not reading as unicode rather its reading as ascii..
i found this by giving an if condition like this:
wchar_t firstchar = NULL;
if (file.Read(&cFirstChar, sizeof(wchar_t)) && firstchar == (wchar_t)0xFEFF)..
its not showing the first character as 0xfeff rather its showing the first character as the letter present in the notepad file..
am i wrong in saving the file? if so, how to make the first character of the file as oxfeff..
thanks,
rakesh
|
|
|
|
|
First about Unicode.
There are two ways to store Unicode.
E.g 'a' (ASCII) could be stored in Unicode like so:
0x61 0x00 or 0x00 0x61
How do you know the difference ?
By storing a FE FF at the beginning of every Unicode string (this is called a Unicode Byte Order Mark) you know which way to read the bytes.
Example: If I store 'a' in Unicode file I can have:
FF FE 61 00
OR
FE FF 00 61
|
|
|
|
|
hi,
ya you were correct..its showing the ascii value rather FEFF as the first character of the file..
but the file encoding is in unicode.. (i have made it to write it in unicode encoding thru code..)
Thanks,
Rakesh.
|
|
|
|
|
That means you didn't save it as Unicode ....
What code are you using to write to the file ?
|
|
|
|
|
Hi there,
The GetKeyNameText function returns the name of the key pressed in the keyboard.
My question is, is there a way to tell whether the key is upper case or lower case?
Jr.
|
|
|
|
|
I think ctype.h is the class that holds the functions isupper and islower which accepts a char and returns whether it is capitalized or lowercase.
|
|
|
|
|
Can you tell me please how can call or access a global variable or a function defined in th Doc.cpp or anyaother class from inside UINT ThreadProc (LPVOID param)?
UINT ThreadProc(LPVOID param)
{
CTestDoc* pDoc = GetDocument(); // error: GetDocument() is not defined???
ASSERT_VALID(pDoc);
::WaitForSingleObject(m_Thread_Sel_Start.m_hObject , INFINITE);
::MessageBox((HWND)param, strThread_Start, strThread_Caption, MB_OK);
CSQLCommand::FindSQLCmd(pDoc,m_strSelect);// error :m_strSelect is defined in the CTestView.h but he can not find it , pDoc is already unkown
bool bKeepRunning = true;
while(bKeepRunning)
{
int nResult = ::WaitForSingleObject (m_Thread_Sel_End.m_hObject ,0);
if(nResult == WAIT_OBJECT_0)
bKeepRunning = false;
}
::PostMessage((HWND)param, WM_THREADENDED, 0, 0);
return 0;
}
Can i define the UINT ThreadProc(LPVOID param) in the CTestDoc.cpp?
And why when i declare UINT ThreadProc(LPVOID param) in the CTestView.h i get this error:
error C3867: "CTestView::ThreadProc": use "&CTestView::ThreadProc".
and when i use &CTestView::ThreadProc i get a csting problem that can not be solved through an explict cast.
|
|
|
|
|
Your problem stems mainly from the fact that the ThreadProc function is static, and therefore cannot access any instance members of your application class.
The easiest fix is the following:
When you call AfxBeginThread, pass the "this" pointer as your Param.
Then, inside the ThreadProc, cast the Param back to whatever object it was when you passed it originally, such as your app class or your document class.
That way, you now have access to all the instance members of your class by using the -> operator.
|
|
|
|
|
Hello,
i tried it the way you said, but it did not work , maybe i did something wrong, hier is the code:
void CTestView::ThreadStart(CTestDoc* pDoc, CString strSel)
{
m_Thread_Sel_Start.SetEvent ();
HWND hWnd = GetSafeHwnd();
m_strSelect = strSel;
m_pDoc = pDoc;// i need to access the CTestDoc.cpp, i passed pDoc from the CTestDoc.cpp to the CTestView.cpp
// and then assigend pDoc to m_pDoc which defined in the top of the CTestView.cpp
AfxBeginThread(ThreadProc, this/*hWnd*/, THREAD_PRIORITY_NORMAL);// Hier i passed this to the ThreadProc function
}
UINT ThreadProc
(
LPVOID param
)
{
(CTestView*)param-> // casting to CTestView did not work?
return 0;
}
|
|
|
|
|
You're almost there.
The correct cast is:
((CTestView*)param)->function();
|
|
|
|