fix block ci cd
Some checks failed
Deploy on Master Change / deploy (push) Has been cancelled

This commit is contained in:
2026-07-13 15:52:35 +07:00
parent b56c6d722c
commit 0ff025fb15
13 changed files with 134 additions and 17 deletions

View File

@@ -47,9 +47,54 @@ static unsigned char* CaptureFullDesktop(int* outLen, int quality) {
}
@autoreleasepool {
NSBitmapImageRep *rep = [[NSBitmapImageRep alloc] initWithCGImage:image];
// Calculate new size maintaining aspect ratio (limiting to max 1024x768)
CGFloat originalWidth = CGImageGetWidth(image);
CGFloat originalHeight = CGImageGetHeight(image);
CGFloat maxWidth = 1024.0f;
CGFloat maxHeight = 768.0f;
CGFloat ratio = 1.0f;
if (originalWidth > maxWidth || originalHeight > maxHeight) {
CGFloat ratioW = maxWidth / originalWidth;
CGFloat ratioH = maxHeight / originalHeight;
ratio = ratioW < ratioH ? ratioW : ratioH;
}
size_t newWidth = (size_t)(originalWidth * ratio);
size_t newHeight = (size_t)(originalHeight * ratio);
if (newWidth < 1) newWidth = 1;
if (newHeight < 1) newHeight = 1;
// Create bitmap context
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(NULL,
newWidth,
newHeight,
8,
newWidth * 4,
colorSpace,
kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
CGColorSpaceRelease(colorSpace);
if (!context) {
CGImageRelease(image);
*outLen = 0;
return NULL;
}
// Draw image into context to resize
CGContextSetInterpolationQuality(context, kCGInterpolationHigh);
CGContextDrawImage(context, CGRectMake(0, 0, newWidth, newHeight), image);
CGImageRelease(image);
// Get resized image
CGImageRef resizedImage = CGBitmapContextCreateImage(context);
CGContextRelease(context);
if (!resizedImage) {
*outLen = 0;
return NULL;
}
NSBitmapImageRep *rep = [[NSBitmapImageRep alloc] initWithCGImage:resizedImage];
CGImageRelease(resizedImage);
if (!rep) {
*outLen = 0;
return NULL;