Извлечение ключа из имени файла
This commit is contained in:
@@ -11,6 +11,7 @@ module Lib
|
||||
|
||||
import Codec.Picture
|
||||
|
||||
import Text.Read (readMaybe)
|
||||
import Data.Word (Word8)
|
||||
import Data.Char (ord, chr)
|
||||
import Data.Bits (testBit, shiftL, complement, (.|.), (.&.))
|
||||
@@ -112,4 +113,9 @@ extractBitsFromImage bitsPerByte img =
|
||||
let width = imageWidth img
|
||||
height = imageHeight img
|
||||
pixels = [ pixelAt img x y | y <- [0..height - 1], x <- [0..width - 1] ]
|
||||
in concatMap (extractBitsFromPixel bitsPerByte) pixels
|
||||
in concatMap (extractBitsFromPixel bitsPerByte) pixels
|
||||
|
||||
extractShift :: String -> Maybe Int
|
||||
extractShift path =
|
||||
let prefix = takeWhile (`elem` ['0'..'9']) (reverse $ takeWhile (/= '_') (reverse path))
|
||||
in readMaybe (reverse prefix)
|
||||
|
||||
Reference in New Issue
Block a user