- Posts: 37
- Thank you received: 0
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
9 years 7 months ago #10754
by Shades
Adding image after moving UIImageView was created by Shades
Hi,
I am trying to add an UIImage after moving its UIImageView to some position but I have a crash on a
and I think I am doing things wrong.
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
I would appreciate any help.
Thank you
I am trying to add an UIImage after moving its UIImageView to some position but I have a crash on a
Code:
addAnnotBitmap
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
9 years 7 months ago - 9 years 7 months ago #10765
by emanuele
Replied by emanuele on topic Adding image after moving UIImageView
Hi,
to get pdf coordinates, for example from a CGPoint, you should simply use:
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:
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];
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.
9 years 7 months ago #10766
by Shades
Replied by Shades on topic Adding image after moving UIImageView
Thank you for your reply.
But PDF_RECT doesn't get rect.width has only 4 properties ( left/right/bottom/top) ?
But PDF_RECT doesn't get rect.width has only 4 properties ( left/right/bottom/top) ?
9 years 7 months ago #10767
by emanuele
Replied by emanuele on topic Adding image after moving UIImageView
sorry, I've updated the answer: rect is PDF_RECT, cgrect is your imageview frame (CGRect)
Time to create page: 0.597 seconds