IOS automatically turns all 3 times times in a folder into a twice-fold graph program source code

Source: Internet
Author: User

If you develop iOS, sometimes it is too late to turn all three times times to twice times the graph, you can write a Mac version of the command-line gadget, automatically convert all three times-dimensional images under a folder into twice-fold images, and will [email protected] command [email Protected]. Of course there is the design of a piece of a cut out is also possible, here is just a quick way to provide

You can also modify the proportion of the inside, automatically cut out more sizes of pictures or support more functions

It is important to note that the Mac version of the crop also needs to consider whether the screen is a high-definition screen, the following are some of the main parts of the code:

<pre name= "code" class= "OBJC" >cgfloat scale = [Nsscreen mainscreen].backingscalefactor; NSLog (@ "scale:%f", scale); CGFloat scalefactor = 1.0/scale;//The following is the clip, you need to convert the size of the picture. Nssize newSize = nsmakesize (image.pixelswide * scalefactor * 2.0/3.0, Image.pixelshigh * scalefactor * 2.0/3.0);    Nsimage *newimage = [self resizeimage:image size:newsize];    NSData *outputdata= [NewImage tiffrepresentation]; Nsbitmapimagerep *imagerep = [Nsbitmapimagerep imagerepwithdata:outputdata]; Nsdictionary *imageprops = [nsdictionary dictionarywithobject:[nsnumber numberwithfloat:0.9] ForKey: Nsimagecompressionfactor]; NSData *data = [Imagerep representationusingtype:nspngfiletype properties:imageprops];    BOOL OK = [data Writetofile:newpath atomically:yes]; NSLog (@ "Save%@ ok:%@", NewPath, OK? @ "YES": @ "NO");

The new image in the code uses the PNG format, and if you need to use the JPEG format, you can download the code to modify it yourself.

Code:

http://download.csdn.net/detail/liyan223/8327709

How the code works:

clang++-o imageresizer main.mm-framework foundation-framework cocoa-framework Quartzcore./imageresizer Imagefolderpath
Of course, above is just one of the ways, you can also use the above code, you simply add a graphical interface



IOS automatically turns all 3 times times in a folder into a twice-fold graph program source code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.