iOS 中byte数组转化成图片

如果是做 java 的可能对这个byte[] 和字符串之间的转化并不陌生.做 iOS 对于图片处理似乎已经习惯了 SDWebImage 了.或许我们更熟悉通过 URL 去加载一张图片.但是这次后台返回了一个这种东西.

{
    img = "[-1, -40, -1, -32, 0, 16, 74, 70, 73, 70, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, -1, -37, 0, 67, 0, 8, 6, 6, 7, 6, 5, 8, 7, 7, 7, 9, 9, 8, 10, 12, 20, 13, 12, 11, 11, 12, 25, 18, 19, 15, 20, 29, 26, 31, 30, 29, 26, 28, 28, 32, 36, 46, 39, 32, 34, 44, 35, 28, 28, 40, 55, 41, 44, 48, 49, 52, 52, 52, 31, 39, 57, 61, 56, 50, 60, 46, 51, 52, 50, -1, -37, 0, 67, 1, 9, 9, 9, 12, 11, 12, 24, 13, 13, 24, 50, 33, 28, 33, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, -1, -64, 0, 17, 8, 0, 50, 0, -102, 3, 1, 34, 0, 2, 17, 1, 3, 17, 1, -1, -60, 0, 31, 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, -1, -60, 0, -75, 16, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 125, 1, 2, 3, 0, 4, 17, 5, 18, 33, 49, 65, 6, 19, 81, 97, 7, 34, 113, 20, 50, -127, -111, -95, 8, 35, 66, -79, -63, 21, 82, -47, -16, 36, 51, 98, 114, -126, 9, 10, 22, 23, 24, 25, 26, 37, 38, 39, 40, 41, 42, 52, 53, 54, 55, 56, 57, 58, 67, 68, 69, 70, 71, 72, 73, 74, 83, 84, 85, 86, 87, 88, 89, 90, 99, 100, 101, 102, 103, 104, 105, 106, 115, 116, 117, 118, 119, 120, 121, 122, -125, -124, -123, -122, -121, -120, -119, -118, -110, -109, -108, -107, -106, -105, -104, -103, -102, -94, -93, -92, -91, -90, -89, -88, -87, -86, -78, -77, -76, -75, -74, -73, -72, -71, -70, -62, -61, -60, -59, -58, -57, -56, -55, -54, -46, -45, -44, -43, -42, -41, -40, -39, -38, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -1, -60, 0, 31, 1, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, -1, -60, 0, -75, 17, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 119, 0, 1, 2, 3, 17, 4, 5, 33, 49, 6, 18, 65, 81, 7, 97, 113, 19, 34, 50, -127, 8, 20, 66, -111, -95, -79, -63, 9, 35, 51, 82, -16, 21, 98, 114, -47, 10, 22, 36, 52, -31, 37, -15, 23, 24, 25, 26, 38, 39, 40, 41, 42, 53, 54, 55, 56, 57, 58, 67, 68, 69, 70, 71, 72, 73, 74, 83, 84, 85, 86, 87, 88, 89, 90, 99, 100, 101, 102, 103, 104, 105, 106, 115, 116, 117, 118, 119, 120, 121, 122, -126, -125, -124, -123, -122, -121, -120, -119, -118, -110, -109, -108, -107, -106, -105, -104, -103, -102, -94, -93, -92, -91, -90, -89, -88, -87, -86, -78, -77, -76, -75, -74, -73, -72, -71, -70, -62, -61, -60, -59, -58, -57, -56, -55, -54, -46, -45, -44, -43, -42, -41, -40, -39, -38, -30, -29, -28, -27, -26, -25, -24, -23, -22, -14, -13, -12, -11, -10, -9, -8, -7, -6, -1, -38, 0, 12, 3, 1, 0, 2, 17, 3, 17, 0, 63, 0, -10, -86, 43, -106, -43, 124, 115, 97, -94, 106, -73, 22, 23, -74, -9, 76, -15, -107, 42, -48, -94, -112, 84, -88, 61, -40, 115, -110, 107, 111, 77, -43, -83, -75, 72, 35, -106, 2, -21, -26, 70, 36, 9, 34, -31, -74, -98, -2, -3, 123, 87, 71, 50, -40, -54, 84, -89, 24, -87, 73, 104, -53, -44, 87, 43, -86, 120, -1, 0, 73, -46, 117, 41, -84, 102, -122, -18, 73, 33, 32, 51, 68, -118, 87, 56, -49, 25, 97, -21, 91, -74, -73, 16, -21, 58, 101, -67, -36, 18, 75, 28, 115, 40, -111, 10, -74, -42, 30, -57, -88, -4, 57, 20, 93, 61, -126, 116, -89, 8, -87, 73, 104, -53, -75, 86, 63, -7, 10, -36, 127, -41, 8, -65, -12, 41, 43, -110, -42, 60, 110, -102, 38, -82, -42, 46, -14, -36, 52, 28, 57, 17, 40, 7, 32, 28, 103, 61, 125, -64, 24, -25, -125, 93, 69, -74, -93, 108, -48, 52, -45, 39, -39, 31, 103, -99, 42, -52, 2, -112, 48, 62, 98, 122, 16, 6, 57, -19, 74, -23, -124, -87, 78, 49, 82, 107, 70, 95, -94, -68, -13, 81, -8, -77, 97, 111, 114, -47, -40, -40, 75, 118, -118, 113, -26, 52, -98, 88, 62, -32, 96, -97, -49, 21, -93, 103, -15, 43, 69, -72, -46, 46, 47, 100, 89, -94, -106, -33, 110, -5, 111, -108, -69, 2, -64, 101, 114, 64, 97, -49, 53, 10, -75, 54, -19, 113, -70, 21, 18, -67, -114, -54, -118, -63, -16, -33, -117, 44, 60, 81, -10, -97, -79, 67, 115, 31, -39, -10, 111, -13, -43, 70, 119, 103, 24, -63, 63, -35, 53, -72, -18, -88, -69, -99, -126, -116, -127, -110, 113, -55, -32, 86, -111, -110, -110, -70, 51, -108, 92, 93, -103, -121, -30, -33, 18, -1, 0, -62, 45, -91, 69, 125, -10, 79, -75, 121, -109, -120, 118, 121, -101, 49, -107, 99, -100, -32, -1, 0, 119, -11, -86, 62, 14, -15, -103, -15, 92, -9, -86, 108, -123, -88, -73, 84, 32, 121, -69, -53, 100, -74, 121, -64, -12, 21, -50, -4, 97, -106, 65, 22, -113, 16, 118, 17, -77, 76, -52, -128, -16, 72, -40, 1, 35, -44, 100, -2, 102, -79, -68, 17, -30, -115, 55, -62, -6, 45, -20, -9, 49, -7, -73, 83, 76, 22, 56, -29, 95, -100, -128, 59, -98, -53, -109, -4, -8, -88, 114, -76, -84, 122, 80, -62, 70, 88, 69, 56, -58, -14, 127, -26, 123, 61, 21, -27, -42, 95, 21, 45, 127, -76, -116, -109, 105, -78, -37, -61, 41, 30, 110, 37, -13, 61, -125, 116, 24, -29, -73, 53, -23, 118, -105, 118, -9, -42, -79, -36, -38, -54, -78, -61, 32, -36, -82, -89, -126, 42, -108, -109, -40, -30, -85, -121, -87, 71, -29, 86, 38, -86, -9, -73, -74, -38, 117, -100, -73, 119, -109, 36, 54, -15, 12, -69, -71, -32, 85, -118, -16, -97, -119, -34, 34, -105, 84, -15, 28, -106, 16, 92, -106, -80, -74, 10, -95, 17, -14, -114, -8, -55, 110, 56, 36, 103, 31, -123, 42, -109, -28, 87, 47, 11, -121, 117, -22, 114, -12, 58, -101, -17, -116, -74, 49, 78, 82, -57, 74, -102, -30, 48, 113, -66, 73, 68, 89, -6, 12, 53, 116, 94, 21, -15, -10, -105, -30, -119, 77, -76, 106, -10, -73, -96, 110, -14, 37, 32, -18, 29, -10, -98, -1, 0, -95, -84, 123, 63, -123, 26, 63, -4, 35, -85, 13, -54, -56, 117, 55, -117, 38, -29, -52, 35, 99, -111, -48, 47, 76, 3, -22, 51, 92, -9, -124, 124, 1, -30, 93, 39, -60, -106, 26, -115, -59, -91, -68, 113, 67, 38, 100, 15, 42, -79, -38, 70, 14, 0, -49, 56, 57, 21, -102, 117, 19, 87, 58, -27, 12, 28, -23, -53, -111, -39, -82, -17, 115, -39, 40, -86, -26, 39, -2, -47, 89, 113, -108, -14, -118, -28, -97, -70, 114, 63, -97, -12, 21, 80, -22, 119, -118, 74, -74, -111, 114, 88, 112, 74, 58, -107, 63, 66, 72, -30, -74, -71, -26, 37, 115, -50, 126, 35, 105, -110, -38, -22, 86, -9, -114, -59, -123, -64, 112, 78, 73, -63, 12, 72, 31, -9, -53, 40, -4, 43, -84, -48, -11, -104, -31, -8, 114, -73, -56, 21, 90, -42, -35, -109, 104, 24, -7, -41, 32, 126, 103, 7, -15, -89, -4, 64, -46, -58, -95, -31, -87, 103, 80, -58, 91, 79, -34, -88, 12, 113, -113, -30, -56, -23, -45, -97, -61, -34, -68, -54, 61, 105, -41, -62, -45, 105, 4, -112, 13, -62, -56, -101, 126, 80, 70, 14, -19, -40, -5, -36, -124, -58, 115, -6, 10, -55, -5, -78, 61, 122, 80, -6, -50, 30, 49, -2, 87, -81, -95, -101, 33, -98, -32, -55, 115, 43, 60, -124, -72, -33, 35, 18, 73, 99, -109, -55, -11, 56, 63, -107, 122, -41, -122, -11, -120, -83, -2, 29, -83, -32, 8, -90, -46, 23, 82, -96, 96, 110, 92, -29, -15, 57, 31, -119, -82, 103, 78, -48, 126, -43, -16, -54, -14, -23, -109, -9, -94, 70, -98, 34, -68, 101, 83, -125, -100, 125, -17, -29, -58, 115, -116, -15, 92, -20, 90, -45, -89, -123, -18, 52, -126, 72, 13, 112, -110, 38, -33, -108, 17, -125, -69, 118, 62, -9, 33, 58, -25, -12, 20, -105, -69, -87, -47, 90, 43, 18, -71, 87, -39, -111, -93, -32, -69, 3, -82, -8, -83, 101, -67, -51, -62, 70, -83, 52, -58, 95, -101, 121, -24, 51, -98, -68, -111, -7, 86, -65, -59, -115, 94, -30, 41, 108, -12, -88, 102, 116, -115, -29, 50, -52, -86, -40, -34, 9, -62, -125, -22, 62, 83, 90, -1, 0, 12, -84, -116, 58, 28, -9, 110, -86, 12, -13, 16, -121, 104, -50, -43, 24, -21, -41, 25, -49, 30, -34, -11, -53, -4, 88, -77, 49, 120, -126, -46, -20, 111, -37, 61, -66, -33, -103, -119, 25, 82, 115, -116, -98, 56, 35, -127, -57, 126, -92, -44, 85, -70, -91, -95, -57, 90, 106, 120, -85, 116, 70, -73, -61, -113, 10, 105, -41, 58, 47, -10, -83, -3, -92, 87, 82, 78, -20, -79, -84, -56, 25, 85, 65, -57, 67, -58, 114, 15, 62, -43, -49, 124, 70, -16, -11, -74, -123, -85, 65, 53, -116, 98, 43, 107, -76, 39, -54, 94, -118, -54, 70, 113, -19, -56, 56, -81, 64, -8, 115, 120, -73, 126, 12, -76, 80, 83, 125, -69, 60, 78, 21, 66, -32, -122, 36, 112, 59, -32, -114, 123, -11, 60, -102, -28, 62, 46, 79, 11, -22, -102, 116, 10, -60, -51, 28, 44, -50, 55, -110, 0, 36, 99, -114, -128, -16, 121, -22, 120, -49, 65, 81, 56, -59, 80, 77, 24, -45, -100, -99, 118, -103, -81, -16, -77, 16, 120, 110, 121, -110, -36, 59, -55, 127, -27, -56, -22, 62, 96, -69, 23, 25, -11, 0, -109, -12, -55, 53, -36, 106, 113, 60, -38, 116, -87, 26, 51, -55, -63, 85, 92, 114, 65, 4, 117, 32, 17, -22, 61, 43, -111, -8, 83, 35, 63, -124, -26, 82, 23, 9, 120, -22, 48, -96, 18, 54, -95, -28, -114, -89, -98, -89, -40, 116, 2, -69, 75, 121, -42, -26, -35, 38, 64, 64, 97, -47, -70, -125, -36, 31, 122, -24, -93, -4, 52, 115, -41, -2, 35, 60, 99, -30, 110, -96, -9, -6, -27, -105, 19, 34, 45, -96, -3, -45, -28, 5, 125, -20, 27, 3, -16, 3, 63, -20, -5, 87, 69, -16, -33, -62, 122, 109, -58, -122, 53, 91, -5, 72, -82, -91, -99, -40, 70, -77, 32, 101, 84, 7, 29, 15, 25, -56, 60, -42, 15, -59, -120, -43, 60, 91, 11, 2, -39, 123, 52, 99, -106, 36, 3, -71, -57, 0, -12, 28, 116, 28, 103, 39, -87, 53, -35, -4, 55, -66, 91, -49, 6, 91, 70, 10, 111, -74, 102, -119, -62, -88, 92, 115, -111, -64, -17, -126, 57, -18, 114, 79, 57, -92, -105, -66, -18, 122, 117, -91, 40, 96, 97, -56, 121, -9, -60, -113, 14, -38, -24, 90, -60, 19, 88, -58, 34, -73, -69, 66, -34, 88, -24, -84, -89, -100, 123, 114, 56, -82, -17, -31, -59, -4, 79, -32, -120, -39, -43, 80, 91, -54, -15, 59, 34, 117, -28, 16, 78, 61, -104, 115, -19, 92, -49, -59, -7, 98, 109, 71, 76, -119, 89, -116, -53, 19, -77, -82, -14, 64, 82, 70, 56, -24, 15, 13, -49, 83, -57, -96, -82, -125, -31, -85, 61, -89, -127, -4, -7, 99, 38, 51, 112, -20, -66, 92, 96, 29, -68, 2, 78, 57, 108, 16, 121, 57, 56, 24, -20, 5, 53, -92, -40, -85, -73, 60, 12, 37, 45, -17, -2, 103, 110, -114, -110, -96, 120, -39, 89, 24, 100, 50, -100, -125, 95, 48, 65, -87, -53, 30, -80, -70, -107, -62, -83, -36, -62, 79, 49, -123, -57, -50, 29, -65, -38, -49, 94, 107, -23, 38, -45, 109, 110, 16, -68, 82, 77, 28, 114, -97, 49, -68, -119, -103, 3, -110, 49, -100, -125, -111, -41, 60, 98, -66, 119, -79, 16, -23, -98, 47, -73, 91, -56, -48, 91, -61, 120, -94, 101, -107, 3, -113, 47, 119, 57, 4, 115, -14, -26, -94, -65, 66, 114, -58, -83, 63, 79, -13, 47, 75, -82, 120, -56, 91, -82, -94, -41, 122, -76, 86, -92, -28, 74, -69, -46, 34, 115, -19, -14, -98, 115, 93, -9, -61, -33, -120, 55, 26, -59, -38, -24, -6, -61, 43, -35, 48, 38, 11, -128, 0, -13, 48, 50, 85, -128, -29, 56, -17, -19, -21, -41, -69, -68, 93, 54, -17, 69, -71, 73, -98, 51, -89, -68, 76, 101, 104, -33, 11, -76, -14, -57, 42, 126, -75, -13, -33, -124, 46, 30, -37, -59, -6, 76, -88, -47, -88, 23, 40, 29, -100, 41, 1, 9, -61, 30, 120, 28, 103, -98, -94, -91, -34, -100, -106, -69, -102, 65, -45, -59, -46, -99, -32, -109, 91, 31, 74, 81, 81, -63, 113, 5, -54, 23, -73, -102, 57, 80, 28, 22, -115, -125, 12, -6, 113, 82, 87, 81, -30, -116, -102, 40, -25, -122, 72, 101, 80, -47, -56, -91, 89, 79, 112, 70, 8, -81, 21, -41, 60, 43, -88, -39, -21, 87, 112, 89, -23, -73, -110, -38, -84, -124, -60, -15, -62, -18, -69, 79, 32, 103, 28, -29, 56, -4, 43, -37, 104, -87, -108, 121, -114, -100, 54, 38, 84, 27, 107, 91, -100, -57, -121, 97, -71, -45, 124, 61, 99, 107, -87, -82, 109, -26, -117, 99, 6, 77, -90, 18, -39, -62, -80, -12, 32, -29, 39, -100, -11, -21, 94, 117, -82, -8, 87, 81, -77, -42, -18, -31, -78, -45, 47, 36, -75, 89, 51, 19, 71, 11, -70, -19, 60, -127, -100, 28, -29, 56, -4, 43, -38, -99, 18, 88, -39, 36, 85, 116, 97, -126, -84, 50, 8, -88, 124, -26, 91, -1, 0, -77, -112, 54, 52, 91, -48, -9, -56, 56, 111, -26, -76, -91, 20, -43, -117, -93, -117, -107, 57, -54, 105, 110, 102, 120, 66, -38, 75, 95, 10, 105, -15, 74, 114, -34, 94, -20, 96, 12, 6, 36, -127, -6, -45, -4, 73, -31, -53, 63, 18, 105, -90, -38, -28, 109, -107, 50, 96, -108, 103, 49, -74, 58, -5, -113, 81, 90, 81, -59, 5, -94, -71, 64, 35, 87, 125, -60, 103, -115, -57, -114, 61, 50, 127, 90, -102, -101, -118, 106, -52, -25, -108, -37, -101, -102, -36, -15, 24, 52, -97, 26, -8, 78, -10, 88, -12, -5, 123, -79, -65, -126, -10, -15, 121, -47, -72, -20, 113, -126, 63, 48, 13, 84, -41, -68, 57, -84, -38, -23, 95, -37, -70, -37, -80, -72, -72, -72, 88, -62, 72, 119, 57, -54, -79, -55, -12, -5, -96, 1, -4, -85, -34, 107, -110, -8, -109, 109, 20, -2, 9, -69, -110, 68, -36, -48, 60, 114, 70, 114, 70, -42, -34, 23, 62, -4, 51, 15, -58, -71, -89, -121, 74, 47, 93, -114, -120, 98, 27, -102, -45, 115, -98, -8, 79, 126, -47, 88, 106, -48, -51, 38, 45, -94, -110, 23, 81, -73, -93, 62, 84, -100, -11, -25, 106, -5, 12, 125, 107, -48, -20, -62, 9, -82, 86, 54, 42, -95, -7, -119, -121, 42, -60, -110, 91, 62, -115, -112, 107, -54, 62, 21, 59, 75, -84, -22, 54, 14, 115, 107, 61, -103, 105, 19, 31, 120, -122, 80, 57, -22, 56, 118, -23, -21, 94, -85, 101, 27, -105, -111, -89, 86, -13, -30, 102, -120, 72, 70, 55, -90, 114, -66, -57, -126, 63, 28, -5, -43, -31, -35, -23, -93, 60, 74, -75, 70, 112, 31, 21, 52, 75, -85, -5, -67, 50, -22, -61, 79, -71, -71, -104, -92, -111, -54, -48, 70, -49, -123, 4, 21, 4, 12, -127, -53, 63, -41, -16, -84, 45, 51, -61, -34, 49, -48, -76, -40, 53, 77, 28, 92, 70, -9, 10, -62, 123, 111, 44, 7, 66, 24, -127, -108, 97, -49, 24, 32, -29, 60, -41, -82, 125, -106, -11, 126, -26, -94, -51, -1, 0, 93, 97, 83, -1, 0, -96, -19, -88, 45, 117, 101, 102, -106, 25, -106, 86, -106, 7, 41, 35, -92, 4, 47, 94, 14, 1, 98, 7, -67, 106, -30, -81, 123, -101, -45, -57, 78, 52, -107, 59, 38, -105, 126, -89, -115, 71, -31, 111, 21, -8, -109, 85, 105, 110, -20, -18, -106, 89, 15, -17, 39, -69, 67, 24, 3, -15, 29, 61, -128, -81, 100, -47, 116, 95, -20, 77, 58, -46, -50, 11, -122, 100, -123, 54, -56, 10, -116, 72, 113, -44, 15, -31, -25, -1, 0, -81, -109, -51, 104, -61, 113, 21, -62, 23, -122, 69, 117, 7, 7, 29, -113, -95, -87, 40, -116, 82, -44, -49, 17, -117, -99, 100, -94, -43, -110, -24, 85, -114, -39, -19, -25, 79, -77, -112, -74, -25, 59, -30, 61, -119, -25, 43, -23, -49, 110, -97, -41, -125, -15, -89, -61, -53, 109, 77, 46, 47, -76, -25, 88, -11, 16, -62, 67, 30, 24, -17, 66, 0, -63, 3, 39, 57, 4, -125, -114, -8, 60, 12, -113, 70, -86, 87, -42, -82, -1, 0, -23, 54, -57, 101, -38, 46, 21, -69, 48, -21, -76, -113, 74, 37, 20, -43, -116, 105, 85, -99, 41, 115, 69, -22, 124, -15, 62, -105, -30, 75, 116, -5, 20, -42, -6, -126, -59, -45, -53, -7, -116, 127, -31, 93, -33, -61, -81, 3, -22, 26, 126, -72, -102, -90, -87, 27, -37, 52, 42, -58, 40, 74, 100, -79, 35, 25, 39, 24, 28, 30, -103, -51, 122, -84, 19, 37, -60, 9, 52, 77, -71, 28, 100, 26, -110, -77, -115, 20, -99, -18, 117, -43, -52, 106, 78, 14, 9, 37, 125, -56, 38, -110, -27, 28, 121, 54, -23, 34, 99, -110, 101, -38, 115, -12, -57, -11, -86, 47, -83, -57, 27, -78, 58, 68, -84, -89, 4, 27, -104, -63, 7, -13, -83, 90, 77, -93, -48, 126, 85, -77, 79, -71, -64, -102, -22, 102, 68, 74, -8, -106, 116, 82, 66, -75, -78, -79, 81, -48, -74, -20, 103, -21, -114, 43, 82, -118, 40, 67, -112, 86, 86, -76, -51, 26, -85, -93, 21, 113, 4, -28, 48, 56, 35, -28, -94, -118, 24, -106, -29, -31, 38, 111, 15, 110, -112, -105, 38, 2, 73, 110, 115, -63, -85, -106, -124, -75, -100, 12, -60, -110, 99, 82, 73, -17, -59, 20, 81, -44, 58, 19, 84, 87, 22, -48, 93, -64, -48, 92, -63, 28, -48, -74, 55, 71, 42, 6, 83, -125, -111, -112, 125, -24, -94, -108, -66, 22, 56, -4, 72, -126, -45, 73, -45, 108, 37, 50, -39, -23, -10, -106, -14, 21, -38, 94, 24, 85, 9, 30, -103, 3, -89, 2, -82, 81, 69, 77, 47, -124, -86, -65, 16, 85, 8, 120, -41, 46, -128, -32, 24, 99, 98, 61, 78, 88, 103, -12, 31, -107, 20, 85, -78, 8, 96, 37, 124, 75, 118, -128, -112, -90, -35, 24, -88, -24, 78, 72, -49, -41, 0, 10, -43, -94, -118, 96, -62, -87, -39, 59, -67, -42, -94, 25, -104, -124, -72, 1, 65, 61, 7, -107, 25, -64, -4, 73, 63, -115, 20, 80, 34, 29, 35, -125, 124, -93, -18, -83, -45, -128, 59, 14, -107, -91, 69, 21, 48, -8, 80, -27, -72, 81, 69, 21, 66, 63, -1, -39]";
}

图片,这是什么👻. 看是个数组 还是个字符串.当然是字符串这一点可以忽略.转化数组还是比较简单的. 下面看看怎么转化.

        // 获取图片字符串
        NSString *str = dict[@"img"];
        // 截取中间的字符串并转化成数组
        str = [str substringWithRange:NSMakeRange(1, str.length - 2)];
        NSArray *array= [str componentsSeparatedByString:@","];
        
        // 子线程中将数组转化成 image
        dispatch_queue_t queue = dispatch_get_global_queue(0, 0);
        dispatch_async(queue, ^{
            NSUInteger count = array.count;
            uint8_t *bytes = malloc(sizeof(*bytes) * count);
            NSUInteger i;
            for (i = 0; i < count; i++) {
                NSString *str = [array objectAtIndex:i];
                NSInteger byte = [str integerValue];
                bytes[i] = byte;
            }
            NSData *data = [NSData dataWithBytesNoCopy:bytes length:count freeWhenDone:YES];
            UIImage *image= [UIImage imageWithData:data];
            
            // 回到主线程更新图片
            [self performSelectorOnMainThread:@selector(verifyImage:) withObject:image waitUntilDone:NO];
        });```


> 解决方案参考stackOverflow:
http://stackoverflow.com/questions/11860830/byte-array-to-nsdata

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,547评论 6 477
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,399评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,428评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,599评论 1 274
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,612评论 5 365
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,577评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,941评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,603评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,852评论 1 297
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,605评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,693评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,375评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,955评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,936评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,172评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 43,970评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,414评论 2 342

推荐阅读更多精彩内容