Skip to content

Commit

Permalink
24042801 update
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan-CRL committed Apr 28, 2024
1 parent 3e30479 commit 7a7e096
Show file tree
Hide file tree
Showing 33 changed files with 3,120 additions and 1,104 deletions.
12 changes: 6 additions & 6 deletions 智绘教/IdtDraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ void saveImageToPNG(IMAGE img, const char* filename, bool alpha, int compression
unsigned char alpha = (color & 0xFF000000) >> 24;
if (alpha != 0)
{
data[(y * width + x) * 4 + 0] = ((color & 0x00FF0000) >> 16) * 255 / alpha;
data[(y * width + x) * 4 + 1] = ((color & 0x0000FF00) >> 8) * 255 / alpha;
data[(y * width + x) * 4 + 2] = ((color & 0x000000FF) >> 0) * 255 / alpha;
data[(y * width + x) * 4 + 0] = unsigned char(((color & 0x00FF0000) >> 16) * 255 / alpha);
data[(y * width + x) * 4 + 1] = unsigned char(((color & 0x0000FF00) >> 8) * 255 / alpha);
data[(y * width + x) * 4 + 2] = unsigned char(((color & 0x000000FF) >> 0) * 255 / alpha);
}
else
{
Expand All @@ -173,9 +173,9 @@ void saveImageToPNG(IMAGE img, const char* filename, bool alpha, int compression
for (int x = 0; x < width; ++x)
{
DWORD color = pMem[y * width + x];
data[(y * width + x) * 4 + 0] = (color & 0x00FF0000) >> 16;
data[(y * width + x) * 4 + 1] = (color & 0x0000FF00) >> 8;
data[(y * width + x) * 4 + 2] = (color & 0x000000FF) >> 0;
data[(y * width + x) * 4 + 0] = unsigned char((color & 0x00FF0000) >> 16);
data[(y * width + x) * 4 + 1] = unsigned char((color & 0x0000FF00) >> 8);
data[(y * width + x) * 4 + 2] = unsigned char((color & 0x000000FF) >> 0);
data[(y * width + x) * 4 + 3] = 255;
}
}
Expand Down
90 changes: 46 additions & 44 deletions 智绘教/IdtDrawpad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ LRESULT CALLBACK DrawpadHookCallback(int nCode, WPARAM wParam, LPARAM lParam)
{
KBDLLHOOKSTRUCT* pKeyInfo = (KBDLLHOOKSTRUCT*)lParam;

if (wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN) KeyBoradDown[pKeyInfo->vkCode] = true;
else if (wParam == WM_KEYUP || wParam == WM_SYSKEYUP) KeyBoradDown[pKeyInfo->vkCode] = false;
if (wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN) KeyBoradDown[(BYTE)pKeyInfo->vkCode] = true;
else if (wParam == WM_KEYUP || wParam == WM_SYSKEYUP) KeyBoradDown[(BYTE)pKeyInfo->vkCode] = false;

if (!IsHotkeyDown && (KeyBoradDown[VK_CONTROL] || KeyBoradDown[VK_LCONTROL] || KeyBoradDown[VK_RCONTROL]) && (KeyBoradDown[VK_LWIN] || KeyBoradDown[VK_RWIN]) && (KeyBoradDown[VK_MENU] || KeyBoradDown[VK_LMENU] || KeyBoradDown[VK_RMENU]))
{
Expand Down Expand Up @@ -74,7 +74,7 @@ LRESULT CALLBACK DrawpadHookCallback(int nCode, WPARAM wParam, LPARAM lParam)
case VK_RIGHT: // 右箭头
case VK_DOWN: // 下箭头
{
if (KeyBoradDown[pKeyInfo->vkCode])
if (KeyBoradDown[(BYTE)pKeyInfo->vkCode])
{
PPTUIControlColor[L"RoundRect/RoundRectLeft2/fill"].v = RGBA(200, 200, 200, 255);
PPTUIControlColor[L"RoundRect/RoundRectRight2/fill"].v = RGBA(200, 200, 200, 255);
Expand All @@ -90,7 +90,7 @@ LRESULT CALLBACK DrawpadHookCallback(int nCode, WPARAM wParam, LPARAM lParam)
case VK_LEFT: // 左箭头
case VK_UP: // 上箭头
{
if (KeyBoradDown[pKeyInfo->vkCode])
if (KeyBoradDown[(BYTE)pKeyInfo->vkCode])
{
PPTUIControlColor[L"RoundRect/RoundRectLeft1/fill"].v = RGBA(200, 200, 200, 255);
PPTUIControlColor[L"RoundRect/RoundRectRight1/fill"].v = RGBA(200, 200, 200, 255);
Expand Down Expand Up @@ -355,9 +355,11 @@ void MultiFingerDrawing(LONG pid, POINT pt)
COLORREF color = brush.color;
} draw_info;

IMAGE Canvas(GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
SetImageColor(Canvas, RGBA(0, 0, 0, 0), true);
IMAGE* BackCanvas = new IMAGE;
int cxscreen = GetSystemMetrics(SM_CXSCREEN);
int cyscreen = GetSystemMetrics(SM_CYSCREEN);

IMAGE Canvas = CreateImageColor(cxscreen, cyscreen, RGBA(0, 0, 0, 0), true);
IMAGE* BackCanvas = new IMAGE(cxscreen, cyscreen);

std::chrono::high_resolution_clock::time_point start;
if (draw_info.rubber_choose == true)
Expand Down Expand Up @@ -561,7 +563,7 @@ void MultiFingerDrawing(LONG pid, POINT pt)
}

// 延迟拉直
if (!StopTimingDisable && !points.empty())
if (draw_info.mode == 1 && !StopTimingDisable && !points.empty())
{
if (sqrt((pt.x - StopTimingPoint.x) * (pt.x - StopTimingPoint.x) + (pt.y - StopTimingPoint.y) * (pt.y - StopTimingPoint.y)) > 5)
{
Expand Down Expand Up @@ -655,7 +657,9 @@ void MultiFingerDrawing(LONG pid, POINT pt)

start = std::chrono::high_resolution_clock::now();
std::unique_lock<std::shared_mutex> lock3(StrokeImageSm[pid]);
*BackCanvas = Canvas;

ImgCpy(BackCanvas, &Canvas);

StrokeImage[pid] = make_pair(BackCanvas, draw_info.mode == 2 ? (/*draw_info.color >> 24*/130) * 10 + 0 : 2550);
lock3.unlock();

Expand Down Expand Up @@ -891,13 +895,16 @@ void MultiFingerDrawing(LONG pid, POINT pt)
lock3.unlock();

std::unique_lock<std::shared_mutex> lock4(StrokeImageSm[pid]);
*BackCanvas = Canvas;

ImgCpy(BackCanvas, &Canvas);

if (draw_info.rubber_choose == true) StrokeImage[pid] = make_pair(BackCanvas, 2553);
else if (draw_info.brush_choose == true)
{
if (draw_info.mode == 2) StrokeImage[pid] = make_pair(BackCanvas, (/*draw_info.color >> 24*/130) * 10 + 1);
else StrokeImage[pid] = make_pair(BackCanvas, 2551);
}

lock4.unlock();
}
void DrawpadDrawing()
Expand All @@ -921,7 +928,7 @@ void DrawpadDrawing()
ulwi.pptDst = &ptDst;
ulwi.psize = &sizeWnd;
ulwi.pptSrc = &ptSrc;
ulwi.crKey = RGB(255, 255, 255);
ulwi.crKey = 0;
ulwi.pblend = &blend;
ulwi.dwFlags = ULW_ALPHA;

Expand Down Expand Up @@ -949,7 +956,7 @@ void DrawpadDrawing()

chrono::high_resolution_clock::time_point reckon;
clock_t tRecord = 0;
for (int bug_fix_i = 1;; bug_fix_i = 2)
for (;;)
{
for (int for_i = 1;; for_i = 2)
{
Expand Down Expand Up @@ -981,7 +988,7 @@ void DrawpadDrawing()
std::unique_lock<std::shared_mutex> LockExtremePointSm(ExtremePointSm);

RecallImage.push_back({ drawpad, extreme_point, 0, make_pair(recall_image_recond, recall_image_reference) });
RecallImagePeak = max(RecallImage.size(), RecallImagePeak);
RecallImagePeak = max((int)RecallImage.size(), RecallImagePeak);

LockExtremePointSm.unlock();
LockStrokeBackImageSm.unlock();
Expand All @@ -1002,7 +1009,7 @@ void DrawpadDrawing()
std::unique_lock<std::shared_mutex> LockExtremePointSm(ExtremePointSm);

RecallImage.push_back({ drawpad, extreme_point, 0, make_pair(recall_image_recond, recall_image_reference) });
RecallImagePeak = max(RecallImage.size(), RecallImagePeak);
RecallImagePeak = max((int)RecallImage.size(), RecallImagePeak);

if (RecallImage.size() > 10)
{
Expand Down Expand Up @@ -1036,7 +1043,7 @@ void DrawpadDrawing()

extreme_point.clear();
RecallImage.push_back({ empty_drawpad, extreme_point, 2, make_pair(0,0) });
RecallImagePeak = max(RecallImage.size(), RecallImagePeak);
RecallImagePeak = max((int)RecallImage.size(), RecallImagePeak);

if (RecallImage.size() > 10)
{
Expand Down Expand Up @@ -1137,7 +1144,7 @@ void DrawpadDrawing()
std::unique_lock<std::shared_mutex> LockExtremePointSm(ExtremePointSm);

RecallImage.push_back({ drawpad, extreme_point, 0, make_pair(recall_image_recond, recall_image_reference) });
RecallImagePeak = max(RecallImage.size(), RecallImagePeak);
RecallImagePeak = max((int)RecallImage.size(), RecallImagePeak);

LockExtremePointSm.unlock();
LockStrokeBackImageSm.unlock();
Expand All @@ -1158,7 +1165,7 @@ void DrawpadDrawing()
std::unique_lock<std::shared_mutex> LockExtremePointSm(ExtremePointSm);

RecallImage.push_back({ drawpad, extreme_point, 0, make_pair(recall_image_recond, recall_image_reference) });
RecallImagePeak = max(RecallImage.size(), RecallImagePeak);
RecallImagePeak = max((int)RecallImage.size(), RecallImagePeak);

if (RecallImage.size() > 10)
{
Expand Down Expand Up @@ -1192,7 +1199,7 @@ void DrawpadDrawing()

extreme_point.clear();
RecallImage.push_back({ empty_drawpad, extreme_point, 0, make_pair(0,0) });
RecallImagePeak = max(RecallImage.size(), RecallImagePeak);
RecallImagePeak = max((int)RecallImage.size(), RecallImagePeak);

if (RecallImage.size() > 10)
{
Expand Down Expand Up @@ -1280,7 +1287,7 @@ void DrawpadDrawing()
std::unique_lock<std::shared_mutex> LockExtremePointSm(ExtremePointSm);

RecallImage.push_back({ drawpad, extreme_point, 0, make_pair(recall_image_recond, recall_image_reference) });
RecallImagePeak = max(RecallImage.size(), RecallImagePeak);
RecallImagePeak = max((int)RecallImage.size(), RecallImagePeak);

LockExtremePointSm.unlock();
LockStrokeBackImageSm.unlock();
Expand All @@ -1301,7 +1308,7 @@ void DrawpadDrawing()
std::unique_lock<std::shared_mutex> LockExtremePointSm(ExtremePointSm);

RecallImage.push_back({ drawpad, extreme_point, 0, make_pair(recall_image_recond, recall_image_reference) });
RecallImagePeak = max(RecallImage.size(), RecallImagePeak);
RecallImagePeak = max((int)RecallImage.size(), RecallImagePeak);

if (RecallImage.size() > 10)
{
Expand Down Expand Up @@ -1335,7 +1342,7 @@ void DrawpadDrawing()

extreme_point.clear();
RecallImage.push_back({ empty_drawpad, extreme_point, 0, make_pair(0,0) });
RecallImagePeak = max(RecallImage.size(), RecallImagePeak);
RecallImagePeak = max((int)RecallImage.size(), RecallImagePeak);

if (RecallImage.size() > 10)
{
Expand Down Expand Up @@ -1455,7 +1462,7 @@ void DrawpadDrawing()
std::unique_lock<std::shared_mutex> LockExtremePointSm(ExtremePointSm);

RecallImage.push_back({ drawpad, extreme_point, 0, make_pair(recall_image_recond,recall_image_reference) });
RecallImagePeak = max(RecallImage.size(), RecallImagePeak);
RecallImagePeak = max((int)RecallImage.size(), RecallImagePeak);

if (RecallImage.size() > 10)
{
Expand Down Expand Up @@ -1525,7 +1532,7 @@ void DrawpadDrawing()
std::unique_lock<std::shared_mutex> LockExtremePointSm(ExtremePointSm);

RecallImage.push_back({ drawpad, extreme_point, 0, make_pair(recall_image_recond,recall_image_reference) });
RecallImagePeak = max(RecallImage.size(), RecallImagePeak);
RecallImagePeak = max((int)RecallImage.size(), RecallImagePeak);
if (RecallImage.size() > 10)
{
while (RecallImage.size() > 10)
Expand Down Expand Up @@ -1564,34 +1571,29 @@ void DrawpadDrawing()
}
}

if (bug_fix_i == 1)
ulwi.hdcSrc = GetImageHDC(&window_background);
if (!UpdateLayeredWindowIndirect(drawpad_window, &ulwi))
{
DWORD* pMem = GetImageBuffer(&window_background);
if ((pMem[0] & 0xFF000000) >> 24 == 0)
{
MessageBox(floating_window, L"智绘教画板显示出现问题,点击确定以重启智绘教\n此方案可能解决该问题", L"智绘教警告", MB_OK);
MessageBox(floating_window, L"智绘教画板显示出现问题,点击确定以重启智绘教\n此方案可能解决该问题", L"智绘教警告", MB_OK);

{
sswindows.clear();
EnumWindows(EnumWindowsProc, 0);

ofstream writejson;
writejson.imbue(locale("zh_CN.UTF8"));
writejson.open(wstring_to_string(string_to_wstring(global_path) + L"bug fix 240408.01.log").c_str());
{
sswindows.clear();
EnumWindows(EnumWindowsProc, 0);

for (int i = 0; i < (int)sswindows.size(); i++)
{
writejson << to_string(i) << " " + wstring_to_string(sswindows[i]) << endl;
}
ofstream writejson;
writejson.imbue(locale("zh_CN.UTF8"));
writejson.open(wstring_to_string(string_to_wstring(global_path) + L"bug fix 240408.01.log").c_str());

writejson.close();
for (int i = 0; i < (int)sswindows.size(); i++)
{
writejson << to_string(i) << " " + wstring_to_string(sswindows[i]) << endl;
}

off_signal = 2;
writejson.close();
}

off_signal = 2;
}
ulwi.hdcSrc = GetImageHDC(&window_background);
UpdateLayeredWindowIndirect(drawpad_window, &ulwi);

tRecord = clock();
}
Expand Down Expand Up @@ -1692,7 +1694,7 @@ int drawpad_main()
shared_lock<std::shared_mutex> LockStrokeBackImageSm(StrokeBackImageSm);
shared_lock<std::shared_mutex> LockExtremePointSm(ExtremePointSm);
RecallImage.push_back({ drawpad, extreme_point, 0 });
RecallImagePeak = max(RecallImage.size(), RecallImagePeak);
RecallImagePeak = max((int)RecallImage.size(), RecallImagePeak);
LockExtremePointSm.unlock();
LockStrokeBackImageSm.unlock();
}
Expand Down
2 changes: 1 addition & 1 deletion 智绘教/IdtFloating.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4626,7 +4626,7 @@ void DrawScreen()
{
ChangeColor(floating_icon[7], UIControlColor[L"Image/test/fill"].v);
hiex::TransparentImage(&background, int(UIControl[L"Image/test/x"].v), int(UIControl[L"Image/test/y"].v), &floating_icon[7], int((UIControlColor[L"Image/test/fill"].v >> 24) & 0xff));
if (AutomaticUpdateStep == 3) hiex::EasyX_Gdiplus_SolidEllipse(UIControl[L"Image/test/x"].v + 30, UIControl[L"Image/test/y"].v, 10, 10, RGBA(228, 55, 66, 255), false, SmoothingModeHighQuality, &background);
if (AutomaticUpdateStep == 9) hiex::EasyX_Gdiplus_SolidEllipse(UIControl[L"Image/test/x"].v + 30, UIControl[L"Image/test/y"].v, 10, 10, RGBA(228, 55, 66, 255), false, SmoothingModeHighQuality, &background);

Gdiplus::Font gp_font(&HarmonyOS_fontFamily, UIControl[L"Words/test/height"].v, FontStyleRegular, UnitPixel);
SolidBrush WordBrush(hiex::ConvertToGdiplusColor(UIControlColor[L"Words/test/words_color"].v, true));
Expand Down
24 changes: 24 additions & 0 deletions 智绘教/IdtImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
int recall_image_recond, recall_image_reference;
shared_mutex RecallImageManipulatedSm;
chrono::high_resolution_clock::time_point RecallImageManipulated;

tm RecallImageTm;
int RecallImagePeak = 0;
deque<RecallStruct> RecallImage;//撤回栈
Expand Down Expand Up @@ -57,4 +58,27 @@ Bitmap* IMAGEToBitmap(IMAGE* easyXImage)
bitmap->UnlockBits(&bitmapData);

return bitmap;
}
bool ImgCpy(IMAGE* tag, IMAGE* src)
{
if (tag == NULL || src == NULL) return false;
if (tag->getwidth() != src->getwidth() || tag->getheight() != src->getheight())
{
tag->Resize(src->getwidth(), src->getheight());
}

int width = src->getwidth();
int height = src->getheight();
DWORD* pSrc = GetImageBuffer(src);
DWORD* pTag = GetImageBuffer(tag);

for (int y = 0; y < height; ++y)
{
for (int x = 0; x < width; ++x)
{
pTag[y * width + x] = pSrc[y * width + x];
}
}

return true;
}
3 changes: 2 additions & 1 deletion 智绘教/IdtImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ extern int RecallImagePeak;
extern IMAGE background;
extern Graphics graphics;

Bitmap* IMAGEToBitmap(IMAGE* easyXImage);
Bitmap* IMAGEToBitmap(IMAGE* easyXImage);
bool ImgCpy(IMAGE* tag, IMAGE* src);
Loading

0 comments on commit 7a7e096

Please sign in to comment.