Solved

Bitblt and vertikal sync

Posted on 2001-06-27
25
693 Views
Last Modified: 2008-03-10
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
Comment
Question by:wytze
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 12
  • 4
  • 3
  • +5
25 Comments
 
LVL 6

Expert Comment

by:MichaelS
ID: 6230412
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
 

Author Comment

by:wytze
ID: 6230643
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
 
LVL 22

Expert Comment

by:nietod
ID: 6230721
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
Independent Software Vendors: 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!

 

Author Comment

by:wytze
ID: 6230767
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
 

Author Comment

by:wytze
ID: 6230784
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
 
LVL 22

Expert Comment

by:nietod
ID: 6230803
>> but i'm stuck to the mfc solution.
mfc doesn't prevent you from using directX.
0
 

Author Comment

by:wytze
ID: 6230854
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
 
LVL 6

Expert Comment

by:MichaelS
ID: 6230864
>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
 
LVL 22

Expert Comment

by:nietod
ID: 6230877
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
 

Author Comment

by:wytze
ID: 6230886
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
 

Author Comment

by:wytze
ID: 6230892
nientod your correct i tried that, also made the frame byte aligned etc. but still not fast enough :-(
0
 

Author Comment

by:wytze
ID: 6230920
nientod your correct i tried that, also made the frame byte aligned etc. but still not fast enough :-(
0
 
LVL 22

Expert Comment

by:ambience
ID: 6231040
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
 
LVL 1

Expert Comment

by:rgoerdes
ID: 6231324
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
 

Author Comment

by:wytze
ID: 6231419
nientod your correct i tried that, also made the frame byte aligned etc. but still not fast enough :-(
0
 

Author Comment

by:wytze
ID: 6231582
nientod your correct i tried that, also made the frame byte aligned etc. but still not fast enough :-(
0
 

Author Comment

by:wytze
ID: 6231590
!@#$ Why is he putting my last comment back when i check if there is a new comment.
0
 
LVL 22

Expert Comment

by:nietod
ID: 6231669
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
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 6233951
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
 

Author Comment

by:wytze
ID: 6234461
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
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 6235371
>>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
 

Author Comment

by:wytze
ID: 6237754
The file will not load, so increase your memory or load the file in pieces like you do.
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 6238715
>>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
 
LVL 11

Expert Comment

by:griessh
ID: 6820071
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
 

Accepted Solution

by:
ComTech earned 0 total points
ID: 6837761
This question will be placed in PAQ.

Regards,
ComTech
CS @ EE
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question