Microsoft Windows Phone 8.1 support ends (13 Jul 2017)

Microsoft has ended support for Windows Phone 8.1

Questions about iOS development and PDF

Adding image after moving UIImageView

More
9 years 7 months ago #10754 by Shades
Hi,
I am trying to add an UIImage after moving its UIImageView to some position but I have a crash on a
Code:
addAnnotBitmap
and I think I am doing things wrong.
Code:
- (NSData *)vAddImage:(NSData *)data frame:(CGRect)frame path:(NSString *)path page:(int)p { struct PDFV_POS pos1; struct PDFV_POS pos2; m_cur_page = p; [m_view vGetPos:&pos1 :(frame.origin.x - self.contentOffset.x) * m_scale :(frame.origin.y - self.contentOffset.y) * m_scale]; [m_view vGetPos:&pos2 :(frame.origin.x - self.contentOffset.x +frame.size.width) * m_scale :(frame.origin.y - self.contentOffset.y + frame.size.height) * m_scale]; _rect.left = pos1.x; _rect.right = pos2.x; _rect.top = pos1.y; _rect.bottom = pos2.y; NSString *tp = NSTemporaryDirectory(); tp = [tp stringByAppendingPathComponent:@"cache.dat"]; [m_doc setCache:tp]; PDFPage *page = [m_doc page:m_cur_page]; CGImageRef ref = [UIImage imageWithData:data].CGImage; [page addAnnotBitmap:ref :YES :&_rect]; [m_view vRenderSync:m_cur_page]; [self refresh]; [m_doc save]; NSData *pdfData = [[NSFileManager defaultManager]contentsAtPath:path]; return pdfData; }

where "Frame " is the frame of UIImageView after moving it.

Also I would like to know How to get the real coordinates according to the PDFView,I am doing something like when moving the UIIMageView in
Code:
touchesMoved:
Code:
PDFVPage *vpage = [m_view vGetPage:0]; [vpage GetWidth]; [vpage GetHeight]; [vpage GetVX:[m_view vGetX]]; [vpage GetVY:[m_view vGetY]]; float x =([vpage GetWidth] *(frame.origin.x *m_scale)/[vpage GetWidth])+self.contentOffset.x +50; float y =([vpage GetHeight] *(frame.origin.y *m_scale)/[vpage GetHeight])+self.contentOffset.y +5;

I would appreciate any help.
Thank you
More
9 years 7 months ago - 9 years 7 months ago #10765 by emanuele
Hi,

to get pdf coordinates, for example from a CGPoint, you should simply use:
Code:
[m_view vGetPos:&pos :point.x * m_scale :point.y * m_scale];
without adding contentoffsets.
For CGRect is the same, you have to PDFV_POS from rect.x and rect.y, then create the PDF_RECT with something like:
Code:
PDF_RECT rect; rect.left = pos.x; rect.right = pos.x + cgrect.width; rect.top = pos.y; rect.bottom = pos.y + cgrect.height;
Last edit: 9 years 7 months ago by emanuele.
More
9 years 7 months ago #10766 by Shades
Thank you for your reply.

But PDF_RECT doesn't get rect.width has only 4 properties ( left/right/bottom/top) ?
More
9 years 7 months ago #10767 by emanuele
sorry, I've updated the answer: rect is PDF_RECT, cgrect is your imageview frame (CGRect)
More
9 years 7 months ago #10769 by Shades
I got the point.Thank you.

But How could I convert PDF_RECT to CGRect ?

Thank you
Time to create page: 0.597 seconds
Powered by Kunena Forum