成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

iPhone圖形開發繪圖教程

移動開發 iOS
本文主要是來介紹iPhone應用中圖形開發繪圖的使用,文中很詳細的介紹了關于繪圖如何來使用,吸納來看詳細內容。

iPhone圖形開發繪圖教程是本文要介紹的內容,介紹了很多關于繪圖類的使用,先來看詳細內容講解。

1、繪圖總結:

繪圖前設置:

  1. CGContextSetRGBFillColor/CGContextSetFillColorWithColor  //填充色   
  2. CGContextSetRGBStrokeColor/CGContextSetStrokeColorWithColor //筆顏色   
  3. CGContextSetLineWidth   //線寬度  

繪圖后設置:

注:  畫完圖后,必須 先用CGContextStrokePath來描線,即形狀,后用CGContextFillPath來填充形狀內的顏色.

2.常見圖形繪制:

  1. CGContextFillRect/CGContextFillRects   
  2. CGContextFillEllipseInRect   
  3. CGContextAddRect/CGContextAddRects   
  4. CGContextAddEllipseInRect   
  5. CGContextAddLines   
  6. CGContextMoveToPoint   
  7. CGContextAddLineToPoint  

3.常見控制方法:

  1. CGContextSaveGState   
  2. CGContextRestoreGState  

4.創建內存圖像context:

  1. CGBitmapContextCreate       <-----CGContextRlease釋放   
  2. CGColorSpaceCreateWithName    (KCGColorSpaceGenericRGB)   
  3. CGColorSpaceRlease   
  4. CGBitmapContextCreateImage()   <-----CGImageRlease 釋放.   
  5. eg:   
  6. CGContextRefMyCreateBitmapContext(intpixelsWide,intpixelsHigh)   
  7. {   
  8. CGContextRef    context=NULL;   
  9. CGColorSpaceRefcolorSpace;   
  10. void*          bitmapData;   
  11. int             bitmapByteCount;   
  12. int             bitmapBytesPerRow;   
  13. bitmapBytesPerRow   =(pixelsWide*4);   
  14. bitmapByteCount     =(bitmapBytesPerRow*pixelsHigh);   
  15. colorSpace=CGColorSpaceCreateDeviceRGB();   
  16. bitmapData=malloc(bitmapByteCount);   
  17. if(bitmapData==NULL)   
  18. {   
  19. fprintf(stderr,"Memorynotallocated!");   
  20. returnNULL;   
  21. }   
  22. context=CGBitmapContextCreate(bitmapData,   
  23.  pixelsWide,    pixelsHigh,    8,    
  24. bitmapBytesPerRow,    colorSpace,   
  25.  kCGImageAlphaPremultipliedLast);   
  26. if(context==NULL)   
  27. {   
  28. free(bitmapData);   
  29. fprintf(stderr,"Contextnotcreated!");   
  30. returnNULL;   
  31. }   
  32. CGColorSpaceRelease(colorSpace);   
  33. returncontext;   
  34. }  

5.圖形的變換:

  1. CGContextTranslateCTM   
  2. CGContextRotateCTM   
  3. CGContextScaleCTM  

6.常用函數:

  1.   CGRectContainsPoint();   
  2. CGRectContainsRect();   
  3. CGRectIntersectsRect();   
  4. CGRectIntersection();   
  5. CGPointEqualToPoint();   
  6. CGSizeEqualToSize();  

7.從原圖片中取小圖.

  1. CGImageCreateWithImageInRect  

8.屏幕快照:

  1. #import "QuartzCore/QuartzCore.h"   
  2.  
  3. UIGraphicsBeginImageContext(yourView.frame.size);   
  4. [[yourView layer] renderInContext:UIGraphicsGetCurrentContext()];   
  5. UIImage*screenshot =UIGraphicsGetImageFromCurrentImageContext();   
  6. UIGraphicsEndImageContext();   
  7. from:http://www.cppblog.com/zhangyuntaoshe/articles/123066.html  

合并兩張bit圖到一張image的方法

  1. To graphically merge two images into a new image, you do something like this:   
  2. UIImage *result = nil;   
  3. unsignedchar *data = calloc(1,size.width*size.height*kBytesPerPixel);   
  4. if (data != NULL) {   
  5. // kCGImageAlphaPremultipliedLast 為預記錄的#define value   
  6. // 設置context上下文   
  7. CGContextRef context = CGBitmapContextCreate(   
  8. data, size.width, size.height, 8, size.width*kBytesPerPixel,   
  9. CGColorSpaceCreateDeviceRGB(), kCGImageAlphaPremultipliedLast);   
  10. if (context != NULL) {   
  11. UIGraphicsPushContext(context);   
  12. //  Image 為下載的背景圖片,用于比較context   
  13. CGContextTranslateCTM(context, 0, size.height);   
  14. CGContextScaleCTM(context, 1, -1);   
  15. [image drawInRect:imageRect];   
  16. [image2 drawInRect:image2Rect];   
  17. UIGraphicsPopContext();   
  18. CGImageRef imageRef = CGBitmapContextCreateImage(context);   
  19. if (imageRef != NULL) {   
  20. result = [UIImageimageWithCGImage:imageRef];   
  21. CGImageRelease(imageRef);   
  22. }   
  23. CGContextRelease(context);   
  24. }   
  25. free(data);   
  26. }   
  27. return result;  

關鍵方法: 

  1. CGContextRef context = CGBitmapContextCreate();   
  2. CGContextTranslateCTM();   
  3. CGContextScaleCTM();   
  4. CGImageRef imageRef = CGBitmapContextCreateImage(context);   
  5. CGImageRelease(imageRef); 

小結:iPhone圖形開發繪圖教程的內容介紹完了,希望本文對你有所幫助!

責任編輯:zhaolei 來源: 互聯網
相關推薦

2011-08-10 15:48:10

iPhone網絡

2011-07-08 14:58:16

iPhone Xcode iOS

2011-07-08 16:02:24

iphone

2011-08-02 17:37:01

IPhone開發 環境搭建

2011-07-25 17:13:31

iPhone 圖形 動畫

2011-07-18 09:35:29

iPhone 框架

2011-08-09 13:10:32

iPhone地圖開發

2011-07-21 10:29:18

iPhone 開發

2011-07-27 17:24:31

iPhone NSXMLParse XML

2011-08-08 18:19:09

iPhone音頻播放

2011-08-10 10:23:20

iPhoneArchivingNSCoder

2011-08-16 10:01:02

2011-08-22 12:01:38

iPhone開發文件

2011-07-18 12:29:10

2011-07-18 11:23:29

iPhone 游戲 動畫

2011-07-18 11:39:58

iPhone 游戲 引擎

2011-07-27 16:46:04

iPhone iPhone破解 MacPort

2011-08-12 10:09:23

iPhone開發多線程

2011-07-18 10:53:09

2011-08-15 11:31:27

iPhone開發日志
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 激情91 | 91精品国产91久久久久久丝袜 | 91亚洲国产 | 九九久久免费视频 | 国产精品一区二区三级 | 精品欧美一区免费观看α√ | 国产欧美一区二区精品忘忧草 | 亚洲精品视频免费看 | 日本一区二区三区免费观看 | 亚洲va在线va天堂va狼色在线 | 久久久久国 | 欧美激情视频一区二区三区在线播放 | 精品国产91乱码一区二区三区 | 久久免费视频在线 | 少妇特黄a一区二区三区88av | 一区二区三区四区不卡 | 国产成人精品免费 | 国产日产欧产精品精品推荐蛮挑 | 午夜小视频免费观看 | 国产一区二区三区精品久久久 | 亚洲国产一区二区三区在线观看 | 请别相信他免费喜剧电影在线观看 | 久久久夜夜夜 | 中文字幕一区在线观看视频 | 亚洲综合在线播放 | 国产亚洲网站 | 国产成人免费视频网站高清观看视频 | 亚洲国产一区二区视频 | 久久99精品久久久久久 | 一区二区视频 | 精品国产91久久久久久 | 亚洲欧洲日韩精品 中文字幕 | 成人影院午夜 | 欧美成人a | 国产在线精品一区二区三区 | 天天干天天插天天 | 在线播放国产一区二区三区 | 一级片在线观看 | 凹凸日日摸日日碰夜夜 | 亚洲精品欧美一区二区三区 | 日韩中文字幕网 |