From 3d5749ca71e6ccb7e930b25c598595fb4c9b969f Mon Sep 17 00:00:00 2001 From: darkress <30271678+DarkressX@users.noreply.github.com> Date: Sun, 11 Jun 2023 03:55:27 +0200 Subject: [PATCH] fixed slicing for images with the condition totalPixels/threadCount != Integer --- de/darkress/pixelfood/Main.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/de/darkress/pixelfood/Main.java b/de/darkress/pixelfood/Main.java index 682d229..f5388bc 100644 --- a/de/darkress/pixelfood/Main.java +++ b/de/darkress/pixelfood/Main.java @@ -91,9 +91,11 @@ class Main public static String[] prepareThreadArray(ArrayList fullArray, int threadNumber, int threadCount) { - String[] threadArray = new String[fullArray.size()/threadCount]; int count = 0; - for(int i = (threadNumber*fullArray.size())/threadCount; i < ((threadNumber+1)*fullArray.size())/threadCount; i++) + int arrayStart = (threadNumber*fullArray.size())/threadCount; + int arrayEnd = ((threadNumber+1)*fullArray.size())/threadCount; + String[] threadArray = new String[arrayEnd-arrayStart]; + for(int i = arrayStart; i < arrayEnd; i++) { threadArray[count] = fullArray.get(i); count++;