Graphics State
Graphics State
Graphics State
Graphics State
Graphics State
Graphics State Graphics State Graphics State Graphics State Graphics State Graphics State Graphics State Graphics State
Graphics State Graphics State
Graphics State
Go Back  Xtreme Visual Basic Talk > > > Graphics State


Reply
 
Thread Tools Display Modes
  #1  
Old 07-16-2017, 10:05 PM
mms mms is offline
Ultimate Contributor
 
Join Date: Jul 2002
Location: Hamilton, Ontario
Posts: 1,859
Default Graphics State


I use this code to draw to Pdf,
It works exactly as I want except I realized when I changed the color of the lines drawn by GraphicsDrawLinesForPdf
the lines are drawn OVER the objects, I need them UNDER.

I thought I could just move the call to GraphicsDrawLinesForPdf BEFORE the call to GraphicsDrawObjectsForPdf

This doesn't work as now the lines are mirrored and not in the correct location
(they are under the objects however)

I'm wondering if another
Save current graphics state
and
Restore saved graphics state
inserted somewhere might do the trick, but I can't figure it out.

Any suggestions?

Code:
Public Sub DrawClipForPdf()

    'Save current graphics state
        pdfWriteObj " q"

    'Modify the current clipping path
        pdfWriteObj " W"

    'Define rect for clipping path
        pdfRectangle dstx, 792 - clipHeight - dsty, clipWidth, clipHeight, nil

    'no-op
        pdfWriteObj " n"

    ' Translate into clipping rectangle
        pdfWriteObj " 1 0 0 1 " & CStr((0)) & " " & CStr(300) & " cm"

    ' Scale due to PPI (pixels per inch) difference in PDF vs GDI+ (72/96 = 75%)
        pdfWriteObj " 0.72 0 0 0.72 0 0 " & " cm"

    ' Draw objects on PDF
        Call GraphicsDrawObjectsForPdf(0, dstx, dsty, srcx, srcy, clipWidth, clipHeight, i)

    ' Mirror about X-axis
        pdfWriteObj " 1 0 0 -1 0 0 " & " cm"
    
    ' Translate again to re-position mirrored graphic back into clipping rectangle
        pdfWriteObj " 1 0 0 1 " & CStr(0) & " " & CStr(-370) & " cm"
    
    ' Fill
        pdfWriteObj " f"

    ' Draw lines on PDF
        Call GraphicsDrawLinesForPdf(0, 0, i)

    ' Restore saved graphics state
        pdfWriteObj " Q"
    
End Sub
Reply With Quote
  #2  
Old 07-17-2017, 02:07 PM
passel's Avatar
passelGraphics State passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,026
Default

Assuming that is your existing code, I would think if you saved the graphics state before you call "draw objects", and then don't call "draw objects", but continue on and draw the lines, then restore the state to what you saved and draw your objects, it would draw correctly.
That seems like it would work if this was purely a GDIP drawing, but since you are writing pdf commands, I'm not sure. Is saving the state stacked based so you can do to "q" commands and have two saved states, then do two "Q" commands to undo the saved states?
I can only say what seems logical to me, not what I know, since I am not familiar with the functions involved, or pdf commands.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
Reply

Tags
pdfwriteobj, graphics, lines, call, pdf, clipping, clipheight, current, draw, objects, translate, restore, save, cstr0, mirrored, saved, rectangle, graphicsdrawlinesforpdf, path, dstx, drawn, clipwidth, dsty, pdfrectangle, cstr300


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Graphics State
Graphics State
Graphics State Graphics State
Graphics State
Graphics State
Graphics State Graphics State Graphics State Graphics State Graphics State Graphics State Graphics State
Graphics State
Graphics State
 
Graphics State
Graphics State
 
-->