|
I'd try doing this using a Memory Mapped File, which theoretically should give much better results, and far simpiler code.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Memory Mapped File, definitely the way to go, its just like a portion of memory then, you can read forward, back even jump through hoops and its still fast .
Alan.
|
|
|
|
|
There are two basic 'hints' you can specify to CreateFile to tell Windows how you intend to manipulate the file.
Specifying no hint indicates to Windows that you mostly intend to read the file forwards. This is what you have at the moment. It will perform some asynchronous read-ahead from the file, and drop the cache mappings fairly quickly after each read. When it does drop them, it adds the physical memory pages to the tail of the list of free pages, so if it needs to reload them again, it doesn't need to reload from disk unless the pages have actually been reused.
Windows actually tries to interpret your read pattern and guess where the next read might occur.
If you use the FILE_FLAG_RANDOM_ACCESS flag, read-ahead is inhibited, and the cache manager is less aggressive about unmapping recently used sections.
Finally, I'll quickly mention FILE_FLAG_SEQUENTIAL_SCAN where the cache manager assumes that you're reading the file from end to end, never going back, and so adds unmapped cache data to the head, not the tail, of the free list so it gets reused quickly.
In order to be able to pass the FILE_FLAG_RANDOM_ACCESS flag, you'll need to subclass CFile .
More complete information in Inside Windows 2000 from MS Press (Solomon & Russinovich).
|
|
|
|
|
Thanks for your hints,
I tried FILE_FLAG_RANDOM_ACCESS from CFile. There was the possibility to use that flag at the CFile constructor.
(CFile::osRandomAccess See FILE_FLAG_RANDOM_ACCESS in CreateFile in the Platform SDK)
But this was not enougth, the memory consumtion still increase.
So I use the FILE_FLAG_NO_BUFFERING flag to bypass the Cache Manager at all.
(CFile::osNoBuffer See FILE_FLAG_NO_BUFFERING in CreateFile in the Platform SDK). After I did some additional tuning on my rinbuffers this seems to be the solution. Memory usage keeps nearly constant and the transfe-rate is enough to do real time parsing on the mpeg stream.
Thanks for all your comments,
Eddie
|
|
|
|
|
I kept a CListCtrl in my application and inserting columns by picking up column captions
by parsing from a flat file . The problem is InsertColumn method is inserting a cloumn but not displaying column caption ?? Rest of the columns are fine and no pronlem with Inserting items.
How to get the first coulmn name displayed??
thanks in advance
Warm Regards,
KKRam
|
|
|
|
|
Use the LVCFMT_LEFT attribute while inserting headings, and also give the correct width required for the column to display the heading.
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
Thanks Jagadeesh,
I am done with that CListCtrl using that Attribute.,
Warm Regards,
KKR
|
|
|
|
|
I've looked thru as many articles as I could find on the subject of bitmaps and I still cannot find how to make a composite bitmap from a few individual ones. I want to do this in a memory dc then when finished adding each bitmap, bitblt the single one to the screen dc. My goal is to reduce or eliminate flickering and ,yes, I know about double buffering but everthing I read was blitting 1 single bitmap not multiple ones.
Basically, I have one large (400x550 pixels) background bitmap and about 38 smaller (30x150) bitmaps that I am layering over the background one. I have lots of flickering. So I thought that if I could combine all bitmaps into one single memory dc then blit to screen dc I would greatly reduce flicker.
Am I or dreaming??
Manufacturing Software Developer
|
|
|
|
|
You can create a new DC which is compatible with your application DC using CreateCompatibleDC( ... ). Then you can do all your layering operations in this newly created DC, and when your are finished, you can BitBlt the newly created DC to your application DC. This can certainly avoid the flickering you are talking about.
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
Yes, that was it exactly. I feel like an idiot because of how simple the solution was. Actually, just after I sent off this question I experimenting with the method that you ended up suggesting. I created a new memory DC, bitblt'd with SCRCOPY each bitmap into that same memory space. Then, finally, bitblt SCRCOPY the memory DC to the screen DC. It worked fine. There was no flickering.
I tend to exhaust all other means of possible solution paths before using common sense!
Thanks!
Manufacturing Software Developer
Hewlett-Packard Company
|
|
|
|
|
Where in VC++.NET do I change the name of the exe file? Thanks.
Matt (Padawan Learner)
|
|
|
|
|
Its in the project settings, in the Link section.. isn't it ?
Just trying to remember off the top of my tiny head.
|
|
|
|
|
Got it. Thanks.
Matt (Padawan Learner)
|
|
|
|
|
Please Tell me How to search and operate a device,such as USB device?
Use the functions such as "SetupDiClassDev() etc.," need GUID,and How can I Get GUID use windows'API functions?
I Use Windows XP OS.
Thanks.
ST!!
Njbull
Sep.12/2003,Beijing
|
|
|
|
|
I need to draw a selection box in a real time video. This box is created when i pressed the left mouse button and drag the outline of the box. However since my codes are not in MFC, i do not know of any way to draw this box.. Can anyone help??
|
|
|
|
|
I am trying to print out everything in Picturebox.
I can't print out anything except blank.
Here is my source in MyViewClass::OnPrint(CDC* pDC, CPrintInfo* pInfo ) and please help me how I am doing wrong?
CRect rect;
GetWindowRect(&rect);
//CDC* pTempDC = GetWindowDC();
CDC memDC;
//IGBMapViewCtrl d;
//d.GetDC();
memDC.CreateCompatibleDC( pDC );
// create bitmap with my window-pDC and set it in the memory-DC
CBitmap bitmap;
bitmap.CreateCompatibleBitmap( m_MapView.GetDC(), rect.Width(), rect.Height());
memDC.SelectObject(&bitmap);
// open printer dialog
// detach DCs
bitmap.Detach();
|
|
|
|
|
to print a bitmap, you need to use a device independent bitmap (DIB), not a device dependent bitmap
|
|
|
|
|
Thank you, I will test it.
Shin
|
|
|
|
|
Thank you, I will test it.
Shin
|
|
|
|
|
Hello,
I'm trying to write a Scene Editor for a 3d engine. In doing this, I have to use Direct3D which means all my surfaces and what not depend on the size of my view.
The only solution I have come up with so far is to create all my stuff, wait until the view is opened so I can get the correct size of it and in it's OnDraw method, initialize Direct3D with the size of the view. I would like to move some of the Direct3D stuff over to my Document class so that they can share this with other views but I'm not sure how to do this. The view hasn't been created by the time OnNewDocument is called so I can't get the right size.
Any ideas?
Thanks
Shawn
|
|
|
|
|
A customer emailed today asking why a combo box in our program sorted like this:
Item1
Item10
Item2
etc
Our combo box sorts alphabetically and it's a field of names which generally wouldn't have numbers in it.
In other words, they expect "Item10" to follow "Item2" which makes intuitive sense but seems to be difficult to program for.
Has anyone ever seen a combo box that sorts alphabetically and numerically, in any program? Any ideas on how to reliably do that? Is this a known problem with a known algorithm?
|
|
|
|
|
Yeah, its a pain isn't it. Happens in all sorts of places.
Try using this http://sourcefrog.net/projects/natsort/[^] and then manualy inserting the items.
You could just wrap the comparison in a std::less or pass it to qsort.
Ryan.
|
|
|
|
|
Ahh! Outstanding link, thank you very much!
Cheers!
|
|
|
|
|
The simple solution is to make sure everything is in the form item001, item010, item283, like so - then it will work.
|
|
|
|
|
Yes, of course!
Thanks for pointing that out, I should have thought of it before.
|
|
|
|