• ### Announcements

#### Archived

This topic is now archived and is closed to further replies.

# "Torn" images with BitBlt

## Recommended Posts

Orpheum    122
Here''s a noggin scratcher... I''ve had this annoying as hell bug for awhile now and its time to squash it! When I execute the program, it should blt the test tile to the screen so that I can see that my new implementation of the bitmap class works. The screwy thing is that sometimes, the tile doesnt show up and you have to move that portion of the window off screen and back again to see it. Doing this will usually only show part of the tile and it appears to be torn. Once in a great while the image will appear normally after execution, but this is definetly the exception. There are a lot of temporary implementations in my engine, just for functionality''s sake... like the bitmap is being loaded in the rendering function so I can test the loading and blting all in one place (fewer chances of something getting f***ed along the way). This is the only thing I can think of that might be causing the tearing of the images (or them not appearing at all). Could the rendering function taking too long (it is called from WM_PAINT) cause the image screwiness? I haven''t had time to build the framework for my caching algorithm so I cant test that yet.

##### Share on other sites
a_insomniac    660
well for one it would help if you were a little more specific, such as are you using Direct X, or something else?

If Direct X...during the routine did you unlock the suface while drawing to it? or did you screw up the color palettes? is it 256 color, 16 bit ???

Also, with code optimization, what is taking place while this is happening? if direct x ...are you using secondary sufaces to help with rendering?.......

a_insomniac

If my compiler was voice activated with the voice of my mother-in-law....there would be no errors!

##### Share on other sites
Orpheum    122
Sorry for not being specific enough... I tried to type that out before a meeting... I am using the regular old Win32 GDI. In my render function (remember just a test) I open the file, load it into memory, convert the DIB to a DDB, and then Blt.

Oh yea, this happens with both 8 and 24 bit bmps.

Edited by - Orpheum on October 3, 2000 7:31:27 PM

##### Share on other sites
Sly    128
Are you invalidating the entire area of the control?

InvalidateRect(hWnd, NULL, false);

Steve 'Sly' Williams
Tools Developer
Krome Studios

##### Share on other sites
Orpheum    122
Not explicitly, I thought that whenever WM_PAINT was called that it automatically did that for you. I have a few test bed projects that do not do this... I have no idea what could be causing it.

I was thinking the render function taking too long would do it...

Edited by - Orpheum on October 4, 2000 11:27:36 PM

I just wanted to point out that calling InvalidateRect does not work. Somebody has to have some ideas... I've noticed that if I move the window as little as possible ~1 pixel, the test tile will appear, but if I move it about ~1 more pixel, it will vanish again! Wtf is going on??

Edited by - Orpheum on October 5, 2000 3:48:30 PM

##### Share on other sites
Orpheum    122
Keeping the dream alive!

##### Share on other sites
Orpheum    122
I've been playing around with InvalidateRect (its the only thing I have to go on) today and have a big problem with it! SOMETIMES when I close the window, the rest of the screen gets all f***ed up. The start bar will be blank until you cause each part of it to be redrawn (pressing ctrl-esc will bring the start button back, clicking where a window is minimized will bring its box on the task bar back, mousing over the quicklaunch icons will bring them back). The best way to fix the screen problem is to hit ctrl+alt+del to bring up task manager, then esc to have the whole screen redrawn. The further I get into my engine, the more I hate Win32! Has anyone had similar experiences that may be able to help me?

Where would you recomend PLACING the call to InvalidateRect??

I'm using W2k BTW.

Edited by - Orpheum on October 5, 2000 4:38:45 PM

##### Share on other sites
Facehat    696
That doesn''t sound right. Are you sure that the InvalidateRect call is being done on a valid window? I''d check to make sure that you aren''t calling it after you''ve closed the window.

----------------------------------------
"Before criticizing someone, walk a mile in their shoes.
Then, when you do criticize them, you will be a mile away and have their shoes." -- Deep Thoughts

##### Share on other sites
Orpheum    122
Well like I said... I was wondering where a good place to put that call would be. I''ve tried at the beginning of WM_PAINT and my render function (which is called during WM_PAINT), and I''ve tried the end of WM_PAINT and my render function. The behavior is the same everywhere.

##### Share on other sites
Orpheum    122
Hey this problem still exists!! What is wrong with this post???? Not enough info/too vague?? Tell me what you need... I''m so stuck (this is a FUNKY problem) that I totally need help on this one.

##### Share on other sites
mr_jrt    134
Well I've looked though my win32 books and I'm afraid I can't help you that much. I was thinking though, I had a similar problem to yours (I'm using directx though, where I was loading bitmaps using gdi).

  HBITMAP hBitmap = (HBITMAP)LoadImage(NULL, FileName , IMAGE_BITMAP, 0, 0,LR_LOADFROMFILE | LR_CREATEDIBSECTION); //not sure on some of the flagsHDC BitmapDC = CreateCompatibleDC (NULL); SelectObject(BitmapDC, hBitmap); HDC WindowDC = GetDC (HWND hWindow);BitBlt(WindowDC, x, y, width, height, BitmapDC, 0, 0, SRCCOPY);ReleaseDC(WindowDC);

NOTE:
I haven't tested this in any way/shape/form, it's based upon some code I wrote to load bitmaps to a directdraw surface, so no guarantees.

I felt bad 'coz hardly anyone seemed to have helped you on this, and I hope this helps.

- Jamie

 fixed up dodgy source formatting
Waassaap!!

Edited by - mr_jrt on October 6, 2000 4:05:33 PM

##### Share on other sites
Orpheum    122
Well I finally fixed this bitch - but the fix is unacceptable. This post is so damn unpopular that I will start a new thread for the discussion of another work around... Thanks to all those who contributed to this tho!!

##### Share on other sites
voodoo    122
You must use invalidaterect, to make the window repaint.

Put invalidate rect in your message loop.

So many ways of doing it....

While
{
if(Peekmessage)
{
}
invalidterect
}