Skip to content

theproadam/SuperFastBlit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 

Repository files navigation

SuperFastBlit

This demo demonstrates the ability to display an ARGB buffer to the screen within 1ms.

SetDIBitsToDevice() can blit a 1080p buffer onto the form at a speed of ~1.2ms. The source buffer must be 32 bits per pixel, otherwise the operation will take ~11ms.

Here's some simple demonstration code:

//Get DC from Form HWND
TargetDC = GetDC(TargetForm.Handle);

//Create bitmap info
BITMAPINFO BINFO = new BITMAPINFO();
BINFO.bmiHeader.biBitCount = 32; //Bits Per Pixel
BINFO.bmiHeader.biWidth = targetWidth; //Width
BINFO.bmiHeader.biHeight = targetHeight; //Height, negate if image is flipped
BINFO.bmiHeader.biPlanes = 1; //Planes, leave at 1
unsafe {
  BINFO.bmiHeader.biSize = (uint)sizeof(BITMAPINFOHEADER);
}

//Blit the argb buffer to the screen
SetDIBitsToDevice(TargetDC, 0, 0, (uint)targetWidth, (uint)targetHeight, 0, 0, 0, (uint)targetHeight, ptr, ref BINFO, 0);

//Release the DC when done
ReleaseDC(TargetForm.Handle, TargetDC)

Exmaple of near 1080p Blit