瀏覽代碼

Tests + Bug Fixes

* Test cases for LSB extraction, RGBA extraction and bit plane browsing
* Bug fix for alpha planes in bit plane browser
Ge0rg3 5 年之前
父節點
當前提交
950a12360e
共有 3 個文件被更改,包括 7 次插入4 次删除
  1. 3 2
      src/core/operations/ViewBitPlane.mjs
  2. 0 1
      tests/operations/index.mjs
  3. 4 1
      tests/operations/tests/Image.mjs

+ 3 - 2
src/core/operations/ViewBitPlane.mjs

@@ -62,7 +62,6 @@ class ViewBitPlane extends Operation {
             throw new OperationError("Error: Bit argument must be between 0 and 7");
         }
 
-        parsedImage.rgba(true);
 
         let pixel, bin, newPixelValue;
 
@@ -73,9 +72,11 @@ class ViewBitPlane extends Operation {
 
             if (bin.charAt(bitIndex) === "1") newPixelValue = 0;
 
-            for (let i=0; i < 4; i++) {
+            for (let i=0; i < 3; i++) {
                 this.bitmap.data[idx + i] = newPixelValue;
             }
+            this.bitmap.data[idx + 3] = 255;
+
         });
 
         const imageBuffer = await parsedImage.getBufferAsync(jimp.AUTO);

+ 0 - 1
tests/operations/index.mjs

@@ -109,4 +109,3 @@ const logOpsTestReport = logTestReport.bind(null, testStatus);
 
 TestRegister.runTests()
     .then(logOpsTestReport);
-

File diff suppressed because it is too large
+ 4 - 1
tests/operations/tests/Image.mjs


Some files were not shown because too many files changed in this diff