File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -45,26 +45,21 @@ proc fbclear*() =
4545 zeroMem (fbMap, FbSize )
4646
4747proc fbscreenshot * (fbMap: pointer , output: string ) =
48- let fbData = cast [ptr UncheckedArray [uint8 ]](fbMap)
49- var rotatedPixels = newSeqUninit [uint8 ](FbPixels * 4 )
48+ let fbData = cast [ptr UncheckedArray [uint16 ]](fbMap)
49+ var rotatedPixels = newSeqUninit [uint32 ](FbPixels )
5050
5151 for x in 0 ..< FbWidth :
5252 let colBase = x * FbHeight
5353 var srcBase = x * 2
5454
5555 for y in 0 ..< FbHeight :
56- let pixel = uint16 ( fbData[srcBase]) or ( uint16 (fbData[srcBase + 1 ]) shl 8 )
56+ let pixel = fbData[srcBase]
5757 srcBase += FbWidth * 2
5858
59- let r = (pixel shr 11 ) and 0x 1F
60- let g = (pixel shr 5 ) and 0x 3F
61- let b = pixel and 0x 1F
62-
63- let dstIdx = (colBase + FbHeight - 1 - y) * 4
64- rotatedPixels[dstIdx] = FiveToEight [r]
65- rotatedPixels[dstIdx + 1 ] = SixToEight [g]
66- rotatedPixels[dstIdx + 2 ] = FiveToEight [b]
67- rotatedPixels[dstIdx + 3 ] = 255
59+ rotatedPixels[colBase + FbHeight - 1 - y] = uint32 (FiveToEight [(pixel shr 11 ) and 0x 1F ]) or
60+ (uint32 (SixToEight [(pixel shr 5 ) and 0x 3F ]) shl 8 ) or
61+ (uint32 (FiveToEight [pixel and 0x 1F ]) shl 16 ) or
62+ 0x FF000000 'u32
6863
6964 discard stbi_write_png (
7065 cstring (output),
You can’t perform that action at this time.
0 commit comments