спасибо, но первый пример жуть как глючит при перерисовке. второй пример чё-то тоже...
да к чёрту sdk. вот нашёл. грузит изображение из ресурсов. не знаю как адаптировать, чтоб поедал из переменной.
- Код: Выделить всё
#COMPILE EXE
#COMPILER PBWIN 9
#DEBUG ERROR ON
#DIM ALL
#RESOURCE "Res.PBR"
#INCLUDE "win32api.inc"
TYPE GdiplusStartupInput
GdiplusVersion AS DWORD
DebugEventCallback AS DWORD
SuppressBackgroundThread AS LONG
SuppressExternalCodecs AS LONG
END TYPE
TYPE GdiplusStartupOutput
NotificationHook AS DWORD
NotificationUnhook AS DWORD
END TYPE
DECLARE FUNCTION GdiplusStartup LIB "gdiplus.dll" ALIAS "GdiplusStartup" (token???, inputbuf AS GdiplusStartupInput, outputbuf AS GdiplusStartupOutput) AS LONG
DECLARE SUB GdiplusShutdown LIB "gdiplus.dll" ALIAS "GdiplusShutdown" (BYVAL token???)
DECLARE FUNCTION GdipDeleteGraphics LIB "gdiplus.dll" ALIAS "GdipDeleteGraphics" (BYVAL hGraphics???) AS LONG
DECLARE FUNCTION GdipCreateFromHDC LIB "gdiplus.dll" ALIAS "GdipCreateFromHDC" (BYVAL hdc???, hGraphics???) AS LONG
DECLARE FUNCTION GdipLoadImageFromFile LIB "gdiplus.dll" ALIAS "GdipLoadImageFromFile" (BYVAL flname$, lpImage???) AS LONG
DECLARE FUNCTION GdipCreateBitmapFromHBITMAP LIB "gdiplus.dll" ALIAS "GdipCreateBitmapFromHBITMAP" (BYVAL hbm&,BYVAL hpal&, nBitmap&) AS LONG
DECLARE FUNCTION GdipCreateBitmapFromStream LIB "gdiplus.dll" ALIAS "GdipCreateBitmapFromStream" (BYVAL pStream???,m_pBitmap&) AS LONG
DECLARE FUNCTION CreateStreamOnHGlobal LIB "ole32.dll" ALIAS "CreateStreamOnHGlobal" (BYVAL hGlobal AS DWORD, BYVAL fDeleteOnRelease AS DWORD, pstm AS DWORD) AS LONG
DECLARE FUNCTION GdipDisposeImage LIB "gdiplus.dll" ALIAS "GdipDisposeImage" (BYVAL lpImage???) AS LONG
DECLARE FUNCTION GdipDrawImageRectI LIB "gdiplus.dll" ALIAS "GdipDrawImageRectI" (BYVAL hGraphics???, BYVAL nImage???, BYVAL x&,BYVAL y&, BYVAL nWidth&, BYVAL nHeight&) AS LONG
DECLARE FUNCTION GdipGetImageWidth LIB "gdiplus.dll" ALIAS "GdipGetImageWidth" (BYVAL lpImage???, nWidth???) AS LONG
DECLARE FUNCTION GdipGetImageHeight LIB "gdiplus.dll" ALIAS "GdipGetImageHeight" (BYVAL lpImage???, nHeight???) AS LONG
DECLARE FUNCTION GdipGetImageThumbnail LIB "gdiplus.dll" ALIAS "GdipGetImageThumbnail" (BYVAL nImage&,BYVAL thumbWidth&,BYVAL thumbHeight&, thumbnImage&, OPT BYVAL pCALLBACK&, OPT BYVAL callbackData&) AS LONG
DECLARE FUNCTION pStreamRelease (pUnk???) AS LONG
DECLARE FUNCTION LoadImageFromResource (BYVAL ResourceName$,OPT BYVAL hInst???) AS DWORD
DECLARE FUNCTION fGDIp_2hBMP (BYVAL FileSpec$,OPT BYVAL hBMP???) AS DWORD
$From_RC = "#1001"
%GDI_Stretch = 0
$FileSpec = $From_RC
FUNCTION WINMAIN ( BYVAL hInstance AS DWORD, _
BYVAL hPrevInst AS DWORD, _
BYVAL lpszCmdLine AS ASCIIZ PTR, _
BYVAL nCmdShow AS LONG ) AS LONG
DIM GDItoken AS LOCAL DWORD
DIM StartupInput AS LOCAL GDIplusStartupInput
DIM hBMP AS LOCAL DWORD
DIM BMPx AS LOCAL SINGLE
DIM BMPy AS LOCAL SINGLE
DIM hWnd AS LOCAL DWORD
DIM XX AS LOCAL SINGLE
DIM YY AS LOCAL SINGLE
StartupInput.GDIplusVersion = 1
IF GDIplusStartup(GDItoken, StartupInput, BYVAL %NULL) <> 0 THEN
MSGBOX "No GDI+"
EXIT FUNCTION
END IF
LOCAL hDlg AS DWORD
#IF %GDI_Stretch
GRAPHIC BITMAP NEW 300, 400 TO hBMP
#ENDIF
DIALOG NEW %HWND_DESKTOP, "Тест",,, 150, 150, %DS_CENTER OR %WS_CAPTION OR %WS_SYSMENU OR %WS_MINIMIZEBOX TO hDlg
CONTROL ADD GRAPHIC, hDlg, 200,"", 0, 0, 150, 150, %WS_CHILD OR %WS_VISIBLE
hBMP = fGDIp_2hBMP($FileSpec,hDlg)
GRAPHIC ATTACH hBMP, 200
GRAPHIC GET CLIENT TO BMPx, BMPy
GRAPHIC COLOR -2, -2
GRAPHIC CLEAR
GDIplusShutdown GDItoken
DIALOG SHOW MODAL hDlg
GRAPHIC ATTACH hBMP, 0
GRAPHIC BITMAP END
GRAPHIC ATTACH hWnd, 0
GRAPHIC WINDOW END
END FUNCTION
FUNCTION LoadImageFromResource (BYVAL ResourceName AS STRING, _
OPT BYVAL hInst AS DWORD ) AS DWORD
DIM hResource AS LOCAL DWORD
DIM imageSize AS LOCAL DWORD
DIM pResourceData AS LOCAL DWORD
DIM m_hBuffer AS LOCAL DWORD
DIM pBuffer AS LOCAL DWORD
DIM pStream AS LOCAL DWORD PTR
DIM m_pBitmap AS LOCAL DWORD
DIM m_pBitmap_status AS LOCAL LONG
DIM pName AS LOCAL ASCIIZ * %MAX_PATH
pName = ResourceName
hResource = FindResource(hInst, pName, BYVAL %RT_RCDATA)
IF hResource = 0 THEN EXIT FUNCTION
imageSize = SizeofResource(hInst, hResource)
IF imageSize = 0 THEN EXIT FUNCTION
pResourceData = LockResource(LoadResource(hInst, hResource))
IF pResourceData = 0 THEN EXIT FUNCTION
m_hBuffer = GlobalAlloc(%GMEM_MOVEABLE, imageSize)
IF m_hBuffer = 0 THEN EXIT FUNCTION
pBuffer = GlobalLock(m_hBuffer)
IF pBuffer = 0 THEN GOTO Exit_1
CopyMemory pBuffer, pResourceData, imageSize
IF CreateStreamOnHGlobal(m_hBuffer, %FALSE, pStream) <> 0 THEN GOTO Exit_2
m_pBitmap_status = GdipCreateBitmapFromStream(pStream, m_pBitmap)
CALL DWORD @@pStream[1] USING pStreamRelease(pStream)
IF (m_pBitmap <> 0) AND _
(m_pBitmap_status = 0) THEN
FUNCTION = m_pBitmap
END IF
Exit_2:
GlobalUnlock m_hBuffer
Exit_1:
GlobalFree m_hBuffer
END FUNCTION
FUNCTION fGDIp_2hBMP ( BYVAL FileSpec AS STRING, _
OPT BYVAL hBMP AS DWORD ) AS DWORD
DIM Bx AS LOCAL LONG
DIM By AS LOCAL LONG
DIM hDC AS LOCAL DWORD
DIM hGraphics AS LOCAL DWORD
DIM hImage AS LOCAL DWORD
DIM Ix AS LOCAL LONG
DIM Iy AS LOCAL LONG
DIM hTmp AS LOCAL DWORD
hImage = LoadImageFromResource(FileSpec)
IF hImage = 0 THEN EXIT FUNCTION
GdipGetImageWidth hImage, Ix
GdipGetImageHeight hImage, Iy
IF hBMP = 0 THEN
Bx = Ix
By = Iy
GRAPHIC BITMAP NEW Bx, By TO hBMP
GRAPHIC ATTACH hBMP, 200
GOSUB Get_DC
ELSE
GRAPHIC ATTACH hBMP, 200
GRAPHIC GET CLIENT TO Bx, By
GOSUB Get_DC
IF (Bx <> Ix) OR _
(By <> Iy) THEN
GdipGetImageThumbnail hImage, Bx, By, hTmp
SWAP hImage, hTmp
GdipDisposeImage hTmp
END IF
END IF
GdipDrawImageRectI hGraphics, hImage, 0, 0, Bx-1, By-1
GdipDeleteGraphics hGraphics
GdipDisposeImage hImage
FUNCTION = hBMP
EXIT FUNCTION
Get_DC:
GRAPHIC GET DC TO hDC
GdipCreateFromHDC hDC, hGraphics
IF hGraphics <> 0 THEN RETURN
GdipDisposeImage hImage
GRAPHIC ATTACH hBMP, 200
GRAPHIC BITMAP END
RETURN
END FUNCTION