HbmNew = CreateCompatibleBitmap(hdc, domino.bmWidth, domino.bmHeight) Create a temp bitmap for our new background Get window and memory dcs for our BitBlt'ing HBITMAP hbmOPrev, hbmPrev, hbmTemp // Handles to bitmaps HBITMAP hbmNew, hbmNPrev // Handles to bitmaps HDC hdcNewBkg, hdcOldBkg // Handles to dcs Void Dragging :: Drag (HWND hWnd, int nX, int nY) IntPtr destinationHdc = () Ġ, 0,, ,Ġ, 0, mMainPictureBox.Width, mMainPictureBox.Height, SRCCOPY)
![stretchblt copyimage stretchblt copyimage](https://content.any.run/tasks/0be1bf01-b63c-4a79-a251-da376d0e805a/download/screens/64a5be47-66d0-4256-bb49-4a3b6b9f742a/image.jpeg)
- Gets unused Bitmap and Graphics objects (these are reused)ĬAviImageInfo aviImageInfo = GetUnusedAviImageInfo()
![stretchblt copyimage stretchblt copyimage](https://content.any.run/tasks/0be1bf01-b63c-4a79-a251-da376d0e805a/download/screens/9f81ba64-c09b-438f-b4ee-2e24c0961c93/image.jpeg)
Called each time image on panel is updated.
![stretchblt copyimage stretchblt copyimage](https://www.codeproject.com/KB/cpp/Multi_Desktop/MultiDesktop.gif)
IntPtr mMainPictureBoxHdc = mMainPictureBoxGraphics.GetHdc() Graphics mMainPictureBoxGraphics = mMainPictureBox.CreateGraphics() PictureBox mMainPictureBox // - Displays the images to be copied - Two PictureBoxs placed on form at design time (one is just to watch for these mirrored images): MAviGraphics = Graphics.FromImage(mAviBitmap) Public CAviImageInfo( int width, int height ) - A small class for creating/storing Bitmap and Graphics objects, which get reused public class CAviImageInfo IntPtr hdcSrc, int nXSrc, int nYSrc, int nSrcWidth, int nSrcHeight, Int32 dwRop ) IntPtr hdcDest, int nXDest, int nYDest, int nDestWidth, int nDestHeight, NOTE: The bitmaps do vary in size (can't use BitBlt), but not by a lot. But when run in the IDE, stepping through image by image, it happens very regularly (maybe 1 in 10).Īny ideas what could be causing this or what I could be doing wrong? Or other FAST methods to copy the Bitmap including re-sizing. I have a work around that doesn't use StretchBlt, but it is much slower and really degrades performance.Īnother possibly useful bit: this flipped image is rare in normal usage (less than 1 in 100 frames). Or a way to detect it happened (so I can flip it back). It doesn't happen often, and I dont see any reason when it does.
#STRETCHBLT COPYIMAGE CODE#
Stepping through the code I can see this happen for a single image that has exactly the same information being passed to StretchBlt (other than the hdc to copy to) as the previous image and the next image (and next, next) all of which are fine.
![stretchblt copyimage stretchblt copyimage](https://image1.slideserve.com/3561428/slide25-l.jpg)
I’ve included some code (c#), hopefully all of the important parts. UPDATE: I changed things to force the source/destination to be the same size, and am using BitBlt with the same behavior. It is NOT due to the intended functionality with StretchBlt of "If the signs of source and destination height or width are different then it creates a mirror image". I’m not sure if this is a known problem with StretchBlt I haven’t yet found mention of or if I am doing something wrong. The problem is that occasionally (not often) a single image is flipped (mirrored across the X axis). The AVI file is an unimportant aspect I believe - I can just display the Bitmap on another PictureBox and see the problem. I’m having a problem using StretchBlt to copy an image from a PictureBox to a Bitmap for use in creating an AVI file.