• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 710
  • Last Modified:

Bitblt and vertikal sync

I have written a program that displays very large bitmaps (>100Mbyte). I'm using standaard software like StretchDIBits.
The problem is the following: When i pan through the image, the display of the image gets cracked. The reason is that the function is still drawing the bits in the window, when the monitor already updates the displayed image, and there what i'm seeing is half of the new image and half of the old image.
In 3D graphics we use double buffering for this problem. My questions are:
- Is there something like double buffering in MFC?
- How do i know when there is vertical retrace?
0
wytze
Asked:
wytze
  • 12
  • 4
  • 3
  • +5
1 Solution
 
MichaelSCommented:
I think you can do StretchDIBits to Memory DC and than BitBlt to the screen from already stretched bitmap. At least BitBlt would work much faster than StretchDIBits
0
 
wytzeAuthor Commented:
Tried that one. Didn't help.
I need StretchDIBit because i want to zoom in. Bitblt is using StretchDIBits when the rectangles are not similar.
Redrawing the screen (1024 * 768) takes so much time, that it cannot be done in a retrace. Therfore i would like double buffering.
0
 
nietodCommented:
I suspect that DirectX will provide the ability to perform double buffering.   If you need high performance graphics, you should be looking into it.  (Even if it dousn't provide double buffering.)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
wytzeAuthor Commented:
Tried that one. Didn't help.
I need StretchDIBit because i want to zoom in. Bitblt is using StretchDIBits when the rectangles are not similar.
Redrawing the screen (1024 * 768) takes so much time, that it cannot be done in a retrace. Therfore i would like double buffering.
0
 
wytzeAuthor Commented:
i'm pretty sure DirectX and also OpenGL provide double buffering, but i'm stuck to the mfc solution.
There is commercial program ACDSEE which displays the large images and you can pan through them without the cracks, so it must be possible but how?
0
 
nietodCommented:
>> but i'm stuck to the mfc solution.
mfc doesn't prevent you from using directX.
0
 
wytzeAuthor Commented:
i'm pretty sure DirectX and also OpenGL provide double buffering, but i'm stuck to the mfc solution.
There is commercial program ACDSEE which displays the large images and you can pan through them without the cracks, so it must be possible but how?
0
 
MichaelSCommented:
>I need StretchDIBit because i want to zoom in

As I proposed you creating memory bitmap, first you do Stretching in it and than BitBlt from it to the screen.
0
 
nietodCommented:
I think that i what he said he tried, but if not, definitely do try that.  It will definitely be faster.  And make sure the memory bitmap i not only the right size, but also the right color format.  i.e. make sure it matches the screen's color format, that will make it faster again.
0
 
wytzeAuthor Commented:
i'm pretty sure DirectX and also OpenGL provide double buffering, but i'm stuck to the mfc solution.
There is commercial program ACDSEE which displays the large images and you can pan through them without the cracks, so it must be possible but how?
0
 
wytzeAuthor Commented:
nientod your correct i tried that, also made the frame byte aligned etc. but still not fast enough :-(
0
 
wytzeAuthor Commented:
nientod your correct i tried that, also made the frame byte aligned etc. but still not fast enough :-(
0
 
ambienceCommented:
With GDI i think the only kind of buffering that you can do is by using Memory Device contexts.

DirectDraw has support for multiple buffers ,direct draw automaticaly handles the case as it only updates surfaces during vertical retraces , also starting from version 4 it has methods that let you wait for or query about the vertical blank status.

correct me if i am wrong...
0
 
rgoerdesCommented:
use directx!!
you can use normal gdi-functions drawing a normal Compatible-DC. then you transfer this to a backbuffer by BitBlt, or whatever function you like. then you flip the backbuffer. flipping DirectX regognizes the vertical sync and suppresses the effects disturbing the appearance.
0
 
wytzeAuthor Commented:
nientod your correct i tried that, also made the frame byte aligned etc. but still not fast enough :-(
0
 
wytzeAuthor Commented:
nientod your correct i tried that, also made the frame byte aligned etc. but still not fast enough :-(
0
 
wytzeAuthor Commented:
!@#$ Why is he putting my last comment back when i check if there is a new comment.
0
 
nietodCommented:
IAre you selecting "refresh" to get back to the question.  If so it will repeat the same "transmission" that obtained the previous one, which includes transmitting a submission to the site.

to get to the question, use the links sent in the e-mail or go to the C++ topic are and select the question from the list.  do't refresh.
0
 
AlexVirochovskyCommented:
It is very interesting. Before 1 month, I wrote class
for display large bitmap. My idea:
Every time I get only part of file (from x, y) coordinates
and display it with StretchBlt/BitBlt(depends from Zoom).
If must be Zoom, I read from file more pixels and use
StretchBlt. Is your idea same? In such case it can't be
fast: every time read from file + redisplay.
0
 
wytzeAuthor Commented:
To AlexVirochovsky
No I don't read it from file. I read it in memory. Therefore the size of the image is maximised by the amount of free memory. I tried this with image's from about 100 Mbytes and get about 30 Hz updaterate, less if i use more crack resistant software (see MichaelS) this increases memory transfers. I get higher update rates when I zoom in (at least it looks like it (i didn't time it)). When you read it from disk it's to slow.

To get crack free images i think i have to go for directx. does rgoerdes have an example of what he is proposing?
(i have no experience in directx)
0
 
AlexVirochovskyCommented:
>>Therefore the size of the image is maximised by the
amount of free memory.
And what make in case, that size of Bitmap > size of Memory?
0
 
wytzeAuthor Commented:
The file will not load, so increase your memory or load the file in pieces like you do.
0
 
AlexVirochovskyCommented:
>>Is there something like double buffering in MFC?
You can easy make double buffering( as I make with help OWL)
Make some bitmap(by size of screen) + dc,
display StretchBlt to this bitmap, and after this
use BitBlt from this dc to screen.
0
 
griesshCommented:
I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. Unless there is objection or further activity,  I will suggest to refund the points and PAQ at zero points since nobody had a solution for you.

The link to the Community Support area is: http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner

0
 
ComTechCommented:
This question will be placed in PAQ.

Regards,
ComTech
CS @ EE
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 12
  • 4
  • 3
  • +5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now