|
I think maybe I haven't explained my problem properly here...
The method you described is what I've always used before this project. But this time, instead of using GDI objects in memory, I've used GDI+ objects (which has made my offscreen drawing code a lot simpler and prettier, which was worth it). So, in my code m_pbmpMemory is a GDI+ bitmap and m_gr is a GDI+ Graphics object.
My problem is that DrawImage() is slow to the screen (the offscreen stuff isn't too bad really). I can't find a way to BitBlt from my GDI+ bitmap to the screen other than the code I posted and I was wondering if anyone else could see something I'm missing.
Hang on, I have an idea. I guess the other option would be to use GDI objects and then create the GDI+ Graphics object from that using Graphics::FromHDC() and store that to use for drawing to the offscreen bitmap. It looks like you can do it that way round, but not the other way (ie. create the Graphics object first, then get the HDC - you can only use one at a time so you need to release the HDC every time you draw to the Bitmap).
I'll go an investigate and see if that works...
|
|
|
|
|
|
Thanks for all the suggestions folks.
After some quick experiments, the solution appears to be something that I should have tried earlier but for some reason it didn't occur to me.
It looks like the best way to do double buffering quickly and efficiently in GDI+ is actually to do the double buffering part in GDI, but when you create the memory DC, also create a GDI+ Graphics object from it and store that as a member of the View/Dialog class. This way, you can draw to the offscreen GDI CBitmap object using either the DC or the Graphics object (whichever takes your fancy / suits your needs).
For the record, in this application, the difference between doing a BitBlt() and a DrawImage() in the OnPaint() command is a speed increase by a factor of between 6 and 8 times!
|
|
|
|
|
I need to do something similar. Do you mind posting the code your using?
|
|
|
|
|
Not at all...
In OnPaint()
<br />
CPaintDC dc(this);<br />
if(!m_pMemDC)<br />
{<br />
vUpdateBitmap(&dc);<br />
}<br />
CRect rcClientRect;<br />
GetClientRect(&rcClientRect);<br />
ULONG32 ulViewWidth = ulGetViewWidth();<br />
{<br />
vUpdateBitmap(&dc);<br />
}<br />
CRect rcPaint;<br />
dc.GetClipBox(rcPaint);<br />
dc.BitBlt(rcPaint.left, rcPaint.top, rcPaint.Width(), rcPaint.Height(),<br />
m_pMemDC, rcPaint.left, rcPaint.top, SRCCOPY);<br />
The vUpdateBitmap function:
<br />
<br />
if(pDC)<br />
{<br />
if(m_pMemDC)<br />
{<br />
delete m_pMemDC;<br />
}<br />
m_pMemDC = new CDC;<br />
m_pMemDC->CreateCompatibleDC(pDC);;<br />
<br />
CBitmap *m_pNewBitmap;<br />
m_pNewBitmap = new CBitmap;<br />
m_pNewBitmap->CreateCompatibleBitmap(pDC, rcClient.Width(), rcClient.Height());<br />
m_pNewBitmap->SetBitmapDimension(rcClient.Width(), rcClient.Height());<br />
m_pMemDC->SelectObject(m_pNewBitmap);<br />
delete m_pbmpMemBitmap;<br />
m_pbmpMemBitmap = m_pNewBitmap;<br />
if(m_gr)<br />
{ delete m_gr; }<br />
m_gr = Graphics::FromHDC(m_pMemDC->m_hDC);<br />
}<br />
Then you can use the m_gr Graphics object to do your GDI+ drawing to the offscreen bitmap and the actual screen draw is done by the much faster BitBlt.
Hope that helps
|
|
|
|
|
Hi everybody,
can anyone help me ?
i'm developing a MFC Dialog based app on multi OS, which can simulate 'Windows Desktop' upto limited functionalities,
using Shell API, IContexMenu etc. With the help of CListCtrl (with Icon view) and CImageList, a Windows Desktop
has been prepared
For Context menu & PIDL, it works all fine on WIn XP,
however, on Win2k & Win98 whenever right-clicking onto non-iconic area (Desktop PIDL), my program raise error.
While debugging (& through logging), came to know that my code failed to find Desktop PIDL.
It failed at IShellFolder::GetUIObjectOf() in getting IContextMenu.
hr = m_pshObject->GetUIObjectOf (NULL, 1, (LPCITEMIDLIST *) m_pIDList, IID_IContextMenu, NULL, (void**) &InvokCmd);
Let me just elaborate through step-wise:
1). All these operation i'm performing onto 'my simulated Windows desktop'
2). To bring about the solution, hardcoding for the
Win98 desktop path C:\Windows\Desktop and for
Win2k C:\Documents and Settings\administrator\Desktop for conveting it into Desktop PIDL
Although after that, it could sucessfully displayed context-menu for desktop.
3). But when attempting to Copy-Paste operation, that is, copy any file/folder by Right-click on it,
and choose 'Paste' operation by right-click on desktop (my simulated Windows desktop),
my program performs bizarre behavior.
4). It made a new file/folder, and lable it 'Desktop' and for file-copying it shows with Windows default icon
5). One more thing, while tracing Log, analyzing for desktop PIDL i observed;
m_pIDList[0]- AppName: Desktop, AppFullPath: C:\Documents and Settings\Admin\Desktop\Desktop
in path, it shows desktop twice ...
i can't figure out how it behaves as such, while it performing nice on XP
Thanks a lot for help !
ab4rum
|
|
|
|
|
So...you supply the PIDL of the desktop folder and ask the desktop folder for the appropriate IContextMenu ?
The documentation describes the PIDL argument like this:
Address of an array of pointers to ITEMIDLIST structures, each of which uniquely identifies a file object or subfolder relative to the parent folder. Each item identifier list must contain exactly one SHITEMID structure followed by a terminating zero. Is the desktop folder a sub-folder of itself? No. I suspect that the fact it works on XP is coincidence - that or some extra checks they put in for errnous uses of the API like yours. The Windows 98/2000 behaviour kind of almost makes sense as well - the root namespace object is called 'Desktop'. You're copying something with the path 'Desktop\something' to the Desktop, so it creates a folder called Desktop as part of the paste process.
|
|
|
|
|
Sorry, i am not well at English.
My problem is that i don't know how to set sound output in left or right side of headphone.
I use portaudio class in my project to control sound output.
There is some parameters which i don't understand such as numOutputChannel.
I set it as 1 because 0 is no output.
When i set it as 2 and i set data (for output) at even point as 0, sound output in left side but sound output is different from i set numOutputChannel as 1.
Please tell me how to solve this problem.
If i set it as 2 that it is right way to control sound output in left side only, why sound output is differrent? and how to solve them?
|
|
|
|
|
nekokan wrote: When i set it as 2 and i set data (for output) at even point as 0, sound output in left side but sound output is different from i set numOutputChannel as 1.
Could you please rephrase?
- ns ami -
|
|
|
|
|
Can anyone tell me how to rename a vc++ project with its solution file.
I need step by step procedure.
Thanks in advance
|
|
|
|
|
What is it that you didn't understand in solutions provided yesterday.
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
|
i tried this but its not working.
I followed following steps:
1)I installed vsrename.
2)I copied my project to that particular folder
3)then i cleaned sol file through clean all.
4)Then i used following command on command prompt:
C:\Documents and Settings\vsrename>vsrename oldfile newfile
Visual Studio Project Renamer v0.5 - Use with care!
Make backups before you use this program.
Do a 'Make Clean' on your original project before use.
Do a 'Rebuild All' on your renamed project.
By Niek Albers (nieka@daansystems.com)
Here we go:
/oldfile/: unmatched () in regexp at c:\vsrename\vsrename.pl li
ne 21.
This is coming.
And solution file is not renamed at all.
If you have another option please tell me
Thanks.....
|
|
|
|
|
why dont you try the GUI that is provided?? there is a link that is available in that site.
|
|
|
|
|
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi Friends,
My product has a feature of logging. Currently it is simple MACRO
based where during release build compiler removes logging function
calls. Now I am planning to make logging available during release
build as well. As a result user will simply pass some command line
parameter during process start and things will start logging.
Now as logging code will be present in my binary during release time,
this will enforce some types of checks even if the logging is not
enabled which will lead to CPU cost.
Is there any way to optimize these checks?
Are there any way where I can bypass these checks during normal
functional behavior.
Assembly, C, C++ compiler/code specific suggestions are welcome.
- Vikram S
|
|
|
|
|
If you write some generic logging function the type checking overhead is minimized. I use a global logging file, so there isnt a lot of stuff to do. Be careful if you do logging and multithreading!!
Greetings from Germany
|
|
|
|
|
vikrams wrote: Now as logging code will be present in my binary during release time,
this will enforce some types of checks even if the logging is not
enabled which will lead to CPU cost.
You mean you cant even check like this too?
if( bLogEnabled )
{
// code for logging...
}
- ns ami -
|
|
|
|
|
I can do this. But When there are hundreds of checks at runtime, will this be not an issue?
- Vikram S
|
|
|
|
|
AFAIK, this 'if' check will not bring any noticable change in the performance. I know even more complex logging mechanisms are used in professional softwares. Also you can avoid logs (if that much necessary) in some extremely performance oriented functions.
Note: You may simplyfy the code (only look) using by using macros, so that repeated if blocks can be avoided.
Eg.
#define LOG(x) if( bLogEnabled ) { LogString( x ); }
- ns ami -
|
|
|
|
|
i m developing msn protocol 15 in c++.but i faced a problem in contact management (in accept and accept & add scenario).
plz any one help.
|
|
|
|
|
Well, you have to fix the problem.
Okay, that's probably the most usefull answer we can give you seing how detailed your question was.
|
|
|
|
|
actually my problem is that when some one adding, than actual msn received a request and there is three option one is decline another one is accept with right click button and accept without right click button so on all the three process whats the actual msn doing on the server side i want that source code.
|
|
|
|
|
I really think you need to ask the Microsoft Guys for that.
|
|
|
|
|
Hi
I have the raw image and want to read it to do convolution. The image has 5 bytes header making all my code goes wrong. Could anyone suggest a way to read it.
The resolution for the image is 190 X 243, 8 bits and 5 bytes of header. Because I use
fopen and fread to open,read the file and I do not how to use pointer to modify the starting point of reading.
This is the image http://edventure.ntu.edu.sg/bbcswebdav/users/z050016/leaf.raw [^]
Thank you very much.
|
|
|
|