Ich möchte Bitmaps kopieren, die in der Zwischenablage von z. B. Paint und so gespeichert werden.PowerBuilder - Kopieren von Bitmap aus der Zwischenablage
bisher Mein Code ist wie folgt:
ulong l_handle, l_datasize, l_lock
long l_file
uint i_format
blob lb_blob
n_bitmap ln_bit
l_handle = handle(parent)
OpenClipboard(l_handle)
//2 = Bitmap
//8 = Bitmapinfo
if not IsClipboardFormatAvailable(8) then
closeclipboard()
return
end if
l_handle = GetclipboardData(8)
l_lock = GlobalLock(l_handle)
if not isnull(l_lock) then
l_datasize = GlobalSize(l_lock)
if l_datasize>0 then
lb_blob = blob(space(l_datasize), EncodingAnsi!)
ReadClipboardData(lb_blob, l_lock, l_datasize)
GlobalUnlock(l_handle)
closeClipboard()
if not isnull(lb_blob) then
//l_file = fileopen("c:\temp\test.dib", StreamMode!, Write!, LockReadWrite!, Replace!)
ln_bit.of_writeblob("c:\temp\test.bmp", lb_blob)
ln_bit.of_writeblob("c:\temp\test1.bmp", BlobMid(lb_blob, 15))
ln_bit.of_writeblob("c:\temp\test2.bmp", BlobMid(lb_blob, 169))
ln_bit.of_writeblob("c:\temp\test3.bmp", BlobMid(lb_blob, 14))
ln_bit.of_writeblob("c:\temp\test4.bmp", BlobMid(lb_blob, 168))
//FileWriteEx(l_file, lb_blob)
//fileclose(l_file)
//p_1.setpicture(lb_blob)
end if
end if
GlobalUnlock(l_handle)
end if
closeClipboard()
Externe Funktionen
Function Ulong GetClipboardData (&
uint uFormat&
) Library "user32.dll"
Function boolean OpenClipboard (&
long hWndNewOwner &
) Library "user32.dll"
Function boolean CloseClipboard (&
) Library "user32.dll"
Function ulong GlobalLock(&
ulong hMem&
) Library "kernel32.dll"
Function boolean GlobalUnlock(ulong hMem) Library "kernel32.dll"
SUBROUTINE ReadClipboardData(ref blob Destination, ulong Source, ulong&
Length) Library "KERNEL32.DLL" Alias for "RtlMoveMemory"
FUNCTION ulong GlobalSize(ulong hMem) Library "kernel32.dll"
FUNCTION boolean IsClipboardFormatAvailable(ulong format) Library "user32.dll"
für GetClipboardData() verwende ich den Wert 8 (BITMAP), da 2 (Bitmap) immer Null zurückgibt, wenn Aufruf der GlobalLock-Funktion.
So gerade jetzt bekomme ich die Bitmapinfo in einem Blob, aber ich kann es nicht speichern. Es sagt immer das Bild ist beschädigt. Der Grund, warum ich all diese BlobMid-Sachen in der of_writeblob-Funktion ausprobierte, war, weil ich die Bitmap aus der Bitmapinfo extrahieren wollte (wenn das überhaupt möglich ist).
Hier "http://www.topwizprogramming.com/freecode_bitmap.html" sie erstellen ein Bitmapinfo und der Blobheader hat eine Länge von 14, also dachte ich, dass es so funktionieren könnte, aber die Datei ist immer noch beschädigt. Ich schätze, die Info enthält nur Informationen und nicht die eigentliche Bitmap.
Hat jemand das jemals gelöst, oder gibt es eine DLL, die ich einfach benutzen kann?
Edit: in der topwiz-Beispiel erstellen sie eine vollständige Bitmap mit der Kopfzeile, die Info und die tatsächliche Bitmap, so dass mein Versuch nur scheitern könnte, denke ich. Also das Hauptproblem ist, warum die Globallock-Funktion Null zurückgibt, wenn Aufruf getclipboarddata mit dem Parameter 2