1. why does this code only work some times

All I'm trying to do in this program is to load 2 bitmaps and then copy both of them to another bitmap and display the new bitmap. To get rid of fliker in a game im making. this code only works every 6 to 7 time or less that i run it.

I tryed "bitBlt" pictures one at a time to "Bitmap2" then displaying "Bitmap2" but when you do that the pictures are not realy loaded onto "Bitmap2" until you display "Bitmap2" which makes it fliker.

so if i make a bitmap of what i wont the screen to look like then load it to "Bitmap2" that should do away with the flikering.

The below code is in "(Intro)"

atom ,new_p,tman,h,testing 
 
 
-- The below code is in "(General)" 
 
testing = loadBitmapFromFile( "c:\\testing.bmp" ) 
tman = loadBitmapFromFile( "c:\\mant1.bmp" ) 
 
 
-- The below code is in "w32HClick" 
 
bitBlt( Bitmap2, 0, 0, testing, 0, 0, 50, 50, SRCCOPY ) 
h = copyToTrueColorBitmapFile(tman, "c:\\test\\testing_n.bmp", 0, 0, 50, 43 ) 
new_p = loadBitmapFromFile( "c:\\test\\testing_n.bmp" )	 
bitBlt( Bitmap2, 50, 50, new_p, 0, 0, 50, 50, SRCCOPY ) 

why does this code not work

[added eucode tags. -matt]

new topic     » topic index » view message » categorize

2. Re: why does this code only work some times

jpbg33 said...

All I'm trying to do in this program is to load 2 bitmaps and then copy both of them to another bitmap and display the new bitmap. To get rid of fliker in a game im making. this code only works every 6 to 7 time or less that i run it.

I tryed "bitBlt" pictures one at a time to "Bitmap2" then displaying "Bitmap2" but when you do that the pictures are not realy loaded onto "Bitmap2" until you display "Bitmap2" which makes it fliker.

so if i make a bitmap of what i wont the screen to look like then load it to "Bitmap2" that should do away with the flikering.

Do you have an on paint event handler? That should be blitting the image whenever windows wants you to paint.

It's not obvious to me what's causing the flicker. Common causes of flicker are from doing a lot of painting work in an on paint handler. Generally, you should do your drawing to a pixmap sitting in memory, and then simply blit that over during an on paint event as requested by windows.

Matt

new topic     » goto parent     » topic index » view message » categorize

3. Re: why does this code only work some times

I haven't tryed that I'm new to this windos vertion I was useing the dos vertion and made a few game with it so now im trying to make one the windows vwertion.

thanks for the help

new topic     » goto parent     » topic index » view message » categorize

4. Re: why does this code only work some times

jpbg33 said...

All I'm trying to do in this program is to load 2 bitmaps and then copy both of them to another bitmap and display the new bitmap. To get rid of fliker in a game im making.

The Bitmap control type is best suited for static images; ones that are not animated.

For animated images, it better to use a combination of a Window control and a Pixmap control. The Window is used to actually display the current image and the Pixmap is used to build or create the image details. Then whenever either the image is changed or the Window needs repainting, the Window's paint event would simply bitblt the Pixmap contents to the Window.

When you are finished updating the image in the Pixmap, you signal to the Window that it needs to be refreshed. The flicker effect is caused when the default Windows repaint function is used. This happens because the Window is first wiped clean by setting all pixels to the background colour, then the foreground pixels are set. To avoid this, use the repaintFG() call rather than the repaintWindow() call.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu