2

サイズが 320X320 の imagview を使用して大きな画像 (350 X 783) を表示しています。

大きな画像をイメージビューに配置している間、画像は圧縮されたように見え、品質のものとは異なります。

私の質問は、元の画像と同じ品質で大きな画像を小さくするにはどうすればよいですか?

4

3 に答える 3

4

そのように、画像ビューを適切なコンテンツモードに設定できます

        imageView.contentMode = UIViewContentModeScaleAspectFit
于 2013-02-15T09:43:36.273 に答える
1
-(UIImage*)scaleToSize:(CGSize)size {
    // Create a bitmap graphics context
    // This will also set it as the current context
    UIGraphicsBeginImageContext(size);
    // Draw the scaled image in the current context
    [self drawInRect:CGRectMake(0, 0, size.width, size.height)];
    // Create a new image from current context
    UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext();
    // Pop the current context from the stack
    UIGraphicsEndImageContext();
    // Return our new scaled image
    return scaledImage;
}
于 2013-02-15T10:02:08.187 に答える
0

あなたはこのようにすることができます、

    UIImage* sourceImage = "yourImage";
    CGSize newSize=CGSizeMake(80,80);
    UIGraphicsBeginImageContext( newSize );
    [image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
    UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    yourImageView.image=newImage;
于 2013-02-15T09:54:58.253 に答える