*/}}

3 Commits 9a648da22b ... a4fe29e01d

Autor SHA1 Mensagem Data
  YimingWu a4fe29e01d release fix for segmented data set há 3 semanas atrás
  YimingWu f666c22b6d Windows compatibility há 3 semanas atrás
  YimingWu 47bc7472b0 readme update há 3 semanas atrás
3 ficheiros alterados com 21 adições e 6 exclusões
  1. 1 0
      CMakeLists.txt
  2. 2 2
      README.md
  3. 18 4
      ouroperations.c

+ 1 - 0
CMakeLists.txt

@@ -17,6 +17,7 @@ find_package(lagui REQUIRED)
 find_package(PNG REQUIRED)
 find_package(LCMS2 REQUIRED)
 
+add_compile_options("$<$<C_COMPILER_ID:MSVC>:/std:c11>")
 add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
 add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
 

+ 2 - 2
README.md

@@ -2,7 +2,7 @@
 
 好得涂是一款绘画软件。
 
-版权所有 (C) 2022-2023 吴奕茗
+版权所有 (C) 2022-2024 吴奕茗
 
 了解更多: https://ChengduLittleA.com/ourpaint
 
@@ -35,7 +35,7 @@ default_brushes.udf 的作者是 吴奕茗。
 
 Our Paint is a painting application.
 
-Copyright (C) 2022-2023 Wu Yiming
+Copyright (C) 2022-2024 Wu Yiming
 
 Learn more about LaGUI: https://ChengduLittleA.com/lagui
 

+ 18 - 4
ouroperations.c

@@ -19,8 +19,10 @@
 #include "ourpaint.h"
 #include "png.h"
 #include "lcms2.h"
-#include <unistd.h>
 #include <threads.h>
+#ifdef __linux__
+#include <unistd.h>
+#endif
 
 OurPaint *Our;
 extern LA MAIN;
@@ -2532,6 +2534,16 @@ int ourthread_ImportPNG(OurThreadImportPNGDataMain* main){
         our_LayerImportPNG(data->l, 0, data->data, 0, 0, 1, Our->TempLoadX, data->starty,1);
     }
 }
+static int our_ProcessorCount() {
+#ifdef __linux__
+    return sysconf(_SC_NPROCESSORS_ONLN);
+#endif
+#ifdef _WIN32
+    SYSTEM_INFO sysinfo; GetSystemInfo(&sysinfo);
+    return sysinfo.dwNumberOfProcessors;
+#endif
+    return 1;
+}
 void ourset_LayerImage(OurLayer* l, void* pdata, uint32_t size){
     if(!pdata) return; char* data=pdata;
     if(l->ReadSegmented.Count>0){
@@ -2539,7 +2551,7 @@ void ourset_LayerImage(OurLayer* l, void* pdata, uint32_t size){
 
         logPrint("\n    Reading segmented layer for size %dx%d...",seg->Width,seg->Height);
 
-        int threads = sysconf(_SC_NPROCESSORS_ONLN); TNS_CLAMP(threads,1,32);
+        int threads = our_ProcessorCount(); TNS_CLAMP(threads,1,32);
         int taskcount=l->ReadSegmented.Count;
         if(threads>taskcount){threads=taskcount;}
         thrd_t* th=calloc(threads,sizeof(thrd_t));
@@ -2616,7 +2628,7 @@ void ourget_LayerImageSegmented(OurLayer* l, int* r_chunks, uint32_t* r_sizes, v
 void* ourget_LayerImageSegmentedInfo(OurLayer* l, int* r_size, int* r_is_copy){
     if(!Our->SegmentedWrite){ *r_is_copy=0; *r_size=0; return 0; }
 
-    int threads = sysconf(_SC_NPROCESSORS_ONLN); TNS_CLAMP(threads,1,32);
+    int threads = our_ProcessorCount(); TNS_CLAMP(threads, 1, 32);
     int X,Y,W,H; our_GetFinalDimension(0,0,0,&X,&Y,&W,&H); l->ReadSegmented.Width=W; l->ReadSegmented.Height=H;
     int useh=H/threads; l->ReadSegmented.Count=threads; 
     for(int i=0;i<threads-1;i++){ l->ReadSegmented.H[i]=useh; } l->ReadSegmented.H[threads-1]=H-useh*(threads-1);
@@ -2624,7 +2636,9 @@ void* ourget_LayerImageSegmentedInfo(OurLayer* l, int* r_size, int* r_is_copy){
     *r_is_copy=0; *r_size=sizeof(OurLayerImageSegmented); return &l->ReadSegmented;
 }
 void ourset_LayerImageSegmentedInfo(OurLayer* l, void* data, int size){
-    memcpy(&l->ReadSegmented,data,sizeof(OurLayerImageSegmented));
+    if (data && size) {
+        memcpy(&l->ReadSegmented, data, sizeof(OurLayerImageSegmented));
+    }
 }
 
 void ourset_LayerMove(OurLayer* l, int move){