diff --git a/main.py b/main.py index fb51a09..3a810cf 100644 --- a/main.py +++ b/main.py @@ -173,28 +173,21 @@ i = dataStart for currentRow in tqdm(range(height), "读入像素点中"): currentCol = 0 while (currentCol < width * (bpp // 8)): + index = dataStart + currentRow * rowLength + currentCol if (bpp == 32): pixels[currentRow].append({ - 'r': - imgBytes[dataStart + currentRow * rowLength + currentCol], - 'g': - imgBytes[dataStart + currentRow * rowLength + currentCol + 1], - 'b': - imgBytes[dataStart + currentRow * rowLength + currentCol + 2], - 'a': - imgBytes[dataStart + currentRow * rowLength + currentCol + 3] + 'r': imgBytes[index], + 'g': imgBytes[index + 1], + 'b': imgBytes[index + 2], + 'a': imgBytes[index + 3] }) currentCol += bpp // 8 else: pixels[currentRow].append({ - 'r': - imgBytes[dataStart + currentRow * rowLength + currentCol], - 'g': - imgBytes[dataStart + currentRow * rowLength + currentCol + 1], - 'b': - imgBytes[dataStart + currentRow * rowLength + currentCol + 2], - 'a': - 0 + 'r': imgBytes[index], + 'g': imgBytes[index + 1], + 'b': imgBytes[index + 2], + 'a': 0 }) currentCol += bpp // 8 # 读入图片为像素数组完成