Эксперт
Покинул форум
Сообщений всего: 4461
Дата рег-ции: Нояб. 2017
Репутация: 585
|
Вместо StretchBlt использовать DrawImage gdi+.
code (Отобразить)CODE:#define SRCCOPY 13369376
#define WS_EX_TRANSPARENT 32
#define WS_EX_LAYERED 524288
#define GWL_EXSTYLE -20
#define GWL_STYLE -16
#define LWA_COLORKEY 1
#define COLOR_3DFACE 15
#define FALSE 0
#define UnitPixel 2
external(INT, "GdiplusStartup", "GdiplusStartup", "Gdiplus.dll");
external(INT, "GdiplusShutdown", "GdiplusShutdown", "Gdiplus.dll");
external(INT, "GdipDisposeImage", "GdipDisposeImage", "Gdiplus.dll");
external(INT, "GdipCreateFromHWND", "GdipCreateFromHWND", "Gdiplus.dll");
external(INT, "GdipDeleteGraphics", "GdipDeleteGraphics", "Gdiplus.dll");
external(INT, "GdipCreateBitmapFromHBITMAP", "GdipCreateBitmapFromHBITMAP", "Gdiplus.dll");
external(INT, "GdipDrawImageRectRectI", "GdipDrawImageRectRectI", "Gdiplus.dll");
external(INT, "GetDC", "GetDC", "User32.dll");
external(INT, "ReleaseDC", "ReleaseDC", "User32.dll");
external(INT, "DeleteDC", "DeleteDC", "Gdi32.dll");
external(INT, "SelectObject", "SelectObject", "Gdi32.dll");
external(INT, "DeleteObject", "DeleteObject", "Gdi32.dll");
external(INT, "CreateCompatibleDC", "CreateCompatibleDC", "Gdi32.dll");
external(INT, "CreateCompatibleBitmap", "CreateCompatibleBitmap", "Gdi32.dll");
external(INT, "BitBlt", "BitBlt", "Gdi32.dll");
external(INT, "SetLayeredWindowAttributes", "SetLayeredWindowAttributes", "User32.dll" );
external(INT, "SetWindowLong", "SetWindowLongA", "User32.dll" );
external(INT, "GetSysColor", "GetSysColor", "User32.dll");
external(INT, "MoveWindow", "MoveWindow", "User32.dll");
win w=window ("Program Manager", "Progman", -1); // окно, с которого выводить изображение
if(w==0)
{
messagebox("Окно не найдено");
}
else
{
int gdiplusToken;
char gdiplusStartupInput[16];
initialarray(#gdiplusStartupInput[0], 0);
writeaddress(1, address(#gdiplusStartupInput[0]));
GdiplusStartup(address(#gdiplusToken), address(#gdiplusStartupInput[0]), 0);
createdialog(0);
showdialog(0, "Dialog", 0, 0, 0, 0, 1, 1);
int coord[4]={0, 0, 1000, 700}; // координаты
int percent = 50; // процент вывода
visualwindow(0, coord[0], coord[1], coord[2], coord[3], 650, 400, percent, w);
looptime(5000)
{
// 0-3 рамка захвата, 4-5 позиция вывода, 6 процент вывода, окно
visualwindow2(coord[0], coord[1], coord[2], coord[3], 50, 400, percent, w);
sleep(1);
}
GdiplusShutdown(gdiplusToken);
}
function getmessage(0, WM_CREATE)
{
SetWindowLong(gethwnd(0), GWL_EXSTYLE, WS_EX_LAYERED | WS_EX_TRANSPARENT);
SetWindowLong(gethwnd(0), GWL_STYLE, 0);
SetLayeredWindowAttributes(gethwnd(0), GetSysColor(COLOR_3DFACE), 0, LWA_COLORKEY);
}
function visualwindow2(int sx, int sy, int ex, int ey, int posX, int posY, int percent, win window_)
{
int width = ex-sx;
int height = ey-sy;
// получить скрин окна
int hScreen = GetDC(formatwi(window_));
int hDc = CreateCompatibleDC(hScreen);
int hBitmap = CreateCompatibleBitmap(hScreen, width, height);
int old_obj = SelectObject(hDc, hBitmap);
BitBlt(hDc, 0, 0, width, height, hScreen, sx, sy, SRCCOPY);
// изменить размер диалога
int w = width*percent/100;
int h = height*percent/100;
MoveWindow(gethwnd(0), posX, posY, w, h, FALSE);
// вывод на диалог
int bitmap;
int lnGraphics;
GdipCreateFromHWND(gethwnd(0), address(#lnGraphics));
GdipCreateBitmapFromHBITMAP(hBitmap, 0, address(#bitmap));
GdipDrawImageRectRectI(lnGraphics, bitmap, 0, 0, w, h, 0, 0, width, height, UnitPixel, 0, 0, 0);
GdipDisposeImage(bitmap);
// удаление ресурсов
SelectObject(hDc, old_obj);
DeleteObject(hBitmap);
DeleteDC(hDc);
ReleaseDC(formatwi(window_), hScreen);
GdipDeleteGraphics(lnGraphics);
} |