画像をバイトに変換してストリームに送信し、入力ストリームからバイトを受け取り、そのバイトを再度画像に変換する方法は?
9897 次
3 に答える
7
画像からバイトを取得する場合:
NSData *imageData = UIImageJPEGRepresentation(image, imageQuality);
バイトから画像を取得する場合:
UIImage *image = [UIImage imageWithData: imageData];
ところで、NSData からのバイトが必要な場合は、bytes メソッドを呼び出すだけです。
于 2012-09-04T06:07:01.880 に答える
1
UIImage
バイト配列へ
UIImage *image = [UIImage imageNamed:@"image.png"];
NSData *data = UIImagePNGRepresentation(image);
NSString *byteArray = [data base64Encoding];
バイト配列UIImage
+ (UIImage *)imageWithData:(NSData *)data;
NSData *data = [NSData dataWithBytes:YOUR_BYTE_ARRAY length:ARRAY_LENGTH];
UIImage *img = [UIImage imageWithData:data];
UIImageView *imgView = [[UIImageView alloc]initWithImage:img];
あなたが解決策を見つけたことを願っています。
于 2012-09-04T06:18:39.650 に答える
1
次のように画像をバイトに変換します。
NSData *imageData = UIImagePNGRepresentation(yourImage.image);
NSUInteger len = [imageData length];
Byte *byteData= (Byte*)malloc(len);
[imageData getBytes:byteData length:len];
次のようにイメージにバイトします。
NSData *pictureData = [NSData dataWithBytes:byteData];
UIImage *image = [[UIImage alloc]initWithData:pictureData];
于 2012-09-04T06:09:28.970 に答える