Reconstructing Serial Image Data from Gameboy Printer Spoof - visualization
Nintendo created a printer that's compatible with the Gameboy. The Gameboy could print to it by means of a serial SPI link. I've used an STM32 to emulate a printer by capturing the data packets from the Gameboy and spoofing printer responses.
The data from the Gameboy is, naturally, a stream of bytes. Each two bits corresponds to one pixel(giving each pixel 4 shades of grayscale). The Gameboy typically prints images that have a resolution of 160 x 144. These images are cut up into 9 segments that are each 16 pixels tall(9*16=144).
Then in each segment, serial pixel data is processed from top to bottom, then left to right.
Now, my issue is that when I process the data with my Java application, it doesn't show as it should be.
Using the data at the end of this question, I get this result:
But it should look something like this:
I'm not sure what the problem is and I've been working on it for quite a while. You can see that the first photo looks almost like two side-by-side versions of the actual photo. Does anyone know if the pixel data is formatted differently than I know or if it's simply a bug in my code?
Here's the code I use to convert the data:
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedImage img = new BufferedImage(160, 144, BufferedImage.TYPE_INT_RGB);
BufferedReader reader = new BufferedReader(new FileReader("gbinput.txt"));
String data = reader.readLine();
String[] textNumbers = data.split(", ");
int[] numbers = new int[160*144];
// Split bytes into crumbs(each pixel is one crumb) and put them into "numbers" array
for(int i = 0; i < textNumbers.length; i++) {
for(int nibble = 0; nibble < 4; nibble++) {
numbers[i * 4 + nibble] = (3 - ((Integer.valueOf(textNumbers[i]) & (0xC0 >> (nibble * 2))) >> ((3 - nibble)*2))) * 5592405;
}
}
// set RGB image data to data in "numbers" array
int i = 0;
for(int y = 0; y < 9; y++) {
for(int x = 0; x < 160; x++) {
for(int a = 0; a < 16; a++) {
img.setRGB(x, a + 16 * y, numbers[i]);
i++;
}
}
}
// save output
File imageOutput = new File("image.png");
ImageIO.write(img, "png", imageOutput);
}
}
Here's the data I use to create the image(it's saved as "gbinput.txt" in the project folder):
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 255, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 255, 255, 255, 255, 28, 255, 62, 28, 12, 28, 4, 12, 12, 4, 36, 4, 255, 255, 255, 255, 99, 255, 7, 99, 67, 35, 99, 63, 2, 98, 2, 98, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 247, 254, 3, 1, 17, 0, 255, 255, 255, 255, 255, 255, 143, 255, 71, 143, 5, 3, 0, 142, 200, 140, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 127, 159, 14, 4, 224, 70, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 231, 255, 65, 3, 33, 1, 255, 255, 255, 255, 248, 255, 240, 248, 240, 248, 224, 248, 192, 128, 24, 0, 255, 255, 255, 255, 255, 255, 127, 255, 126, 255, 109, 243, 97, 192, 68, 140, 255, 255, 255, 255, 191, 255, 191, 31, 95, 15, 15, 31, 159, 255, 63, 127, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 255, 255, 255, 255, 255, 255, 36, 16, 48, 16, 48, 24, 60, 24, 24, 60, 255, 255, 255, 255, 255, 255, 2, 98, 2, 98, 2, 98, 66, 34, 2, 98, 255, 255, 255, 255, 255, 255, 25, 48, 25, 48, 25, 48, 25, 48, 17, 56, 255, 255, 255, 255, 255, 255, 76, 136, 76, 136, 76, 136, 72, 140, 204, 142, 255, 255, 255, 255, 255, 255, 6, 0, 250, 4, 122, 228, 162, 68, 6, 12, 255, 255, 255, 255, 255, 255, 32, 49, 33, 48, 32, 49, 33, 49, 97, 49, 255, 255, 255, 255, 255, 255, 0, 24, 0, 24, 0, 24, 152, 0, 192, 128, 255, 255, 255, 255, 255, 255, 4, 140, 132, 12, 4, 140, 72, 132, 97, 192, 255, 255, 255, 255, 255, 255, 127, 63, 127, 63, 127, 63, 63, 127, 127, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 161, 255, 247, 255, 254, 255, 85, 255, 126, 255, 223, 255, 255, 255, 87, 255, 98, 255, 86, 253, 96, 255, 81, 255, 8, 255, 119, 255, 253, 255, 73, 247, 33, 255, 242, 221, 192, 255, 16, 255, 20, 251, 21, 255, 222, 255, 134, 125, 192, 255, 66, 253, 0, 255, 178, 93, 5, 250, 68, 255, 254, 255, 149, 127, 3, 255, 160, 95, 0, 255, 181, 95, 4, 251, 86, 253, 212, 255, 112, 255, 64, 255, 116, 255, 104, 255, 93, 247, 227, 255, 85, 255, 103, 255, 17, 255, 4, 251, 130, 125, 0, 255, 9, 247, 0, 255, 80, 255, 106, 255, 41, 215, 0, 255, 66, 253, 1, 254, 8, 247, 3, 255, 21, 255, 240, 255, 137, 119, 2, 255, 41, 215, 0, 255, 20, 255, 176, 255, 48, 223, 8, 255, 21, 255, 34, 255, 81, 255, 0, 255, 40, 215, 0, 255, 44, 215, 129, 254, 0, 255, 32, 255, 1, 255, 0, 255, 192, 127, 0, 255, 140, 119, 64, 191, 0, 255, 0, 255, 0, 255, 0, 255, 10, 245, 34, 255, 64, 255, 0, 255, 127, 255, 163, 255, 96, 223, 0, 255, 129, 127, 0, 255, 96, 223, 0, 255, 255, 255, 255, 255, 85, 255, 10, 255, 17, 255, 11, 255, 21, 255, 0, 255, 255, 255, 255, 255, 255, 255, 175, 255, 85, 255, 186, 255, 93, 255, 200, 255, 255, 255, 255, 255, 255, 255, 255, 255, 127, 255, 191, 255, 93, 255, 234, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 125, 255, 255, 255, 85, 255, 255, 255, 119, 255, 251, 255, 247, 255, 255, 255, 127, 255, 255, 255, 221, 255, 175, 255, 85, 255, 251, 255, 87, 255, 242, 255, 85, 255, 186, 255, 85, 255, 114, 255, 85, 255, 251, 255, 84, 255, 202, 255, 85, 255, 254, 255, 84, 255, 166, 255, 85, 255, 207, 255, 85, 255, 220, 255, 80, 255, 34, 255, 85, 255, 68, 255, 87, 255, 144, 255, 108, 215, 0, 255, 213, 127, 122, 255, 117, 255, 160, 255, 0, 255, 0, 255, 21, 255, 1, 255, 85, 255, 224, 255, 96, 223, 0, 255, 80, 255, 3, 255, 95, 255, 255, 255, 0, 255, 0, 255, 118, 221, 3, 255, 159, 127, 255, 255, 255, 255, 255, 255, 24, 247, 128, 255, 92, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 40, 215, 132, 251, 234, 85, 1, 254, 26, 245, 5, 250, 170, 213, 129, 254, 138, 117, 4, 251, 168, 87, 1, 254, 136, 119, 85, 170, 171, 84, 65, 190, 8, 247, 65, 190, 170, 85, 16, 239, 168, 87, 68, 187, 170, 85, 69, 186, 136, 119, 68, 187, 170, 85, 20, 235, 136, 119, 84, 171, 170, 85, 81, 174, 1, 255, 0, 255, 1, 255, 0, 255, 48, 223, 4, 251, 168, 87, 0, 255, 21, 255, 138, 255, 12, 247, 0, 255, 16, 255, 0, 255, 160, 95, 128, 255, 85, 255, 63, 255, 85, 255, 66, 255, 85, 255, 179, 255, 100, 223, 32, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 119, 255, 251, 255, 213, 255, 78, 255, 119, 255, 255, 255, 85, 255, 46, 255, 85, 255, 243, 255, 85, 255, 244, 255, 213, 255, 251, 255, 229, 255, 192, 255, 87, 255, 142, 255, 87, 255, 7, 255, 87, 255, 15, 255, 71, 255, 7, 255, 117, 255, 51, 255, 84, 255, 64, 255, 7, 255, 143, 255, 79, 255, 143, 255, 28, 247, 1, 255, 87, 255, 127, 255, 255, 255, 255, 255, 255, 255, 255, 255, 31, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 255, 245, 255, 160, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 251, 255, 85, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 127, 255, 191, 255, 95, 255, 63, 255, 194, 253, 225, 254, 234, 245, 241, 254, 250, 245, 248, 255, 250, 253, 252, 255, 170, 85, 124, 131, 186, 69, 191, 64, 170, 85, 124, 131, 254, 1, 61, 194, 170, 85, 92, 163, 170, 85, 80, 175, 170, 85, 69, 186, 234, 21, 221, 34, 162, 93, 69, 186, 170, 85, 80, 175, 128, 127, 65, 190, 170, 85, 213, 42, 129, 127, 64, 191, 171, 85, 0, 255, 136, 119, 64, 191, 162, 93, 16, 239, 131, 127, 8, 255, 129, 127, 32, 255, 136, 119, 0, 255, 70, 253, 0, 255, 53, 255, 3, 255, 21, 255, 96, 255, 205, 255, 34, 255, 85, 255, 46, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 87, 255, 58, 255, 84, 255, 12, 255, 89, 247, 16, 255, 117, 255, 12, 255, 81, 255, 0, 255, 18, 253, 128, 255, 138, 117, 0, 255, 93, 255, 0, 255, 47, 215, 3, 255, 87, 255, 15, 255, 191, 127, 63, 255, 63, 255, 63, 255, 199, 255, 195, 255, 223, 247, 227, 255, 241, 255, 241, 255, 243, 253, 240, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 239, 231, 231, 215, 255, 251, 255, 213, 255, 244, 255, 208, 255, 255, 255, 245, 255, 193, 254, 64, 255, 32, 255, 66, 253, 5, 250, 137, 119, 161, 255, 95, 255, 255, 0, 170, 85, 116, 139, 186, 69, 243, 0, 202, 245, 175, 240, 74, 245, 116, 139, 175, 95, 79, 191, 167, 95, 119, 143, 175, 87, 195, 63, 169, 87, 3, 255, 252, 255, 254, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 170, 85, 94, 161, 170, 85, 69, 186, 42, 213, 197, 186, 234, 213, 209, 238, 174, 81, 68, 187, 170, 85, 69, 186, 170, 85, 213, 42, 170, 85, 87, 168, 168, 87, 4, 251, 170, 85, 0, 255, 168, 87, 192, 63, 34, 221, 1, 254, 160, 95, 68, 187, 40, 215, 0, 255, 153, 119, 64, 191, 162, 93, 4, 251, 133, 127, 3, 255, 4, 255, 2, 255, 129, 127, 32, 255, 171, 85, 32, 255, 85, 255, 130, 255, 85, 255, 33, 255, 64, 255, 99, 191, 69, 255, 162, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 65, 255, 2, 255, 124, 215, 0, 255, 73, 247, 163, 255, 129, 127, 0, 255, 9, 247, 112, 255, 164, 95, 4, 255, 7, 255, 0, 255, 83, 253, 252, 255, 95, 255, 31, 255, 95, 255, 31, 255, 175, 95, 7, 255, 71, 255, 7, 255, 248, 255, 248, 255, 254, 253, 252, 255, 252, 255, 254, 255, 254, 255, 255, 255, 255, 255, 127, 255, 127, 255, 63, 255, 191, 127, 63, 255, 159, 127, 31, 255, 202, 245, 225, 254, 202, 245, 247, 248, 250, 245, 241, 254, 242, 253, 249, 254, 231, 16, 250, 0, 213, 0, 254, 0, 167, 80, 127, 128, 181, 64, 127, 128, 85, 0, 2, 0, 64, 0, 0, 0, 64, 0, 224, 0, 85, 0, 203, 0, 86, 1, 191, 0, 85, 0, 15, 0, 85, 0, 61, 130, 109, 23, 159, 127, 255, 255, 127, 255, 255, 127, 191, 127, 63, 127, 127, 255, 255, 255, 254, 255, 200, 247, 245, 234, 202, 245, 212, 235, 202, 245, 213, 234, 170, 213, 117, 138, 234, 21, 84, 171, 170, 85, 84, 171, 138, 117, 69, 186, 186, 69, 17, 238, 170, 85, 76, 179, 170, 85, 17, 238, 234, 21, 92, 163, 170, 85, 125, 130, 136, 119, 0, 255, 32, 223, 1, 254, 170, 85, 4, 251, 170, 85, 116, 139, 129, 127, 2, 255, 53, 223, 0, 255, 133, 127, 2, 255, 105, 215, 81, 174, 5, 255, 2, 255, 125, 255, 138, 255, 80, 255, 7, 255, 85, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 93, 247, 0, 255, 80, 255, 204, 255, 20, 255, 15, 255, 85, 255, 0, 255, 9, 247, 0, 255, 68, 255, 243, 255, 5, 255, 224, 255, 100, 223, 254, 255, 151, 127, 75, 255, 135, 127, 9, 255, 213, 255, 43, 255, 6, 253, 111, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 159, 127, 143, 255, 103, 223, 135, 255, 239, 215, 195, 255, 203, 247, 225, 255, 252, 255, 253, 254, 254, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 171, 84, 92, 163, 168, 87, 3, 255, 31, 255, 255, 255, 255, 255, 254, 255, 86, 1, 195, 63, 127, 255, 255, 255, 255, 255, 248, 255, 202, 245, 114, 143, 127, 255, 255, 255, 252, 255, 231, 248, 36, 223, 128, 127, 254, 117, 7, 248, 242, 253, 223, 224, 238, 17, 255, 0, 190, 65, 63, 192, 187, 68, 255, 0, 170, 85, 221, 34, 170, 85, 255, 0, 234, 21, 253, 2, 187, 68, 255, 0, 138, 117, 196, 59, 170, 85, 85, 170, 224, 31, 192, 63, 174, 85, 240, 15, 170, 85, 4, 251, 170, 85, 80, 175, 161, 95, 68, 187, 168, 87, 21, 234, 170, 85, 64, 191, 170, 85, 20, 235, 41, 215, 4, 251, 105, 215, 0, 255, 169, 87, 0, 255, 25, 247, 0, 255, 85, 255, 68, 187, 35, 221, 128, 255, 80, 255, 10, 255, 85, 255, 34, 255, 80, 255, 42, 255, 84, 255, 42, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 117, 255, 191, 255, 245, 255, 127, 255, 247, 255, 43, 255, 245, 255, 255, 255, 85, 255, 254, 255, 215, 255, 175, 255, 127, 255, 251, 255, 125, 255, 175, 255, 85, 255, 187, 255, 214, 253, 253, 255, 85, 255, 240, 255, 221, 255, 238, 255, 255, 255, 255, 255, 127, 255, 63, 255, 127, 255, 63, 255, 127, 255, 63, 255, 251, 245, 241, 255, 250, 245, 249, 254, 248, 255, 249, 254, 254, 253, 253, 254, 255, 255, 255, 255, 252, 255, 119, 248, 170, 85, 195, 63, 148, 127, 39, 248, 234, 245, 156, 227, 234, 21, 201, 62, 154, 117, 159, 224, 251, 4, 255, 0, 141, 127, 33, 254, 111, 208, 127, 128, 234, 21, 255, 0, 187, 68, 255, 0, 175, 80, 255, 0, 170, 85, 255, 0, 174, 81, 223, 32, 239, 16, 255, 0, 251, 4, 255, 0, 251, 4, 255, 0, 239, 16, 255, 0, 255, 0, 255, 0, 174, 81, 252, 3, 249, 7, 243, 15, 235, 23, 199, 59, 169, 87, 86, 169, 184, 71, 252, 227, 126, 241, 255, 248, 58, 61, 27, 60, 179, 252, 225, 254, 170, 85, 84, 171, 170, 85, 17, 238, 170, 85, 4, 251, 170, 85, 84, 171, 170, 85, 80, 175, 42, 213, 20, 235, 168, 87, 4, 251, 168, 87, 20, 235, 8, 247, 66, 191, 40, 215, 72, 191, 38, 223, 64, 191, 34, 221, 0, 255, 85, 255, 160, 255, 96, 223, 4, 255, 12, 247, 0, 255, 74, 245, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 87, 255, 43, 255, 255, 255, 255, 255, 255, 255, 255, 255, 95, 255, 62, 255, 93, 255, 255, 255, 213, 255, 254, 255, 93, 255, 243, 255, 197, 255, 196, 255, 117, 255, 191, 255, 66, 253, 132, 255, 31, 255, 232, 255, 85, 255, 252, 255, 95, 255, 223, 255, 71, 255, 79, 255, 127, 255, 159, 255, 71, 255, 3, 255, 252, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 174, 81, 255, 0, 170, 85, 127, 128, 43, 212, 223, 160, 191, 192, 255, 192, 231, 16, 255, 0, 245, 0, 254, 0, 80, 3, 179, 12, 112, 16, 208, 48, 255, 0, 255, 0, 93, 0, 255, 0, 231, 16, 126, 128, 59, 196, 189, 78, 255, 16, 255, 0, 223, 0, 255, 0, 117, 0, 251, 2, 85, 0, 42, 0, 118, 1, 255, 0, 223, 1, 254, 1, 86, 1, 251, 0, 85, 0, 254, 0, 219, 124, 173, 254, 244, 255, 158, 207, 142, 207, 238, 255, 190, 125, 215, 40, 168, 87, 205, 50, 190, 65, 127, 128, 190, 65, 127, 128, 251, 4, 127, 128, 136, 119, 192, 63, 234, 21, 97, 158, 162, 93, 244, 11, 250, 5, 240, 15, 168, 87, 81, 174, 162, 93, 0, 255, 170, 85, 16, 239, 170, 85, 21, 234, 160, 95, 0, 255, 4, 255, 0, 255, 10, 245, 2, 255, 136, 119, 0, 255, 138, 117, 0, 255, 128, 127, 32, 255, 32, 223, 32, 255, 154, 117, 128, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 85, 255, 255, 255, 253, 87, 142, 255, 117, 255, 254, 255, 85, 255, 173, 255, 125, 255, 128, 255, 213, 255, 94, 255, 85, 255, 30, 255, 84, 255, 252, 255, 85, 255, 10, 255, 21, 255, 0, 255, 113, 223, 48, 255, 100, 223, 18, 255, 141, 119, 57, 255, 81, 255, 32, 255, 25, 247, 8, 255, 84, 255, 96, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 127, 255, 127, 255, 255, 255, 231, 208, 223, 224, 197, 240, 239, 240, 253, 240, 247, 248, 241, 252, 250, 252, 120, 24, 172, 28, 78, 29, 255, 63, 255, 255, 255, 255, 255, 255, 127, 255, 126, 127, 127, 127, 255, 255, 255, 255, 223, 255, 237, 254, 243, 252, 255, 248, 21, 0, 10, 0, 213, 0, 142, 0, 213, 0, 255, 0, 213, 0, 239, 0, 117, 0, 187, 0, 85, 0, 191, 0, 87, 0, 191, 0, 85, 0, 254, 0, 70, 17, 255, 0, 87, 0, 255, 0, 119, 0, 191, 0, 53, 64, 126, 224, 238, 17, 255, 0, 255, 0, 255, 0, 125, 3, 255, 0, 95, 4, 251, 7, 232, 23, 156, 227, 234, 117, 247, 56, 110, 157, 210, 239, 185, 119, 217, 63, 138, 117, 0, 255, 42, 213, 0, 255, 32, 223, 20, 235, 109, 215, 130, 255, 138, 117, 0, 255, 73, 247, 40, 255, 149, 127, 2, 255, 85, 255, 160, 255, 81, 255, 34, 255, 82, 253, 42, 255, 23, 255, 224, 255, 81, 255, 2, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 87, 255, 255, 255, 85, 255, 118, 255, 81, 255, 135, 255, 92, 255, 32, 255, 247, 255, 191, 255, 69, 255, 238, 255, 85, 255, 130, 255, 93, 255, 0, 255, 255, 255, 223, 255, 21, 255, 118, 255, 116, 255, 56, 255, 69, 255, 128, 255, 85, 255, 0, 255, 213, 255, 224, 255, 154, 245, 96, 255, 100, 223, 192, 255, 127, 255, 63, 255, 95, 255, 31, 255, 191, 95, 15, 255, 167, 95, 23, 239, 253, 252, 255, 252, 255, 252, 253, 254, 255, 255, 254, 255, 255, 255, 255, 255, 127, 127, 183, 123, 107, 21, 254, 1, 86, 1, 191, 0, 213, 0, 75, 128, 251, 252, 207, 252, 255, 252, 246, 248, 97, 208, 160, 0, 85, 0, 130, 0, 87, 0, 175, 0, 85, 0, 174, 1, 85, 3, 47, 3, 95, 7, 159, 15, 84, 1, 186, 1, 151, 67, 235, 199, 199, 247, 223, 227, 183, 192, 46, 192, 229, 240, 227, 248, 205, 240, 156, 224, 53, 192, 127, 128, 213, 0, 254, 0, 111, 17, 235, 28, 94, 7, 191, 99, 94, 49, 175, 28, 94, 199, 61, 227, 173, 223, 86, 239, 177, 127, 78, 191, 205, 255, 98, 255, 180, 127, 42, 255, 43, 213, 16, 239, 81, 255, 129, 254, 73, 247, 130, 255, 69, 255, 128, 255, 5, 255, 175, 255, 17, 255, 38, 255, 21, 255, 190, 255, 65, 255, 14, 255, 68, 255, 243, 255, 84, 255, 239, 255, 85, 255, 202, 255, 84, 255, 232, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 87, 255, 2, 255, 85, 255, 113, 255, 16, 255, 38, 255, 85, 255, 224, 255, 197, 255, 97, 255, 7, 253, 128, 255, 129, 95, 0, 255, 74, 245, 0, 255, 149, 127, 0, 255, 50, 221, 129, 255, 61, 215, 0, 255, 218, 117, 0, 255, 20, 255, 0, 255, 106, 213, 129, 254, 168, 87, 0, 255, 234, 85, 0, 255, 187, 87, 203, 183, 169, 87, 17, 239, 139, 117, 28, 227, 170, 85, 245, 10, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 127, 255, 21, 192, 163, 192, 245, 192, 208, 224, 197, 240, 226, 240, 245, 240, 248, 240, 85, 0, 34, 0, 85, 0, 160, 0, 85, 0, 186, 0, 85, 0, 168, 0, 95, 15, 180, 15, 86, 1, 131, 0, 85, 0, 35, 0, 85, 0, 14, 0, 213, 0, 163, 0, 213, 0, 174, 0, 85, 0, 251, 0, 87, 0, 255, 0, 87, 0, 63, 0, 87, 0, 255, 0, 86, 1, 255, 0, 219, 4, 247, 8, 94, 49, 236, 31, 255, 7, 255, 3, 121, 7, 242, 15, 231, 31, 15, 255, 213, 255, 107, 255, 87, 255, 14, 255, 126, 253, 249, 254, 242, 253, 192, 255, 1, 255, 160, 255, 138, 117, 20, 235, 170, 85, 73, 190, 137, 119, 33, 254, 85, 255, 160, 255, 33, 223, 16, 239, 138, 117, 16, 239, 225, 95, 0, 255, 112, 255, 10, 255, 116, 255, 192, 255, 203, 119, 112, 191, 100, 223, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 209, 127, 48, 255, 141, 127, 48, 255, 213, 127, 32, 255, 16, 255, 0, 255, 152, 119, 0, 255, 26, 245, 32, 255, 72, 247, 16, 255, 162, 93, 0, 255, 153, 119, 0, 255, 168, 87, 0, 255, 170, 85, 12, 243, 170, 85, 17, 238, 168, 87, 0, 255, 146, 125, 13, 242, 170, 85, 76, 179, 170, 85, 31, 224, 170, 85, 69, 186, 170, 85, 31, 224, 174, 81, 93, 162, 170, 85, 5, 250, 255, 127, 191, 127, 191, 127, 255, 63, 223, 63, 95, 191, 175, 95, 79, 191, 253, 240, 254, 248, 240, 252, 254, 252, 255, 252, 253, 254, 252, 255, 254, 255, 85, 0, 171, 0, 85, 0, 42, 0, 85, 0, 43, 0, 85, 0, 138, 0, 85, 0, 179, 0, 85, 0, 238, 0, 87, 0, 187, 0, 85, 0, 255, 0, 87, 0, 191, 0, 85, 0, 255, 0, 114, 5, 243, 15, 175, 95, 63, 255, 106, 21, 242, 15, 231, 31, 63, 255, 127, 255, 255, 255, 255, 255, 254, 255, 127, 255, 255, 255, 255, 255, 254, 255, 252, 255, 249, 254, 202, 245, 255, 128, 202, 245, 140, 243, 42, 213, 0, 255, 129, 127, 204, 51, 174, 81, 255, 0, 132, 127, 2, 255, 90, 245, 32, 255, 24, 247, 5, 250, 170, 85, 81, 174, 131, 127, 66, 191, 32, 223, 16, 239, 136, 119, 64, 191, 169, 87, 36, 255, 80, 255, 32, 255, 50, 221, 0, 255, 72, 247, 32, 255, 16, 255, 128, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 7, 255, 35, 255, 21, 255, 62, 255, 149, 127, 62, 255, 85, 255, 6, 255, 170, 85, 128, 255, 25, 247, 0, 255, 25, 247, 32, 255, 114, 221, 160, 255, 170, 85, 0, 255, 74, 245, 4, 251, 75, 245, 5, 250, 170, 85, 3, 252, 170, 85, 1, 254, 162, 93, 1, 254, 170, 85, 125, 130, 234, 21, 223, 32, 170, 85, 79, 176, 171, 84, 23, 232, 191, 64, 255, 0, 169, 84, 255, 0, 175, 95, 119, 143, 175, 87, 127, 131, 119, 3, 239, 3, 87, 1, 226, 1, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 213, 0, 115, 128, 21, 192, 174, 193, 171, 215, 203, 255, 255, 255, 255, 255, 89, 7, 199, 63, 159, 127, 191, 255, 255, 255, 255, 255, 255, 255, 254, 255, 255, 255, 255, 255, 255, 255, 254, 255, 250, 253, 231, 248, 234, 213, 113, 142, 255, 252, 247, 248, 245, 192, 239, 0, 119, 0, 255, 0, 191, 64, 95, 160, 247, 0, 255, 0, 222, 1, 255, 0, 106, 21, 221, 34, 170, 85, 240, 15, 234, 21, 221, 34, 170, 85, 119, 136, 170, 85, 93, 162, 170, 85, 81, 174, 168, 87, 5, 250, 168, 87, 0, 255, 170, 85, 84, 171, 170, 85, 20, 235, 241, 127, 35, 255, 133, 127, 0, 255, 40, 215, 32, 255, 8, 247, 0, 255, 8, 247, 0, 255, 0, 255, 0, 255, 200, 119, 34, 255, 21, 255, 2, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 85, 255, 176, 255, 85, 255, 62, 255, 85, 255, 58, 255, 85, 255, 254, 255, 80, 255, 16, 255, 100, 223, 1, 254, 58, 245, 132, 251, 42, 213, 1, 254, 106, 213, 92, 163, 170, 85, 112, 143, 170, 85, 116, 139, 202, 21, 253, 2, 174, 81, 31, 224, 170, 85, 81, 174, 190, 85, 0, 255, 244, 95, 8, 255, 171, 84, 223, 32, 170, 85, 127, 128, 170, 85, 5, 250, 75, 244, 128, 255, 117, 0, 120, 128, 149, 64, 254, 0, 87, 0, 250, 0, 181, 64, 90, 160, 255, 255, 127, 255, 255, 127, 191, 127, 63, 127, 63, 63, 125, 30, 246, 8, 255, 255, 255, 255, 255, 255, 250, 252, 205, 240, 58, 192, 85, 0, 14, 0, 250, 253, 204, 243, 42, 213, 253, 2, 94, 1, 191, 0, 85, 0, 171, 0, 174, 85, 0, 255, 162, 93, 116, 139, 170, 85, 189, 2, 94, 1, 255, 0, 42, 213, 20, 235, 170, 85, 85, 170, 170, 85, 87, 168, 187, 68, 247, 8, 170, 85, 69, 186, 170, 85, 84, 171, 170, 85, 85, 170, 186, 69, 223, 32, 170, 85, 0, 255, 34, 221, 64, 191, 161, 95, 0, 255, 162, 93, 85, 170, 152, 119, 64, 191, 136, 119, 0, 255, 129, 127, 64, 191, 40, 215, 0, 255, 9, 247, 2, 255, 37, 223, 2, 255, 81, 255, 2, 255, 34, 221, 17, 238, 213, 127, 130, 255, 145, 127, 54, 255, 148, 127, 8, 255, 132, 127, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 255, 252, 254, 252, 248, 249, 241, 227, 243, 255, 255, 255, 255, 255, 255, 119, 143, 14, 7, 135, 126, 252, 254, 254, 252, 255, 255, 255, 255, 255, 255, 191, 126, 60, 62, 30, 60, 24, 60, 24, 60, 255, 255, 255, 255, 255, 255, 119, 251, 241, 115, 97, 115, 33, 99, 32, 67, 255, 255, 255, 255, 255, 255, 123, 135, 129, 3, 131, 63, 63, 63, 55, 15, 255, 255, 255, 255, 255, 255, 187, 199, 195, 131, 217, 131, 193, 155, 130, 131, 255, 255, 255, 255, 255, 255, 222, 227, 195, 128, 37, 152, 25, 60, 120, 60, 255, 255, 255, 255, 255, 255, 187, 125, 113, 57, 3, 51, 35, 135, 207, 135, 255, 255, 175, 213, 251, 213, 251, 213, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 227, 243, 247, 227, 227, 243, 240, 243, 240, 248, 250, 252, 255, 255, 255, 255, 249, 252, 156, 8, 136, 24, 91, 145, 3, 19, 7, 51, 255, 255, 255, 255, 61, 152, 58, 25, 147, 25, 209, 147, 195, 147, 167, 211, 255, 255, 255, 255, 72, 3, 24, 11, 128, 27, 179, 24, 51, 184, 177, 250, 255, 255, 255, 255, 15, 7, 55, 15, 63, 127, 3, 127, 1, 3, 7, 3, 255, 255, 255, 255, 131, 130, 56, 145, 60, 153, 168, 17, 1, 3, 139, 7, 255, 255, 255, 255, 121, 60, 125, 56, 120, 57, 75, 49, 129, 3, 203, 135, 255, 255, 255, 255, 143, 207, 143, 223, 207, 159, 207, 159, 207, 159, 255, 159, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
Related
Problem in decoding h264 raw frame in swift
I try to decode an inputstream of [UInt8] to h264 video , I have search the whole web and read the beautiful detailed answer of olivia How to use VideoToolbox to decompress H.264 video stream , I tried to convert her objc answer to swift but it didn't worked for me . Then i came to this nice pod https://github.com/songbihai/VideoDecoder?ref=iosexample.com the problem is i am getting some of images completely and some other in half green , Beside this image issue , the other issue i have is this code doesn't work on real device(iPad pro 2019 , iOS 15), and gives me DecodeError.decompressionOutputCallback(-12909) which as I searched means bad data(!?) , and this is just for my stream the example file included in pod is ok, I tried to tweak some parameters but when I did it just didn't give me anything both on simulator and the real device. this is one part of data that I'm getting 1, 0, 0, 0, 85, 3, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 253, 8, 0, 0, 6, 102, 1, 0, 53, 3, 0, 0, 4, 1, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 97, 224, 112, 124, 79, 87, 150, 179, 234, 117, 62, 173, 161, 255, 77, 252, 87, 185, 125, 113, 31, 255, 255, 87, 241, 151, 222, 199, 142, 213, 117, 121, 250, 180, 99, 215, 101, 247, 175, 94, 229, 188, 214, 166, 189, 243, 107, 139, 188, 215, 170, 203, 138, 174, 181, 38, 226, 122, 180, 220, 187, 228, 229, 239, 8, 47, 215, 235, 245, 253, 98, 247, 23, 186, 235, 81, 26, 155, 189, 241, 21, 87, 142, 235, 95, 90, 159, 171, 212, 35, 147, 171, 244, 228, 234, 241, 61, 106, 78, 173, 84, 174, 242, 195, 61, 125, 117, 175, 171, 205, 85, 105, 175, 25, 213, 165, 234, 247, 214, 162, 124, 208, 133, 123, 95, 87, 174, 181, 17, 187, 235, 95, 87, 133, 191, 93, 111, 35, 249, 122, 212, 41, 214, 164, 235, 215, 205, 127, 212, 223, 191, 12, 49, 122, 123, 105, 188, 144, 238, 35, 171, 86, 253, 195, 143, 233, 252, 109, 215, 213, 170, 173, 234, 94, 181, 9, 119, 175, 142, 147, 179, 235, 213, 246, 229, 234, 213, 213, 190, 251, 201, 221, 120, 222, 175, 243, 111, 164, 55, 101, 191, 19, 17, 151, 155, 215, 94, 241, 253, 90, 47, 171, 117, 151, 81, 92, 215, 125, 87, 147, 63, 55, 180, 77, 221, 99, 43, 223, 175, 17, 141, 239, 79, 44, 51, 215, 213, 103, 228, 247, 87, 147, 173, 77, 201, 218, 147, 247, 136, 172, 188, 180, 250, 234, 213, 173, 105, 235, 123, 234, 213, 19, 87, 174, 181, 10, 94, 171, 93, 90, 42, 176, 142, 19, 221, 127, 47, 74, 185, 123, 207, 133, 101, 198, 233, 100, 132, 57, 111, 253, 94, 90, 196, 86, 126, 11, 123, 232, 246, 155, 147, 165, 9, 117, 120, 158, 189, 92, 102, 143, 189, 157, 143, 96, 95, 193, 85, 27, 119, 109, 46, 214, 131, 171, 227, 175, 233, 116, 116, 252, 22, 117, 183, 99, 243, 102, 190, 47, 58, 134, 47, 69, 241, 158, 187, 123, 116, 244, 31, 193, 12, 210, 216, 216, 141, 189, 245, 168, 67, 115, 241, 126, 158, 223, 198, 250, 91, 116, 52, 61, 122, 15, 151, 211, 252, 41, 236, 39, 76, 149, 239, 122, 119, 191, 205, 175, 224, 135, 216, 153, 240, 133, 47, 64, 126, 255, 31, 211, 219, 247, 246, 89, 24, 227, 55, 39, 87, 159, 113, 187, 142, 234, 208, 75, 184, 107, 130, 75, 125, 136, 156, 146, 110, 93, 250, 140, 234, 245, 120, 158, 93, 15, 124, 157, 168, 142, 181, 238, 28, 235, 221, 226, 123, 167, 196, 98, 100, 220, 70, 225, 77, 215, 86, 251, 239, 47, 55, 181, 226, 116, 251, 89, 186, 180, 61, 201, 111, 139, 230, 239, 92, 212, 184, 107, 171, 198, 106, 106, 205, 201, 127, 228, 239, 25, 213, 253, 43, 201, 201, 127, 230, 244, 15, 203, 75, 146, 209, 188, 184, 42, 241, 60, 154, 235, 151, 75, 124, 221, 185, 111, 55, 90, 159, 154, 203, 136, 172, 70, 235, 190, 178, 240, 81, 218, 191, 98, 184, 158, 221, 127, 190, 213, 242, 122, 248, 202, 210, 233, 94, 148, 170, 149, 14, 184, 78, 191, 183, 226, 180, 187, 31, 225, 46, 236, 73, 255, 25, 239, 163, 214, 235, 97, 176, 252, 37, 239, 189, 112, 81, 234, 170, 142, 223, 8, 251, 237, 167, 106, 190, 16, 238, 235, 178, 176, 255, 31, 207, 11, 59, 185, 55, 191, 130, 207, 44, 45, 232, 156, 198, 255, 17, 181, 75, 68, 161, 30, 79, 114, 113, 93, 236, 249, 121, 111, 205, 194, 22, 182, 244, 237, 255, 8, 119, 245, 98, 254, 46, 213, 83, 206, 24, 15, 197, 221, 191, 127, 132, 111, 125, 157, 200, 65, 219, 126, 59, 96, 94, 195, 158, 25, 249, 169, 255, 8, 123, 62, 205, 28, 141, 75, 193, 85, 135, 172, 112, 221, 213, 45, 34, 241, 222, 77, 161, 49, 253, 175, 139, 221, 171, 21, 143, 229, 218, 252, 20, 216, 246, 223, 175, 175, 138, 239, 162, 252, 18, 119, 215, 197, 123, 105, 115, 117, 233, 234, 111, 75, 223, 181, 228, 245, 39, 94, 139, 226, 55, 223, 251, 223, 241, 30, 233, 255, 116, 139, 15, 196, 211, 96, 189, 126, 74, 86, 171, 143, 223, 183, 250, 249, 50, 209, 159, 238, 203, 79, 242, 81, 214, 184, 139, 243, 193, 47, 196, 82, 73, 157, 36, 177, 60, 186, 89, 121, 54, 13, 63, 146, 151, 91, 147, 114, 110, 54, 241, 29, 106, 78, 246, 121, 47, 27, 29, 119, 230, 239, 210, 63, 37, 248, 138, 199, 245, 121, 55, 62, 235, 8, 43, 68, 110, 159, 10, 197, 117, 105, 249, 186, 197, 245, 98, 126, 172, 85, 97, 110, 111, 105, 64
How flutter parses ArrayBuffer
flutter 2.0.0 uses the long connection websocket protocol, the returned data is ArrayBuffer, how to convert it into json data [31, 139, 8, 0, 0, 0, 0, 0, 0, 0, 37, 144, 49, 79, 195, 48, 16, 70, 255, 10, 186, 217, 61, 249, 206, 103, 59, 241, 214, 38, 65, 68, 13, 36, 212, 41, 66, 221, 2, 237, 192, 208, 5, 194, 84, 229, 191, 115, 41, 147, 101, 125, 239, 61, 75, 190, 193, 231, 245, 12, 9, 126, 126, 63, 240, 123, 154, 47, 96, 224, 60, 205, 19, 164, 27, 28, 115, 61, 174, 231, 208, 119, 25, 146, 160, 48, 137, 129, 93, 126, 131, 196, 145, 48, 82, 136, 6, 218, 62, 43, 100, 209, 122, 239, 165, 208, 185, 122, 130, 20, 98, 68, 9, 6, 170, 237, 190, 81, 216, 161, 13, 106, 62, 182, 29, 36, 138, 1, 197, 137, 154, 117, 175, 162, 88, 100, 17, 29, 235, 109, 86, 145, 11, 198, 82, 43, 221, 160, 155, 35, 36, 13, 254, 231, 169, 8, 108, 160, 25, 43, 133, 244, 42, 209, 25, 120, 63, 12, 26, 68, 231, 136, 244, 177, 174, 125, 217, 171, 196, 120, 175, 159, 154, 149, 36, 143, 190, 92, 27, 207, 107, 132, 138, 184, 114, 247, 134, 148, 24, 189, 129, 215, 241, 168, 19, 9, 150, 236, 138, 101, 49, 48, 127, 93, 47, 250, 29, 108, 153, 54, 86, 54, 68, 15, 76, 73, 202, 100, 9, 150, 63, 238, 197, 136, 230, 44, 1, 0, 0]
BadSessionNotActivated,0x80270000,The session cannot be used because ActivateSession has not been called
Whenever I try to send an ActivateSessionRequest to the opcua server, it throws an error stating "BadSessionNotActivated". Below is the message format of ActivateSessionRequest: var ActivateSessionRequest v_activateSessionReq := { requestHeader := session_reqHeader, clientSignature := { algorithm := valueof(tr_String("http://opcfoundation.org/UA/SecurityPolicy#None")), Signature := valueof(tr_ByteString({48, 130, 4, 19, 48, 130, 2, 251, 160, 3, 2, 1, 2, 2, 2, 16, 26, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 11, 5, 0, 48, 40, 49, 18, 48, 16, 6, 3, 85, 4, 10, 19, 9, 78, 111, 100, 101, 79, 80, 67, 85, 65, 49, 18, 48, 16, 6, 3, 85, 4, 3, 19, 9, 78, 111, 100, 101, 79, 80, 67, 85, 65, 48, 34, 24, 15, 50, 48, 49, 56, 48, 50, 48, 53, 49, 51, 53, 54, 48, 50, 90, 24, 15, 50, 48, 49, 57, 48, 50, 48, 53, 49, 51, 53, 54, 48, 50, 90, 48, 40, 49, 18, 48, 16, 6, 3, 85, 4, 10, 19, 9, 78, 111, 100, 101, 79, 80, 67, 85, 65, 49, 18, 48, 16, 6, 3, 85, 4, 3, 19, 9, 78, 111, 100, 101, 79, 80, 67, 85, 65, 48, 130, 1, 34, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 3, 130, 1, 15, 0, 48, 130, 1, 10, 2, 130, 1, 1, 0, 178, 243, 137, 233, 196, 81, 105, 65, 195, 121, 2, 212, 193, 216, 187, 73, 213, 135, 135, 163, 140, 13, 165, 74, 203, 63, 212, 221, 158, 178, 59, 89, 71, 118, 141, 147, 102, 111, 5, 111, 52, 36, 160, 187, 189, 244, 38, 0, 200, 206, 33, 174, 227, 110, 132, 79, 202, 59, 223, 29, 116, 217, 12, 193, 191, 44, 87, 168, 113, 69, 125, 23, 239, 71, 139, 38, 121, 203, 255, 54, 196, 68, 199, 249, 43, 206, 32, 255, 192, 10, 134, 200, 71, 104, 150, 176, 66, 233, 241, 17, 227, 3, 96, 172, 169, 164, 96, 113, 114, 190, 194, 28, 232, 161, 46, 241, 170, 0, 70, 215, 89, 228, 130, 219, 152, 216, 85, 234, 72, 142, 103, 63, 211, 101, 238, 224, 160, 84, 134, 171, 241, 148, 60, 212, 190, 250, 16, 203, 248, 212, 153, 16, 56, 159, 153, 185, 202, 239, 135, 150, 185, 188, 80, 207, 62, 122, 172, 25, 110, 80, 124, 166, 227, 86, 32, 97, 137, 35, 164, 156, 1, 150, 51, 64, 140, 180, 196, 162, 32, 131, 207, 170, 144, 19, 90, 251, 239, 173, 33, 65, 135, 125, 110, 137, 2, 184, 106, 146, 55, 166, 217, 141, 127, 163, 137, 57, 91, 158, 133, 29, 218, 205, 174, 98, 208, 123, 30, 240, 42, 29, 102, 187, 113, 26, 166, 30, 55, 207, 49, 32, 132, 173, 115, 155, 7, 207, 206, 201, 27, 209, 52, 198, 119, 210, 142, 161, 2, 3, 1, 0, 1, 163, 130, 1, 65, 48, 130, 1, 61, 48, 12, 6, 3, 85, 29, 19, 1, 1, 255, 4, 2, 48, 0, 48, 29, 6, 3, 85, 29, 14, 4, 22, 4, 20, 162, 197, 27, 92, 111, 157, 37, 181, 146, 213, 162, 250, 174, 112, 194, 229, 164, 3, 176, 205, 48, 81, 6, 3, 85, 29, 35, 4, 74, 48, 72, 128, 20, 162, 197, 27, 92, 111, 157, 37, 181, 146, 213, 162, 250, 174, 112, 194, 229, 164, 3, 176, 205, 161, 44, 164, 42, 48, 40, 49, 18, 48, 16, 6, 3, 85, 4, 10, 19, 9, 78, 111, 100, 101, 79, 80, 67, 85, 65, 49, 18, 48, 16, 6, 3, 85, 4, 3, 19, 9, 78, 111, 100, 101, 79, 80, 67, 85, 65, 130, 2, 16, 26, 48, 91, 6, 3, 85, 29, 17, 4, 84, 48, 82, 134, 44, 117, 114, 110, 58, 97, 118, 100, 111, 111, 116, 99, 104, 97, 108, 107, 101, 45, 86, 105, 114, 116, 117, 97, 108, 66, 111, 120, 58, 78, 111, 100, 101, 79, 80, 67, 85, 65, 45, 83, 101, 114, 118, 101, 114, 130, 9, 108, 111, 99, 97, 108, 104, 111, 115, 116, 130, 23, 97, 118, 100, 111, 111, 116, 99, 104, 97, 108, 107, 101, 45, 86, 105, 114, 116, 117, 97, 108, 66, 111, 120, 48, 44, 6, 9, 96, 134, 72, 1, 134, 248, 66, 1, 13, 4, 31, 22, 29, 79, 112, 101, 110, 83, 83, 76, 32, 71, 101, 110, 101, 114, 97, 116, 101, 100, 32, 67, 101, 114, 116, 105, 102, 105, 99, 97, 116, 101, 48, 14, 6, 3, 85, 29, 15, 1, 1, 255, 4, 4, 3, 2, 2, 252, 48, 32, 6, 3, 85, 29, 37, 1, 1, 255, 4, 22, 48, 20, 6, 8, 43, 6, 1, 5, 5, 7, 3, 1, 6, 8, 43, 6, 1, 5, 5, 7, 3, 2, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 11, 5, 0, 3, 130, 1, 1, 0, 147, 168, 16, 170, 204, 221, 81, 100, 167, 38, 104, 142, 27, 107, 108, 87, 94, 195, 100, 124, 141, 117, 46, 23, 231, 145, 68, 182, 241, 225, 148, 94, 144, 1, 142, 61, 228, 88, 64, 243, 126, 180, 17, 33, 164, 128, 234, 183, 198, 31, 223, 59, 125, 218, 110, 0, 112, 182, 244, 199, 220, 139, 114, 162, 153, 76, 245, 134, 167, 163, 199, 175, 153, 82, 214, 106, 142, 15, 52, 87, 11, 230, 95, 75, 23, 170, 137, 92, 144, 76, 111, 179, 1, 36, 150, 191, 84, 226, 252, 199, 228, 38, 97, 138, 26, 32, 230, 65, 110, 154, 179, 104, 146, 186, 104, 248, 246, 26, 136, 12, 15, 220, 6, 203, 220, 141, 230, 11, 185, 247, 250, 9, 76, 236, 74, 101, 149, 32, 100, 220, 249, 46, 255, 129, 21, 126, 6, 86, 230, 198, 94, 228, 51, 50, 73, 103, 57, 212, 105, 255, 9, 181, 189, 104, 121, 27, 21, 78, 196, 226, 99, 176, 44, 194, 176, 211, 216, 13, 81, 142, 35, 52, 76, 116, 49, 190, 253, 199, 166, 51, 41, 105, 81, 90, 222, 232, 223, 74, 100, 203, 192, 130, 48, 46, 116, 37, 236, 199, 70, 81, 60, 244, 6, 45, 51, 246, 4, 254, 178, 240, 14, 22, 64, 200, 134, 199, 249, 171, 118, 219, 81, 124, 218, 91, 175, 65, 59, 233, 19, 110, 217, 72, 165, 91, 75, 182, 12, 214, 215, 30, 169, 153, 36, 7, 69, 60 ,224, 153, 75, 106, 120, 118, 227, 63, 4, 63, 14, 101, 116, 161, 229, 230, 127, 196, 14, 37, 23, 251, 174, 94, 204, 114, 180, 26, 77, 200, 61, 148})) }, clientSoftwareCertificates := { realArray := { arrayLength := 0, arrayValues := { } } }, localeIds := valueof(tr_ListOfLocaleId({})), userIdentityToken := { encodingByte := 1, twoByteNodeValue := omit, namespaceIndex := 0, fourByteNodeValue := 321, encoding := 1, parameterLength := 13, extensibleParameterBody := { anonymousIdentityToken := { policyId := valueof(tr_String( "username_basic256")) } } }, userTokenSignature := { algorithm := valueof(tr_StringNull), Signature := valueof(tr_ByteStringNull) } } Client-Server Communication As shown in the image, ActivateSessionRequest is successful by sending SessionId and AuthenticationToken to the server. The header of ActivateSessionRequest contains AuthenticationToken. But How shall I provide the SessionId to the server? Is it because I am not providing the SessionId in the ActivateSessionRequest that the server throws an error or due to some other mistake? can someone guide me? Any feedback is highly appreciated. Thank you in Advance With Regards, Avdoot
Get values of effect options in vintageJS
I am working on website that add effects to images online using vintageJS. I have the following effect effect1 = { vignette: 0.7, viewFinder: "js/ImageEffects/assets/viewfinder/ttv-1.jpg", screen: { r: 227, g: 12, b: 169, a: 0.15 } }; and also I have the four basic effect of vintageJS( I get the four effects form the website of vintageJS . The website should have nine effects which mean that I need another four effects. I try to write some random values but I didn't get a good effect. Can anyone give some values that produce a good effect ?
Try the these effects: var RetroCurveR = [0, 0, 0, 1, 1, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 12, 12, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 17, 18, 19, 19, 20, 21, 22, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 39, 40, 41, 42, 44, 45, 47, 48, 49, 52, 54, 55, 57, 59, 60, 62, 65, 67, 69, 70, 72, 74, 77, 79, 81, 83, 86, 88, 90, 92, 94, 97, 99, 101, 103, 107, 109, 111, 112, 116, 118, 120, 124, 126, 127, 129, 133, 135, 136, 140, 142, 143, 145, 149, 150, 152, 155, 157, 159, 162, 163, 165, 167, 170, 171, 173, 176, 177, 178, 180, 183, 184, 185, 188, 189, 190, 192, 194, 195, 196, 198, 200, 201, 202, 203, 204, 206, 207, 208, 209, 211, 212, 213, 214, 215, 216, 218, 219, 219, 220, 221, 222, 223, 224, 225, 226, 227, 227, 228, 229, 229, 230, 231, 232, 232, 233, 234, 234, 235, 236, 236, 237, 238, 238, 239, 239, 240, 241, 241, 242, 242, 243, 244, 244, 245, 245, 245, 246, 247, 247, 248, 248, 249, 249, 249, 250, 251, 251, 252, 252, 252, 253, 254, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]; var RetroCurveG = [0, 0, 1, 2, 2, 3, 5, 5, 6, 7, 8, 8, 10, 11, 11, 12, 13, 15, 15, 16, 17, 18, 18, 19, 21, 22, 22, 23, 24, 26, 26, 27, 28, 29, 31, 31, 32, 33, 34, 35, 35, 37, 38, 39, 40, 41, 43, 44, 44, 45, 46, 47, 48, 50, 51, 52, 53, 54, 56, 57, 58, 59, 60, 61, 63, 64, 65, 66, 67, 68, 69, 71, 72, 73, 74, 75, 76, 77, 79, 80, 81, 83, 84, 85, 86, 88, 89, 90, 92, 93, 94, 95, 96, 97, 100, 101, 102, 103, 105, 106, 107, 108, 109, 111, 113, 114, 115, 117, 118, 119, 120, 122, 123, 124, 126, 127, 128, 129, 131, 132, 133, 135, 136, 137, 138, 140, 141, 142, 144, 145, 146, 148, 149, 150, 151, 153, 154, 155, 157, 158, 159, 160, 162, 163, 164, 166, 167, 168, 169, 171, 172, 173, 174, 175, 176, 177, 178, 179, 181, 182, 183, 184, 186, 186, 187, 188, 189, 190, 192, 193, 194, 195, 195, 196, 197, 199, 200, 201, 202, 202, 203, 204, 205, 206, 207, 208, 208, 209, 210, 211, 212, 213, 214, 214, 215, 216, 217, 218, 219, 219, 220, 221, 222, 223, 223, 224, 225, 226, 226, 227, 228, 228, 229, 230, 231, 232, 232, 232, 233, 234, 235, 235, 236, 236, 237, 238, 238, 239, 239, 240, 240, 241, 242, 242, 242, 243, 244, 245, 245, 246, 246, 247, 247, 248, 249, 249, 249, 250, 251, 251, 252, 252, 252, 253, 254, 255]; var RetroCurveB = [53, 53, 53, 54, 54, 54, 55, 55, 55, 56, 57, 57, 57, 58, 58, 58, 59, 59, 59, 60, 61, 61, 61, 62, 62, 63, 63, 63, 64, 65, 65, 65, 66, 66, 67, 67, 67, 68, 69, 69, 69, 70, 70, 71, 71, 72, 73, 73, 73, 74, 74, 75, 75, 76, 77, 77, 78, 78, 79, 79, 80, 81, 81, 82, 82, 83, 83, 84, 85, 85, 86, 86, 87, 87, 88, 89, 89, 90, 90, 91, 91, 93, 93, 94, 94, 95, 95, 96, 97, 98, 98, 99, 99, 100, 101, 102, 102, 103, 104, 105, 105, 106, 106, 107, 108, 109, 109, 110, 111, 111, 112, 113, 114, 114, 115, 116, 117, 117, 118, 119, 119, 121, 121, 122, 122, 123, 124, 125, 126, 126, 127, 128, 129, 129, 130, 131, 132, 132, 133, 134, 134, 135, 136, 137, 137, 138, 139, 140, 140, 141, 142, 142, 143, 144, 145, 145, 146, 146, 148, 148, 149, 149, 150, 151, 152, 152, 153, 153, 154, 155, 156, 156, 157, 157, 158, 159, 160, 160, 161, 161, 162, 162, 163, 164, 164, 165, 165, 166, 166, 167, 168, 168, 169, 169, 170, 170, 171, 172, 172, 173, 173, 174, 174, 175, 176, 176, 177, 177, 177, 178, 178, 179, 180, 180, 181, 181, 181, 182, 182, 183, 184, 184, 184, 185, 185, 186, 186, 186, 187, 188, 188, 188, 189, 189, 189, 190, 190, 191, 191, 192, 192, 193, 193, 193, 194, 194, 194, 195, 196, 196, 196, 197, 197, 197, 198, 199]; var EnhanceCurveR = [], EnhanceCurveG = [], EnhanceCurveB = []; for (var i = 0; i <= 255; ++i) EnhanceCurveB[i] = EnhanceCurveG[i] = EnhanceCurveR[i] = Math.round(-12 * Math.sin(i * 2 * Math.PI / 255) + i); effect1 = { noise: 20, vignette: 0.6, desaturate: 0.05, curves: { r: EnhanceCurveR, g: EnhanceCurveG, b: EnhanceCurveB }, screen: { r: 12, g: 75, b: 153, a: 0.3 } }; effect2 = { noise: 20, lighten: 0.1, vignette: 0.6, desaturate: 0.05, curves: { r: RetroCurveR, g: RetroCurveG, b: RetroCurveB }, screen: { r: 0, g: 0, b: 255, a: 0.25 } }; effect3 = { sepia: true, lighten: 0.1, desaturate: 0.8, curves: { r: EnhanceCurveR, g: EnhanceCurveG, b: EnhanceCurveB }, };
Byte Array to NSData
In a WebService JSON response is coming. In the response, there is image is coming as a byte array. I have to show the image in a UIImageView. I am trying to convert the byte array to NSData. But not getting how to do that. Any help would be appreciated. I am confident that the byte array has image data in it. Sample Byte array for your reference: (137, 80, 78, 71, ... 66, 96, 130) Thanks
Here is an example of getting your data into a NSData object. const unsigned char bytes[] = {values here}; NSData *data = [NSData dataWithBytes:bytes length:sizeof(bytes)]; NSLog(#"%#", data);
You have to convert the JSON to an array of strings first; you can, for example, use the NSJSONSerialization class: NSArray *strings = [NSJSONSerialization JSONObjectWithData:theJSONString options:kNilOptions error:NULL]; Then walk the strings array, convert each entry to an integer, and add it to an allocated byte pointer/array: unsigned c = strings.count; uint8_t *bytes = malloc(sizeof(*bytes) * c); unsigned i; for (i = 0; i < c; i++) { NSString *str = [strings objectAtIndex:i]; int byte = [str intValue]; bytes[i] = byte; } Then finally make an NSData out of the bytes, then init an UIImage object using it: NSData *imageData = [NSData dataWithBytesNoCopy:bytes length:c freeWhenDone:YES]; UIImage *image = [UIImage imageWithData:imageData];
and here's how to do it in Swift... var bytes:[Byte] = [137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 130, 0, 0, 0, 22, 8, 6, 0, 0, 0, 12, 244, 68, 168, 0, 0, 0, 1, 115, 82, 71, 66, 0, 174, 206, 28, 233, 0, 0, 0, 4, 103, 65, 77, 65, 0, 0, 177, 143, 11, 252, 97, 5, 0, 0, 0, 9, 112, 72, 89, 115, 0, 0, 14, 196, 0, 0, 14, 196, 1, 149, 43, 14, 27, 0, 0, 3, 212, 73, 68, 65, 84, 104, 67, 237, 153, 61, 139, 20, 65, 16, 134, 55, 17, 253, 3, 114, 127, 224, 208, 204, 64, 228, 18, 3, 19, 21, 19, 35, 217, 200, 204, 15, 48, 19, 228, 48, 50, 242, 76, 12, 245, 2, 99, 47, 55, 88, 83, 65, 220, 76, 48, 57, 19, 49, 220, 95, 224, 125, 120, 34, 126, 224, 120, 207, 65, 141, 53, 189, 213, 85, 189, 238, 172, 176, 210, 5, 195, 206, 77, 87, 87, 247, 84, 189, 245, 118, 213, 220, 160, 169, 82, 61, 112, 232, 129, 65, 245, 66, 245, 0, 30, 168, 64, 168, 56, 56, 242, 64, 5, 66, 5, 66, 5, 66, 197, 192, 31, 15, 12, 142, 29, 63, 209, 228, 174, 209, 232, 101, 199, 87, 147, 201, 36, 171, 139, 141, 55, 227, 113, 179, 122, 234, 180, 171, 115, 110, 109, 173, 217, 217, 217, 53, 99, 112, 241, 210, 229, 169, 185, 216, 244, 246, 88, 50, 134, 93, 145, 18, 125, 79, 231, 230, 173, 219, 217, 253, 47, 51, 176, 92, 32, 156, 92, 89, 233, 188, 219, 189, 245, 245, 16, 8, 219, 219, 239, 27, 230, 69, 206, 76, 157, 246, 112, 99, 99, 106, 14, 78, 71, 230, 13, 94, 159, 64, 96, 47, 218, 222, 50, 7, 95, 239, 221, 5, 2, 47, 77, 96, 17, 178, 56, 10, 48, 217, 139, 192, 36, 81, 240, 158, 111, 109, 181, 251, 176, 178, 30, 102, 233, 43, 139, 75, 128, 192, 187, 161, 39, 87, 196, 108, 226, 23, 15, 8, 223, 70, 47, 154, 131, 7, 247, 155, 253, 27, 215, 155, 79, 103, 86, 59, 23, 207, 24, 67, 71, 203, 175, 253, 189, 230, 235, 179, 39, 157, 235, 199, 187, 183, 13, 23, 250, 123, 195, 171, 71, 118, 248, 229, 111, 158, 91, 130, 221, 207, 119, 239, 52, 59, 231, 207, 154, 107, 179, 6, 107, 137, 132, 64, 128, 202, 145, 167, 155, 155, 97, 112, 5, 8, 232, 91, 25, 174, 193, 129, 227, 113, 38, 0, 179, 156, 206, 49, 84, 2, 132, 89, 51, 50, 7, 208, 52, 203, 217, 151, 7, 102, 253, 174, 233, 30, 126, 126, 252, 208, 6, 44, 5, 128, 245, 55, 65, 101, 14, 66, 96, 83, 29, 43, 152, 90, 231, 251, 235, 87, 237, 22, 176, 19, 233, 235, 185, 2, 196, 16, 8, 165, 103, 191, 232, 105, 167, 64, 237, 158, 51, 1, 217, 181, 225, 112, 74, 7, 16, 105, 241, 108, 244, 5, 4, 246, 66, 112, 229, 138, 128, 239, 49, 130, 100, 109, 9, 8, 68, 103, 247, 202, 133, 44, 16, 34, 59, 4, 94, 196, 2, 1, 207, 96, 32, 139, 153, 176, 13, 248, 90, 32, 224, 136, 156, 195, 117, 198, 122, 122, 105, 150, 144, 85, 158, 190, 181, 158, 117, 254, 70, 199, 140, 55, 158, 218, 155, 199, 150, 204, 245, 106, 4, 178, 211, 10, 28, 52, 205, 24, 23, 247, 150, 14, 99, 22, 35, 136, 46, 129, 204, 101, 59, 64, 128, 238, 83, 187, 28, 31, 233, 209, 147, 234, 0, 220, 22, 8, 81, 6, 136, 19, 60, 61, 139, 46, 75, 106, 11, 177, 205, 113, 97, 117, 20, 243, 4, 175, 111, 32, 68, 93, 131, 21, 12, 28, 157, 138, 197, 26, 204, 205, 29, 13, 114, 116, 96, 199, 2, 3, 243, 172, 140, 103, 29, 97, 3, 126, 249, 219, 154, 223, 2, 129, 5, 162, 2, 73, 186, 136, 92, 96, 114, 231, 38, 52, 90, 18, 204, 180, 93, 45, 169, 17, 116, 129, 103, 221, 75, 231, 81, 98, 43, 98, 22, 93, 183, 228, 142, 36, 11, 8, 60, 75, 37, 167, 103, 1, 1, 6, 209, 98, 129, 136, 121, 127, 115, 36, 9, 59, 116, 128, 16, 177, 130, 156, 221, 179, 2, 129, 151, 136, 90, 79, 198, 115, 242, 47, 106, 4, 214, 240, 186, 34, 41, 110, 163, 154, 164, 132, 158, 177, 1, 101, 167, 20, 157, 99, 132, 20, 72, 86, 230, 151, 50, 130, 102, 7, 125, 223, 1, 66, 196, 10, 146, 17, 139, 0, 66, 238, 35, 19, 123, 138, 170, 119, 93, 228, 165, 247, 227, 195, 2, 80, 23, 118, 158, 173, 40, 17, 116, 75, 59, 11, 35, 16, 112, 221, 38, 114, 111, 213, 8, 60, 183, 24, 161, 20, 8, 95, 30, 63, 10, 107, 4, 169, 37, 210, 22, 117, 10, 8, 57, 103, 80, 221, 71, 244, 234, 181, 84, 81, 59, 233, 101, 90, 201, 177, 18, 209, 122, 180, 119, 230, 35, 81, 167, 83, 242, 49, 105, 150, 246, 77, 3, 130, 190, 126, 30, 32, 48, 223, 90, 155, 35, 3, 144, 88, 44, 196, 250, 204, 153, 2, 2, 206, 176, 40, 178, 36, 171, 254, 7, 32, 148, 116, 58, 105, 123, 155, 130, 56, 151, 241, 94, 27, 40, 140, 49, 15, 16, 216, 199, 172, 107, 3, 2, 10, 209, 129, 20, 88, 250, 101, 96, 5, 93, 120, 105, 54, 64, 79, 198, 104, 13, 245, 189, 215, 91, 243, 37, 49, 87, 216, 201, 71, 171, 28, 43, 48, 47, 93, 43, 183, 7, 235, 185, 174, 63, 188, 226, 82, 214, 231, 61, 162, 34, 52, 250, 178, 136, 115, 115, 25, 168, 1, 129, 142, 238, 8, 184, 151, 234, 94, 126, 211, 175, 143, 100, 183, 238, 6, 244, 7, 41, 222, 1, 102, 64, 199, 99, 38, 198, 244, 145, 83, 255, 13, 29, 85, 127, 61, 140, 19, 92, 249, 76, 44, 191, 58, 248, 61, 44, 225, 154, 72, 215, 182, 148, 43, 16, 22, 29, 133, 37, 177, 95, 129, 176, 36, 129, 90, 244, 54, 43, 16, 22, 237, 225, 37, 177, 255, 27, 38, 183, 224, 140, 178, 26, 189, 95, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130]; var imageData:NSData = NSData(bytes: bytes, length: bytes.count); var image:UIImage = UIImage(data: imageData); var imageView:UIImageView = UIImageView(image: image);
I have my way to do it in Swift if let serverBytesArray = serverAnswer as? NSArray { var bytes:[Byte] = [] for serverByte in serverBytesArray { bytes.append(Byte(serverByte as UInt)) } var data = NSData(bytes: bytes, length: bytes.count); let tmpDir = NSTemporaryDirectory() data.writeToFile(tmpDir.stringByAppendingPathComponent("test.pdf"), atomically: true) }