Hi
I'm trying to put together some code to easily draw a FreeBasic ImageBuffer that the internal gfx library uses, in a WinFBE project. I have working code that shows a ImageBuffer drawn on a Window, but I'm hoping someone has some good tips to avoid flickering when the window gets resized.
Here is the code that draws the FB Imagebuffer, it gets called when the Window gets a WM_PAINT message:
Sub FBImageBox.Draw()
PrintMSG "FBImageBox.Draw()"
If Buffer = 0 then exit sub
If TempBuffer = 0 Then TempBuffer = ImageCreate(MaxW, MaxH, 0, 32)
Put TempBuffer, (0, 0), Buffer, Pset
Dim As BITMAPV4HEADER bmi
With BMI
.bV4Size = Len(BITMAPV4HEADER)
.bv4width = TempBuffer->Pitch / 4
.bv4height = -(TempBuffer->Height)
.bv4planes = 1
.bv4bitcount = 32
.bv4v4compression = 0
.bv4sizeimage = ((TempBuffer->Pitch / 4) * TempBuffer->Height) * 4
.bV4RedMask = &h0f00
.bV4GreenMask = &h00f0
.bV4BlueMask = &h000f
.bV4AlphaMask = &hf000
End With
Var hdc = GetDC(Parent.hWindow)
StretchDIBits(hDC, x, y, Buffer->Width, Buffer->Height, 0, 0, Buffer->Width, Buffer->Height, CPtr(Any Ptr, TempBuffer) + SizeOf(FB.Image), CPtr( BITMAPINFO Ptr, @BMI), DIB_RGB_COLORS, SRCCOPY )
DeleteDC(hdc)
end sub
Most of the code I think I found on the FB forum years ago, I have also attached a test WinFBE project if anyone is interested.
PS: Is there an option in WinFB to save the code the way it is displayed?