Mac Read Andriod screenshot

Source: Internet
Author: User
Tags fread

intMainintargcConst Char*argv[]) {    //Insert code here ...            stringSTR3 ="/users/ethan/downloads/aaa/platform-tools/adb Shell Screencap-p"; Nsmutabledata*resultdata=[[Nsmutabledata alloc] init]; FILE* FStream =NULL; if(null== (Fstream=popen-str3.c_str (),"R")) {fprintf (stderr,"Execute command failed:%s", Strerror (errno)); returnNULL; } FILE*png = fopen ("/var/folders/_g/mmsygkld2sv2pl719654cscm0000gn/t/2.png","W"); Chartmp[1024x768];//store each line of outputsize_t all=0; size_t Readnum=fread (TMP,1,sizeof(TMP)-1, FStream);  while(readnum!=0)    {               if(tmp[readnum-1] ==0xd) {Tmp[readnum++] =fgetc (fstream); }                       for(unsignedinti =0; i < Readnum; ++i) {if(Tmp[i] = =0xd&& tmp[i+1] ==0xa) {Tmp[i]=0xa;  for(unsignedintj = i+1; J < Readnum-1; ++j) Tmp[j]= tmp[j+1]; Readnum--; }} All=all+Readnum; //Write to FileFwrite (TMP,1, Readnum, PNG); //put it directly into memory[Resultdata appendbytes:tmp length:readnum]; Readnum=fread (TMP,1,sizeof(TMP)-1, FStream); } nsimage*img=[[Nsimage alloc] initwithdata:resultdata]; NSLog (@"%f", Img.size.width); return 0;}

Mac Read Andriod screen

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.