public byte[] GeneratePayload(KeyBitmap keyBitmap) { var rawData = keyBitmap.GetScaledVersion(ImgWidth, ImgWidth); var bmp = new byte[ImgWidth * ImgWidth * ColorChannels + BmpHeader.Length]; Array.Copy(BmpHeader, 0, bmp, 0, BmpHeader.Length); if (rawData != null) { for (var y = 0; y < ImgWidth; y++) { for (var x = 0; x < ImgWidth; x++) { var src = (y * ImgWidth + x) * ColorChannels; var tar = ((ImgWidth - x - 1) * ImgWidth + y) * ColorChannels + BmpHeader.Length; bmp[tar + 0] = rawData[src + 0]; bmp[tar + 1] = rawData[src + 1]; bmp[tar + 2] = rawData[src + 2]; } } } return(bmp); }
public byte[] GeneratePayload(KeyBitmap keyBitmap) { var rawData = keyBitmap.GetScaledVersion(imgWidth, imgWidth); var bmp = new byte[imgWidth * imgWidth * colorChannels + bmpHeader.Length]; Array.Copy(bmpHeader, 0, bmp, 0, bmpHeader.Length); if (rawData != null) { for (int y = 0; y < imgWidth; y++) { for (int x = 0; x < imgWidth; x++) { var src = (y * imgWidth + x) * colorChannels; var tar = ((imgWidth - x - 1) * imgWidth + y) * colorChannels + bmpHeader.Length; bmp[tar + 0] = rawData[src + 0]; bmp[tar + 1] = rawData[src + 1]; bmp[tar + 2] = rawData[src + 2]; } } } return(bmp); }
public byte[] GeneratePayload(KeyBitmap keyBitmap) { var rawData = keyBitmap.GetScaledVersion(imgSize, imgSize); if (rawData is null) { return(GetNullImage()); } return(EncodeImageToJpg(rawData)); }