Solved

Bitblt and vertikal sync

Posted on 2001-06-27
25
676 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
  • 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
 

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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now