Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15038

GDIPlus: how create a memory DC for Graphics?

$
0
0
how can i create a memory DC for Graphics?
Code:

Public Sub Class_Initialize()
    GDIsi.GdiplusVersion = 1&
    GdiplusStartup gToken, GDIsi
    'hDC = CreateCompatibleDC(GetDC(0))
    GdipCreateFromHWND GetForegroundWindow(), hGraphics
    GdipGetDC hGraphics, hDC
    If (hDC = 0) Then MsgBox "error"
    If Err Then
          Err.Clear
          Exit Sub
    ElseIf gToken = 0& Then
        Exit Sub
    End If
End Sub

when i draw the bitmap, the bitmap isn't drawed :(
Code:

Public Function FromFile(FileName As String) As Boolean
    If FileName = "" Then Exit Function
    If hGraphics Then
        Call GdipLoadImageFromFile(StrPtr(FileName), hBitmap)
        If hBitmap Then
            GdipGetImageHeight hBitmap, ImageHeight
            GdipGetImageWidth hBitmap, ImageWidth
            FromFile = True
            GdipDrawImage hGraphics, hBitmap, 0, 0
        End If
    End If
End Function

i know these, because when i get pixel a pixel, i only get the black color

Viewing all articles
Browse latest Browse all 15038

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>