Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 10-21-2011, 03:27 PM   #13 (permalink)
yunas
Registered Member
 
Join Date: Mar 2010
Posts: 13
yunas is on a distinguished road
Default provide the reference

for me it seems not to pass the center x and y instead pass the screen portion/coords (x,y,w,h) you want to crop and then skew.


Ah, i just went through the blog where this code was posted...
Well for you,
http://iphonedevelopment.blogspot.co...part-6_25.html
try this blog... It will teach/guide you on how to blend an image... plus the author has pasted his code as well...
Happy coding






Quote:
Originally Posted by sindhutiwari View Post
I need to crop a image into irregular shape and deskew .

I have used this

Can some one please tell me the parameters which i need to pass here .. i mean to say what is X and Y here ??

i have passed center.x and center.y of the image and it resulted in a blank screen.


Code:
(void)compute_transform_matrix:(float)X:(float)Y:(float)W:(float)H:(float)x1a:(float)y1a:(float)x2a:(float)y2a:(float)x3a:(float)y3a:(float)x4a:(float)y4a
{
	float y21 = y2a - y1a, 
	y32 = y3a - y2a,
	y43 = y4a - y3a,
	y14 = y1a - y4a,
	y31 = y3a - y1a,
	y42 = y4a - y2a;
	
    float a = -H*(x2a*x3a*y14 + x2a*x4a*y31 - x1a*x4a*y32 + x1a*x3a*y42);
    float b = W*(x2a*x3a*y14 + x3a*x4a*y21 + x1a*x4a*y32 + x1a*x2a*y43);
    float c = H*X*(x2a*x3a*y14 + x2a*x4a*y31 - x1a*x4a*y32 + x1a*x3a*y42) - H*W*x1a*(x4a*y32 - x3a*y42 + x2a*y43) - W*Y*(x2a*x3a*y14 + x3a*x4a*y21 + x1a*x4a*y32 + x1a*x2a*y43);
	
    float d = H*(-x4a*y21*y3a + x2a*y1a*y43 - x1a*y2a*y43 - x3a*y1a*y4a + x3a*y2a*y4a);
    float e = W*(x4a*y2a*y31 - x3a*y1a*y42 - x2a*y31*y4a + x1a*y3a*y42);
    float f = -(W*(x4a*(Y*y2a*y31 + H*y1a*y32) - x3a*(H + Y)*y1a*y42 + H*x2a*y1a*y43 + x2a*Y*(y1a - y3a)*y4a + x1a*Y*y3a*(-y2a + y4a)) - H*X*(x4a*y21*y3a - x2a*y1a*y43 + x3a*(y1a - y2a)*y4a + x1a*y2a*(-y3a + y4a)));
	
    float g = H*(x3a*y21 - x4a*y21 + (-x1a + x2a)*y43);
    float h = W*(-x2a*y31 + x4a*y31 + (x1a - x3a)*y42);
    float i = W*Y*(x2a*y31 - x4a*y31 - x1a*y42 + x3a*y42) + H*(X*(-(x3a*y21) + x4a*y21 + x1a*y43 - x2a*y43) + W*(-(x3a*y2a) + x4a*y2a + x2a*y3a - x4a*y3a - x2a*y4a + x3a*y4a));
	
	CATransform3D skewTransform;
	skewTransform.m11 = a;
	skewTransform.m12 = b;
	skewTransform.m13 = 0;
	skewTransform.m14 = c;
	skewTransform.m21 = d;
	skewTransform.m22 = e;
	skewTransform.m23 = 0;
	skewTransform.m24 = f;
	skewTransform.m31 = 0;
	skewTransform.m32 = 0;
	skewTransform.m33 = 1;
	skewTransform.m34 = 0;
	skewTransform.m41 = g;
	skewTransform.m42 = h;
	skewTransform.m43 = 0;
	skewTransform.m44 = i;
	
	imgImage.layer.transform = skewTransform;
}

Last edited by yunas; 10-21-2011 at 03:39 PM.
yunas is offline   Reply With Quote
 

» Advertisements
» Online Users: 440
14 members and 426 guests
aqlucky, diane21, elhanche, freewind, guillermotricia, hrushikeshaddon, iOS.Lover, iram91418, jeroenkeij, LunarMoon, nicsmotherman, poke, ryantcb, Viekiehug
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,610
Threads: 94,084
Posts: 402,790
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Viekiehug
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:56 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.