Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
Questions about iOS development and PDF
  • Page:
  • 1

TOPIC:

Can't draw a point for annotation 7 years 7 months ago #11225

  • Shades
  • Shades's Avatar Topic Author
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 37
  • Thank you received: 0
Hello,

I have a strange issue.I can't draw a point it's always a line.The code below is for drawing .
-(void)drawInk:(CGContextRef)context
{
  if( m_status == sta_ink && m_ink )
    {
       
        NSLog(@"g_ink_color = %d",g_ink_color);
        int cnt = [m_ink nodesCount];
        int cur = 0;
        CGContextSetLineWidth(context, g_Ink_Width);
        float red = ((g_ink_color>>16)&0xFF)/255.0f;
        float green = ((g_ink_color>>8)&0xFF)/255.0f;
        float blue = (g_ink_color&0xFF)/255.0f;
        float alpha = ((g_ink_color>>24)&0xFF)/255.0f;
        CGContextSetRGBStrokeColor(context, red, green, blue, alpha);
        CGContextBeginPath( context );
        while( cur < cnt )
        {
            PDF_POINT pt;
            PDF_POINT pt2;
            int type = [m_ink node: cur: &pt];
            switch( type )
            {
                   
                case 1:
            
                    CGContextAddLineToPoint(context, self.contentOffset.x + pt.x/m_scale, self.contentOffset.y + pt.y/m_scale);
                    cur++;
                    break;
                case 2:
                    [m_ink node: cur + 1: &pt2];
                    CGContextAddCurveToPoint(context, self.contentOffset.x + pt.x/m_scale, self.contentOffset.y + pt.y/m_scale,
                                             self.contentOffset.x + pt.x/m_scale, self.contentOffset.y + pt.y/m_scale,
                                             self.contentOffset.x + pt2.x/m_scale, self.contentOffset.y + pt2.y/m_scale );
                    cur += 2;
                    break;
                default:
                   
                    CGContextMoveToPoint(context, self.contentOffset.x + pt.x/m_scale, self.contentOffset.y + pt.y/m_scale);
                    
                    cur++;
                    break;
            }
        }
        CGContextStrokePath( context );
    }
}

Thank you a lot for your help

Please Log in or Create an account to join the conversation.

Can't draw a point for annotation 7 years 6 months ago #11244

  • stronglee
  • stronglee's Avatar
  • Offline
  • Premium Member
  • Premium Member
  • Posts: 93
  • Thank you received: 2
Hi,
In PDF document ,there is no pixel concept. If you want draw a point,here is same way
1.Draw line ,end point value subtract start point value equal the point's diameter where you want to draw
2.Add a image ,the image is 1 pixel like a point

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Powered by Kunena Forum