2012-12-25 22 views
3

的形象已經繪就CGContextRef:如何移動圖像上的CGContextRef

CGContextDrawImage(context, CGRectMake(0, 0, width, height), image); 

在另一個功能,我想移動圖像的矩形狀

CGRectMake(100, 100, width, height); 

哪有我做?

void func(CGContextRef context)//there is just one parameter 
{ 
    //move the image 
} 

回答

0

試試這個

void func(CGContextRef context, CGFloat x, CGFloat y) 
{ 
    CGContextDrawImage(context, CGRectMake(x,y, width, height), image); 
} 
1

一旦你被它吸引了無法挽回的環境。您可以繪製上一張圖片,或許使用純色匹配背景。我不知道爲什麼你會想要繪製上下文,然後移動它。

我要去假設繪製圖像的第一功能調用定位它的第二個。如果是這樣的話,你可以有第二個功能,簡單地套用平移變換,上下文,然後讓第一函數調用第二後繪製圖像。