从iphone app到wcf服务的图片

时间:2013-07-05 20:57:35

标签: ios wcf nsdata

任何人都可以建议我如何通过WCF网络服务从iphone应用程序中检索图像 并将其保存到目录。

我正在接收来自iphone应用程序的NSDATA形式的图像(不知道,实际上iphone develpoer正在给我一个像Nsdata的图像)。 我这样做是为了将这些数据转换为图像并保存到我的目录

public Image byteArrayToImage(byte[] byteArrayIn)
{
Image returnImage = null;


string ApplicationVerifyPath = ConfigurationManager.AppSettings["ImagePath"].ToString();
ApplicationVerifyPath = ApplicationVerifyPath + "RetailerAdmin/ProductImages/";

using (MemoryStream ms = new MemoryStream(byteArrayIn, 0, byteArrayIn.Length))
{
ms.Write(byteArrayIn, 0, byteArrayIn.Length);
ms.Seek(0, SeekOrigin.Begin);
returnImage = Image.FromStream(ms);
returnImage.Save(ApplicationVerifyPath + returnImage, System.Drawing.Imaging.ImageFormat.Png);
}
return returnImage;
}

显示(参数是Image.FromStream(ms)中的无效错误。

请帮助我摆脱这个解决方案。

图像数据示例

ffd8ffe0 00104a46 49460001 01000001 00010000 ffe10058 45786966 00004d4d 002a0000 00080002 

01120003 00000001 00010000 87690004 00000001 00000026 00000000 0003a001 00030000 00010001 0000a002 

00040000 00010000 00e1a003 00040000 00010000 00e10000 0000ffdb 00430020 16181c18 14201c1a 1c242220 

26305034 302c2c30 62464a3a 5074667a 78726670 6e8090b8 9c8088ae 8a6e70a0 daa2aebe c4ced0ce 7c9ae2f2 

e0c8f0b8 cacec6ff db004301 22242430 2a305e34 345ec684 7084c6c6 c6c6c6c6 c6c6c6c6 c6c6c6c6 c6c6c6c6 

c6c6c6c6 c6c6c6c6 c6c6c6c6 c6c6c6c6 c6c6c6c6 c6c6c6c6 c6c6c6c6 c6c6c6c6 ffc00011 0800e100 e1030122 

00021101 031101ff c4001f00 00010501 01010101 01000000 00000000 00010203 04050607 08090a0b ffc400b5 

10000201 03030204 03050504 04000001 7d010203 00041105 12213141 06135161 07227114 328191a1 082342b1 

c11552d1 f0243362 7282090a 16171819 1a252627 28292a34 35363738 393a4344 45464748 494a5354 55565758 

595a6364 65666768 696a7374 75767778 797a8384 85868788 898a9293 94959697 98999aa2 a3a4a5a6 a7a8a9aa 

b2b3b4b5 b6b7b8b9 bac2c3c4 c5c6c7c8 c9cad2d3 d4d5d6d7 d8d9dae1 e2e3e4e5 e6e7e8e9 eaf1f2f3 f4f5f6f7 

f8f9faff c4001f01 00030101 01010101 01010100 00000000 00010203 04050607 08090a0b ffc400b5 11000201 

02040403 04070504 04000102 77000102 03110405 21310612 41510761 71132232 81081442 91a1b1c1 09233352 

f0156272 d10a1624 34e125f1 1718191a 26272829 2a353637 38393a43 44454647 48494a53 54555657 58595a63 

64656667 68696a73 74757677 78797a82 83848586 8788898a 92939495 96979899 9aa2a3a4 a5a6a7a8 a9aab2b3 

b4b5b6b7 b8b9bac2 c3c4c5c6 c7c8c9ca d2d3d4d5 d6d7d8d9 dae2e3e4 e5e6e7e8 e9eaf2f3 f4f5f6f7 f8f9faff 

da000c03 01000211 0311003f 00e828a2 aadede47 6716f7e5 8f0aa3a9 34016738 a85eeedd 0e1e7894 fbb815ce 

5c5ddcde 37ef1c85 3d11781f fd7a885b 36385fe9 401d3fdb ad3fe7e6 1ffbec51 f6eb4ff9 f987fefb 15ccfd99 

bfba3f31 47d99bfb bfa8a00e 9bedd69f f3f30ffd f628fb75 a7fcfcc3 ff007d8a e67eccdf dd1f98a3 eccdfdd1 

f98a00e9 bedd69ff 003f30ff 00df628f b75a7fcf cc3ff7d8 ae67eccd fdd1f98a 3eccdfdd 1f98a00e 9bedd69f 

f3f30ffd f628fb75 a7fcfcc3 ff007d8a e67eccdf dd1f98a3 eccde83f 31401d37 dbad3fe7 e61ffbec 51f6eb4f 

f9f987fe fb15ccfd 99bd07e6 297eccdf dd1f98a0 0e97edd6 9ff3f30f fdf628fb 75a7fcfc c3ff007d 8ae67ecc 

dfdd1f98 a3eccdfd d1f98a00 e9bedd69 ff003f30 ff00df62 8fb75a7f cfcc3ff7 d8ae67ec cde83f31 47d99bfb 

a3f31401 d37dbad3 fe7e61ff 00bec51f 6eb4ff00 9f987fef b15ccfd9 9bfba3f3 147d99bf ba3f3140 1d37dbad 

3fe7e61f fbec51f6 eb4ff9f9 87fefb15 cd7d99bf ba3f3149 f666fee8 fcc50074 df6eb4ff 009f987f efb147db 

ad3fe7e6 1ffbec57 33f666fe e8fcc51f 666feefe a2803a75 bcb56385 b8889f40 e2a60411 906b9236 cd8fbbfa 

d2c33dc5 9b7ee5ca e3f84f4f ca803ada 2a8e9da8 25ea107e 5957ef2f f51ed57a 800a28a2 80109c0c d72b7970 

6f2eda4c e541c20f 6ae8ef9c a5a4cc3a 8427f4ae 5a100628 0275c20e 3af73464 9ea68a28 00a29296 800e68e6 

8a2800a2 8a2800fc 68a28a00 28a4a5a0 028a4a28 0168a292 80168a4a 5a0028a2 8a0028a2 8a0039f5 a52430c3 

7e06928a 008e391e d675993a a9e9ea3b 8aeae291 658d5d4e 430c835c 9cb5d068 cc5b4e8b 3d811f91 22802fd1 

45140153 51ff008f 19ff00eb 9b7f2ae6 a2ed5d2e a5ff001e 33ff00d7 36fe55cc c5401351 45140051 4945002d 

14514005 14514005 14946680 168a4cd2 6e1400ea 29bb87ad 2eea005a 29334500 2d1494b4 00514514 00514514 

00514514 011cb5bb a27fc83e 3fc7f99a c296b774 4ff907c7 f53fccd0 06951451 4015352f f8f19ffe b9b7f2ae 

662ae9b5 2ff8f19f feb9b7f2 ae662a00 968a4a5a 0028a4a2 80168a4a 28016834 84e2a6b3 b396f1fe 4f9507de 

73fd2802 11962154 1627a003 26af5be9 37128065 2221e879 35ad6b67 0daae235 f9bbb1ea 6ac50067 c7a3db27 

df2f21f7 381fa54e ba7da01f f1ef19fa 8cd59a69 9635382e a3ea6802 03a7da11 ff001ef1 8fa2e2a1 9348b57f 

ba1a33fe cb7f8d5c 13447a48 87fe0429 f401873e 8f320cc2 e241e878 354183c6 db24528c 3b118aea ea2b8b68 

ae536ca8 08ec7b8f a5007339 a2ac5f58 4966770f 9e1fef77 1f5aac0e 680168a2 8a0028a2 9280168a 29280192 

d6f689ff 0020f8fe a7f99ac1 92b7b44f f907c7f5 3fccd006 95145140 15352ff8 f19ffeb9 b7f2ae62 2ae9f52f 

f8f19ffe b9b7f2ae 622a0096 8a4a2801 68a4a280 1690d148 0348eb1a 0cb31c01 40162c6d 1af26db9 c46bf7db 

fa574714 69146111 42a81c01 515a5bad adbac4bd ba9f5353 92154963 803a9340 01200c93 802b32e7 57018c76 

89e637f7 cfdd1fe3 556eeede fe42884a db838f77 ff00eb51 1a2a2e00 a9723a21 4afab18d f69b8399 a77c7f75 

4e0520b3 8fb8c9f5 353e68cd 4dcd9452 20365176 5c52aa4f 01cc13ba fb139153 668cd170 714c96df 57746097 

898ffa68 bd3f115a 88eb2207 460ca790 45623287 1c8a8e09 e4d3e4ca 7cd093f3 27f514d4 8c6747aa 3a0650ca 

430c83d4 1ae7b52b 236926f8 c7ee58f1 fec9f4ad f8e449a3 5910e558 641a4962 49a368dc 655860d5 9ce72e0e 

68a59a26 b6b8785f aa9ebea3 b1a6d002 d1494500 2d149450 0324aded 13fe41f1 fd5bf99a c192b7f4 4ff907c7 

f56fe668 034a8a28 a00a9a9f fc78cfff 005cdbf9 572f1575 1a9ffc78 4fff005c dbf9572f 1d004b45 251400b4 

52514001 ad0d0e0d f3bcec38 4185fa9a cd63815d 0e931f97 a745c72f f39fc7ff 00ad4017 4726b2f5 9b924ada 

21ebcb9f 6ec2b4f2 154b13c0 1cd736ae 669e499b abb67fc2 a64ec8da 8c39a44f 1a851802 9d9a6668 cd6676d8 

7e68cd33 346680b0 fcd19a66 68cd0161 f9a6b00c 39a4cd19 a02c4da5 5c1b7b9f b331fddc 9cafb1f4 ad93c1ae 

6ae32007 53865390 6ba18651 35bc728f e200d691 671d6872 bb99baec 198d2e14 72a76b7d 0d648391 5d2ddc5e 

75a4b1ff 00794e3e bdab9843 95aa301f 45251400 b452519a 006c95bd a1ff00c8 3e3fab7f 33581256 fe87ff00 

20f8fead ff00a11a 00d3a28a 28029ea7 ff001e13 ff00d736 fe55cbc7 5d46a7ff 001e13ff 00d736fe 55cbc740 

12514514 0052d251 400c9490 a71e95d5 c2a1208d 47f0a815 c94bf70f d2bad560 63523b81 4011deb9 4b19d81e 

429ac080 e12b7350 e74f9ffd dae7d0e0 715133b7 0aaf72ce ea37541b 8d2ee350 75f293ee a37541bc d1bcd01c 

a4fba8dd 506f346f 34072936 ea37543b 8d26e340 72924ad9 4ad8d218 b69c993f 74902b09 98915b5a 3f1a70ff 

0078d544 e5c4ab24 5feb5c99 1b25917f baec3f23 5d58ae52 420dccc4 77918fea 6b43845a 28a2800a 28a28019 

25741a17 fc83a3fa b7fe846b 9f92ba0d 0bfe41f1 fd5bff00 423401a7 45145005 3d4ffe3c 27ff00ae 6dfcab96 

8eba9d4f fe3c27ff 00ae6dfc ab968e80 24a2928a 005a2928 a006b8c8 ae974f93 cdd3e06f f6003f51 c5736dd2 

b5f40981 864809e5 0ee1f434 01a52287 8dd0ff00 12915cc2 e54953d4 1c1aea1b 8ac2d520 30dd79aa 3e4939fc 

7bd4491d 1879f2ca c56a2933 45667a37 168a4a28 0b8b4525 1405c5a2 928cd017 11ce16ba 2b28cc56 71211ced 

c9fc6b0e ca037374 aa47c8bc b7d2ba21 c9ad22ba 9c1899dd d824711c 4ee7a2a9 26b938f2 464f53c9 adfd6a6f 

2ac0a03f 34a768fa 77ac15e0 559ca3e8 a4a28017 34525140 0d7ae874 2ff907c7 f56ffd08 d73cf5d0 e85ff20e 

8feadffa 11a00d3a 28a28029 ea7ff1e1 3ffd736f e55cac75 d56a7ff1 e13ffd73 6fe55caa 5003e969 28a00296 

928a000d 3ed2e0da 5da4dd87 0c3da994 d619a00e b32aea19 4e548c82 2abdcc2b 3c4d1bf4 3d0fa1ac ed1aff00 

6e2d263c 7fcb363f cab61968 04ec7332 c6f04a63 90608fd6 9335bb73 6d1dc26d 9074e8c3 a8ac6b8b 49ad8e48 

de9fde1f d6b3713b 69d74f46 47453036 69d9a93a 3993168a 4cd216c5 01cc8752 00d23844 1b98f402 9f05bcd7 

27f76bf2 f763d056 c5a59c76 c3e5f99c f56354a3 730a9592 d10fb2b6 16d0ec07 2c7963ef 57145314 567eb17e 

21436d11 fde30f98 8fe11fe3 5a1c4ddd dd99fa9d d0bbbd25 4e638fe5 5f7f5355 c714c418 14fa042d 25145002 

d1494500 35eba2d0 bfe41d1f d5bff423 5cebd743 a17fc83a 3fab7fe8 46803528 a28a00a7 a9ff00c7 84ff00f5 

cdbf9572 895d5ea7 ff001e13 ff00d736 fe55ca25 003e8a28 a0028a28 a0028345 1400c65a d7d3b560 4082e8e0 

f4590f7f ad651a6b 2e6803ac 65c8e2a3 208ae7ed 3519ecc6 d07cc8ff 00b8ddbe 9e95af6f aa5acfc1 6f29ff00 

baff00e3 4004b656 d29cb440 1f55e2a0 3a4c24f1 2c8bed8c d69050c3 2a4107b8 a361a564 52935b33 306910e7 

99a43f80 a9e3b0b5 8cf116e3 eae73573 61a5da00 e68b2073 6fa8c038 e071e952 2a5559f5 1b4b6183 26f6feea 

726b26ef 559ee414 8c7951fa 03c9fa9a 649a1a8e aab0030d b90f2f76 ecbffd7a c3e598b3 12c49c92 7a9a4550 

074a78e2 80147145 14500145 14500145 1450035e ba2d0bfe 41d1fd5b ff004235 cebd745a 17fc83a3 fab7fe84 

6803528a 28a00a7a a7fc784f ff005cdb f957269d abacd53f e3c2e3fe b9b7f2ae 4d2801f4 51450014 5252d001 

45145001 45149400 100d34a8 3da9f494 00d46923 3fbb774f f75b153a dfdea0e2 e1ff001c 1a8a8c0a 0095b50b 

d61cdc37 e000a85d e597fd6c aeff00ef 3134b8a3 02801a10 0e829c00 1452d001 45145001 45149400 b4514500 

14514500 35aba3d0 bfe41d1f d5bff423 5ce35747 a0ff00c8 3a2fab7f e8468035 28a28a00 a7aa7fc7 84ff00f5 

cdbf9572 69dabadd 48136338 1ff3cdbf 957229d2 801f4525 1400b452 52d00145 251400b4 5251400b 45251400 

b4514500 14514940 0b452514 00b45251 400b4525 1400b452 51400b45 2514008d 5d2683ff 0020e8be adff00a1 

1ae6daba 5d0b8d3a 2fc7f99a 00d3a28a 280229d7 72104704 571d2c4d 04ef1375 53f98ed5 da30c8ac 6d574ff3 

ff007883 120fd680 30fad14d 21918ab8 2ac3a834 b9a005a2 93346680 168a4cd1 9a005a29 33466801 68a4cd19 

a005a293 34668016 8a4cd19a 005a2933 46680168 a4cd19a0 05a29334 6680168a 4cd19a00 5a293349 924e00c9 

3d00a005 c33b0551 9663802b aeb18843 6f1c63f8 540ac8d2 b4e64613 4c3e7fe1 1e9ffd7a de45c2d0 03e8a28a 

002a3910 30a928a0 0cdb9b18 e618740d fcea8b68 d0e78320 f606b7c8 069be58f 4a00c0fe c68bfbd2 7e63fc28 

fec68bfb d27e63fc 2b7fcb1e 947963d2 80303fb1 a2fef49f 98ff000a 3fb1a2fe f49f98ff 000adff2 c7a51e58 

f4a00c0f ec68bfbd 27e63fc2 8fec68bf bd27e63f c2b7fcb1 e947963d 280303fb 1a2fef49 f98ff0a3 fb1a2fef 

49f98ff0 adff002c 7a51e58f 4a00c0fe c68bfbd2 7e63fc28 fec68bfb d27e63fc 2b7fcb1e 947963d2 80303fb1 

a2fef49f 98ff000a 3fb1a2fe f49f98ff 000adff2 c7a51e58 f4a00c0f ec68bfbd 27e63fc2 8fec68bf bd27e63f 

c2b7fcb1 e947963d 280303fb 1a2fef49 f98ff0a3 fb1a2fef 49f98ff0 adff002c 7a51e58f 4a00c0fe c68bfbd2 

7e63fc28 fec68bfb d27e63fc 2b7fcb1e 947963d2 80303fb1 a2fef49f 98ff000a 3fb1a2fe f49f98ff 000adff2 

c7a51e58 f4a00c11 a3459e5a 43f8d5cb 6d3e2879 4400faf7 ad2f2c52 85028019 1c61474a 92968a00 28a28a00 

28a28a00 28a28a00 28a28a00 28a28a00 28a28a00 28a28a00 28a28a00 28a28a00 28a28a00 28a28a00 28a28a00 

28a28a00 28a28a00 28a28a00 28a28a00 ffd9

1 个答案:

答案 0 :(得分:0)

在iPhone中集成WCF REST服务时,您可以尝试以下方式,就像我在我的一个项目中实现的那样。

将NSDATA获取到字符串属性或变量。将此字符串用作Base64字符串并将其转换为图像并将其保存到您的目录中。

public void Base64ToImage(string imageString)
{

   // Convert Base64 String to byte[]
   byte[] imageBytes = Convert.FromBase64String(imageString);
   MemoryStream ms = new MemoryStream(imageBytes, 0,
   imageBytes.Length);

   // Convert byte[] to Image
   ms.Write(imageBytes, 0, imageBytes.Length);
   System.Drawing.Image image = System.Drawing.Image.FromStream(ms, true);
   image.Save("Base64ToImage.png"); //Specify your filename here
}