HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了iphone – UIImage小中型大像苹果邮件大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
是否有任何参教程可以在小型或中型环境中获取图像大小.

我只是想知道根据宽度和高度计算图像大小,我们如何计算UIImage大小,当像小苹果邮件一样小,中等或大时.

这就像我们在Mail中附加图像时要求小,中,大..

Plz不提供this,因为我已经通过了这个..

提前致谢.

解决方法

最后从许多解决方案中看到我得到了以下解决方案并根据此完成了代码.

我们可以获得如下图像.

small = 320 pixels on longest edge JPEG
Medium = 640 pixels on longest edge JPEG
Large =  1296 pixels on longest edge JPEG

其中typeOfImage = 0,1,2分别为小型,中型和大型.

-(CGSizE)getImageWithRespectiveSize:(UIImage *)pImage withType:(NSInteger)typeOfImg
{
    CGSize pSize;
    if(typeOfImg == 0)
        pSize = [self getCGSizesOfImages:320 andImage:pImage];
    else if(typeOfImg == 1)
        pSize = [self getCGSizesOfImages:640 andImage:pImage];
    else if(typeOfImg == 2)
        pSize = [self getCGSizesOfImages:1296 andImage:pImage];
    else 
        pSize = CGSizeMake(pImage.size.width,pImage.size.height);

    return pSize;
}

-(CGSizE)getCGSizesOfImages:(NSInteger)pIntPixels andImage:(UIImage *)pImage
{
    CGSize pSize;
    if(pImage.size.width > pImage.size.height)
    {
        CGFloat tmp = pImage.size.height/pImage.size.width*pIntPixels;
        pSize = CGSizeMake(pIntPixels,tmp);
    }
    else if(pImage.size.width < pImage.size.height)
    {
        CGFloat tmp = pImage.size.width/pImage.size.height*pIntPixels;
        pSize =  CGSizeMake(tmp,pIntPixels);       
    }   
    else
    {
        CGFloat tmp = pImage.size.height/pImage.size.width*pIntPixels;
        pSize =  CGSizeMake(tmp,pIntPixels);       
    }
    return pSize;
}

调用这样的功能

CGSize size = [self getImageWithRespectiveSize:imgOriginal withType:0];

大佬总结

以上是大佬教程为你收集整理的iphone – UIImage小中型大像苹果邮件全部内容,希望文章能够帮你解决iphone – UIImage小中型大像苹果邮件所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。