From e2271e31d95cc30a019d32fbad33003c4de9fd00 Mon Sep 17 00:00:00 2001 From: zhouchengrong Date: Mon, 10 Feb 2025 17:12:02 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=88=E6=96=B0=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=89:=20fix=EF=BC=88=E4=BF=AE=E5=A4=8Dbug=EF=BC=89:=20=20p?= =?UTF-8?q?rint=5Fpainting.py=20=E5=9D=90=E6=A0=87=E7=AE=97=E6=B3=95?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=20docs=EF=BC=88=E6=96=87=E6=A1=A3=E5=8F=98?= =?UTF-8?q?=E6=9B=B4=EF=BC=89:=20refactor=EF=BC=88=E9=87=8D=E6=9E=84?= =?UTF-8?q?=EF=BC=89:=20test(=E5=A2=9E=E5=8A=A0=E6=B5=8B=E8=AF=95):?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 代码回溯 --- app/service/design_fast/pipeline/print_painting.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/service/design_fast/pipeline/print_painting.py b/app/service/design_fast/pipeline/print_painting.py index 980981c..2f97474 100644 --- a/app/service/design_fast/pipeline/print_painting.py +++ b/app/service/design_fast/pipeline/print_painting.py @@ -407,12 +407,14 @@ class PrintPainting: # y_offset = random.randint(0, image.shape[1] - image_size_w) # 1.拿到偏移量后和resize后的print宽高取余 得到真正偏移量 - x_offset = print_w - int(location[0][1] % print_w) - y_offset = print_w - int(location[0][0] % print_h) + # 偏移量增加2分之print.w 使坐标位于图中间 如果要位于左上角删除+ print_w // 2 即可 + x_offset = print_w - int(location[0][1] % print_w) + print_w // 2 + y_offset = print_h - int(location[0][0] % print_h) + print_h // 2 # y_offset = int(location[0][0]) # x_offset = int(location[0][1]) + if len(image.shape) == 2: image = image[x_offset: x_offset + image_size_h, y_offset: y_offset + image_size_w] elif len(image.shape) == 3: