Results 1 to 22 of 22

Thread: Why FillPath is Different Result in PictureBox and PrintDocument ?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2018
    Posts
    77

    Why FillPath is Different Result in PictureBox and PrintDocument ?

    ....
    Last edited by Nicomendox; May 16th, 2020 at 07:58 PM.

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Why FillPath is Different Result in PictureBox and PrintDocument ?

    I haven’t yet had a good look at your code, but I can guess the problem. The printed page has margins which limit the area you can draw in. I’ll have another look on my workstation now...

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Why FillPath is Different Result in PictureBox and PrintDocument ?

    I stand by what i said...

    BTW... CDec(10) is equal to 10D

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Nov 2018
    Posts
    77

    Re: Why FillPath is Different Result in PictureBox and PrintDocument ?

    Quote Originally Posted by .paul. View Post
    I haven’t yet had a good look at your code, but I can guess the problem. The printed page has margins which limit the area you can draw in. I’ll have another look on my workstation now...
    Did You Try To Test My code in a Form ? or you talk only about Codes in my Question ?

    Put a Picturebox and 2 Button and a PrintDocument and PrintPreviewDialog into a FORM...

    Then copy paste my code

    With Button1 Call Printdocument PrintPage.

    then dont you see anything when Debug codes ?

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Nov 2018
    Posts
    77

    Re: Why FillPath is Different Result in PictureBox and PrintDocument ?

    ....
    Last edited by Nicomendox; May 7th, 2020 at 06:47 PM. Reason: Doublicated my Reply...

  6. #6
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Why FillPath is Different Result in PictureBox and PrintDocument ?

    Try this...

    Code:
    Private Sub PrintDocument2_PrintPage(sender As Object, e As PrintPageEventArgs) Handles PrintDocument2.PrintPage
    
        Dim newImage As Image = Drawing.Image.FromFile("C:\Users\Yaman\Desktop\Frames\384.jpg")
        Dim imaj As Bitmap = New Bitmap("C:\Users\Yaman\Desktop\Frames\384.jpg")
        Dim grpX As Graphics = e.Graphics 
    
        Dim rectX As Rectangle = New Rectangle(e.MarginBounds.Left + 10, e.MarginBounds.Top + 10, 200, 100)
        Dim tg As Graphics = Graphics.FromImage(imaj) 
        tg.SmoothingMode = SmoothingMode.AntiAlias
        grpX.SmoothingMode = SmoothingMode.AntiAlias
        tg.DrawImage(newImage, 10, 10, 200, 100)        
        Dim TBrush As New TextureBrush(imaj)
        Dim gp As New GraphicsPath
        gp = createRoundRect(rectX, 12)
        grpX.FillPath(TBrush, gp)
    
    End Sub

  7. #7
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Why FillPath is Different Result in PictureBox and PrintDocument ?

    tg.DrawImage(newImage, 10, 10, 200, 100)

    That should probably be 0, 0, 200, 100

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Nov 2018
    Posts
    77

    Re: Why FillPath is Different Result in PictureBox and PrintDocument ?

    ....
    Last edited by Nicomendox; May 16th, 2020 at 08:04 PM.

  9. #9
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Why FillPath is Different Result in PictureBox and PrintDocument ?

    What is the size of the picturebox?

  10. #10
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Why FillPath is Different Result in PictureBox and PrintDocument ?

    And the 2 images you’re loading. What size are they?
    What is your picturebox SizeMode?

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Nov 2018
    Posts
    77

    Re: Why FillPath is Different Result in PictureBox and PrintDocument ?

    384.Jpg size is 1024x697

    I don't change any size mode. Keep as default.

  12. #12
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Why FillPath is Different Result in PictureBox and PrintDocument ?

    So what size is the picturebox???

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Nov 2018
    Posts
    77

    Re: Why FillPath is Different Result in PictureBox and PrintDocument ?

    Picturebox size is not important. But size is 600x600

    I just onlt try to fillPath as I could do in Picturebox

    Even PictureBox Size 700x400 or 500x300 or any size Same Result. I just wonder why code is working in PictureBox but not work in Printdocument...

  14. #14
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Why FillPath is Different Result in PictureBox and PrintDocument ?

    Code:
    Private Sub PrintDocument2_PrintPage(sender As Object, e As PrintPageEventArgs) Handles PrintDocument2.PrintPage
    
        Dim newImage As New Bitmap("C:\Users\Yaman\Desktop\Frames\384.jpg", 200, 100)
        Dim imaj As New Bitmap("C:\Users\Yaman\Desktop\Frames\384.jpg", 200, 100)
        Dim grpX As Graphics = e.Graphics 
    
        Dim rectX As Rectangle = New Rectangle(e.MarginBounds.Left + 10, e.MarginBounds.Top + 10, 200, 100)
        Dim tg As Graphics = Graphics.FromImage(imaj) 
        tg.SmoothingMode = SmoothingMode.AntiAlias
        grpX.SmoothingMode = SmoothingMode.AntiAlias
        tg.DrawImage(newImage, 10, 10, 200, 100)        
        Dim TBrush As New TextureBrush(imaj)
        Dim gp As New GraphicsPath
        gp = createRoundRect(rectX, 12)
        grpX.FillPath(TBrush, gp)
    
    End Sub

  15. #15
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Why FillPath is Different Result in PictureBox and PrintDocument ?

    BTW picturebox size is important - more than you think. particularly if you have SizeMode set to stretch

  16. #16

    Thread Starter
    Lively Member
    Join Date
    Nov 2018
    Posts
    77

    Re: Why FillPath is Different Result in PictureBox and PrintDocument ?

    ....
    Last edited by Nicomendox; May 16th, 2020 at 08:00 PM.

  17. #17

    Thread Starter
    Lively Member
    Join Date
    Nov 2018
    Posts
    77

    Re: Why FillPath is Different Result in PictureBox and PrintDocument ?

    Paul thank you for your effort to find Solution.

    Did you tried to code with any image in your computer ?

    if problem is in my Computer ?

  18. #18
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Why FillPath is Different Result in PictureBox and PrintDocument ?

    Code:
    Dim newImage As New Bitmap("C:\Users\Yaman\Desktop\Frames\384.jpg", 200, 100)
    Dim imaj As New Bitmap("C:\Users\Yaman\Desktop\Frames\384.jpg", 200, 100)
    Change those to...

    Code:
    Dim newImage As New Bitmap("C:\Users\Yaman\Desktop\Frames\384.jpg")
    newImage = New Bitmap(newImage, 200, 100)
    Dim imaj As New Bitmap("C:\Users\Yaman\Desktop\Frames\384.jpg")
    imaj = New Bitmap(imaj, 200, 100)

  19. #19
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Why FillPath is Different Result in PictureBox and PrintDocument ?

    Quote Originally Posted by Nicomendox View Post
    Paul thank you for your effort to find Solution.

    Did you tried to code with any image in your computer ?

    if problem is in my Computer ?

    I’m typing this freehand on my iPhone. It should work better now...

  20. #20

    Thread Starter
    Lively Member
    Join Date
    Nov 2018
    Posts
    77

    Re: Why FillPath is Different Result in PictureBox and PrintDocument ?

    ....
    Last edited by Nicomendox; May 16th, 2020 at 08:03 PM.

  21. #21
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Why FillPath is Different Result in PictureBox and PrintDocument ?

    Not sure of the cause of that. Getting some sleep now... it’s 03:30am

  22. #22

    Thread Starter
    Lively Member
    Join Date
    Nov 2018
    Posts
    77

    Re: Why FillPath is Different Result in PictureBox and PrintDocument ?

    So Sorry. and thanks a lot. God Bless you.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width