private ImageRenderInfo(GraphicsState gs, PdfIndirectReference refi, PdfDictionary colorSpaceDictionary)
 {
     this.gs = gs;
     this.refi = refi;
     this.inlineImageInfo = null;
     this.colorSpaceDictionary = colorSpaceDictionary;
 }
Example #2
0
        public void SetControlValueTable(FUnit[] cvt, float scale, float ppem, byte[] cvProgram)
        {
            if (this.scale == scale || cvt == null)
                return;

            if (controlValueTable == null)
                controlValueTable = new float[cvt.Length];
            for (int i = 0; i < cvt.Length; i++)
                controlValueTable[i] = cvt[i] * scale;

            this.scale = scale;
            this.ppem = (int)Math.Round(ppem);
            zp0 = zp1 = zp2 = points;
            state.Reset();
            stack.Clear();

            if (cvProgram != null)
            {
                Execute(new InstructionStream(cvProgram), false, false);

                // save off the CVT graphics state so that we can restore it for each glyph we hint
                if ((state.InstructionControl & InstructionControlFlags.UseDefaultGraphicsState) != 0)
                    cvtState.Reset();
                else
                {
                    // always reset a few fields; copy the reset
                    cvtState = state;
                    cvtState.Freedom = Vector2.UnitX;
                    cvtState.Projection = Vector2.UnitX;
                    cvtState.DualProjection = Vector2.UnitX;
                    cvtState.RoundState = RoundMode.ToGrid;
                    cvtState.Loop = 1;
                }
            }
        }
 private ImageRenderInfo(GraphicsState gs, InlineImageInfo inlineImageInfo, PdfDictionary colorSpaceDictionary)
 {
     this.gs = gs;
     this.refi = null;
     this.inlineImageInfo = inlineImageInfo;
     this.colorSpaceDictionary = colorSpaceDictionary;
 }
Example #4
0
 /**
  * Creates a new TextRenderInfo object
  * @param text the text that should be displayed
  * @param gs the graphics state (note: at this time, this is not immutable, so don't cache it)
  * @param textMatrix the text matrix at the time of the render operation
  * @param markedContentInfo the marked content sequence, if available
  */
 internal TextRenderInfo(String text, GraphicsState gs, Matrix textMatrix, ICollection markedContentInfo) {
     this.text = text;
     this.textToUserSpaceTransformMatrix = textMatrix.Multiply(gs.ctm);
     this.gs = gs;
     this.markedContentInfos = new List<MarkedContentInfo>();
     foreach (MarkedContentInfo m in markedContentInfo) {
         this.markedContentInfos.Add(m);
     }
 }
Example #5
0
 public Interpreter(int maxStack, int maxStorage, int maxFunctions, int maxInstructionDefs, int maxTwilightPoints)
 {
     stack = new ExecutionStack(maxStack);
     storage = new int[maxStorage];
     functions = new InstructionStream[maxFunctions];
     instructionDefs = new InstructionStream[maxInstructionDefs > 0 ? 256 : 0];
     state = new GraphicsState();
     cvtState = new GraphicsState();
     twilight = new Zone(new PointF[maxTwilightPoints], isTwilight: true);
 }
Example #6
0
        public void setState(GraphicsState state)
        {
            switch (currentState)
            {
                case GraphicsState.ClientLoading:
                    quitState_ClientLoading();
                    break;
                case GraphicsState.Login:
                    quitState_Login();
                    break;
                case GraphicsState.LobbyLoading:
                    quitState_LobbyLoading();
                    break;
                case GraphicsState.Lobby:
                    quitState_Lobby();
                    break;
                case GraphicsState.GameLoading:
                    quitState_GameLoading();
                    break;
                case GraphicsState.Game:
                    quitState_Game();
                    break;
            }

            currentState = state;

            switch (currentState)
            {
                case GraphicsState.ClientLoading:
                    enterState_ClientLoading();
                    break;
                case GraphicsState.Login:
                    enterState_Login();
                    break;
                case GraphicsState.LobbyLoading:
                    enterState_LobbyLoading();
                    break;
                case GraphicsState.Lobby:
                    enterState_Lobby();
                    break;
                case GraphicsState.GameLoading:
                    enterState_GameLoading();
                    break;
                case GraphicsState.Game:
                    enterState_Game();
                    break;
            }
        }
        /**
         * Copy constructor.
         * @param source    another GraphicsState object
         */
        public GraphicsState(GraphicsState source){
            // note: all of the following are immutable, with the possible exception of font
            // so it is safe to copy them as-is
            ctm = source.ctm;
            characterSpacing = source.characterSpacing;
            wordSpacing = source.wordSpacing;
            horizontalScaling = source.horizontalScaling;
            leading = source.leading;
            font = source.font;
            fontSize = source.fontSize;
            renderMode = source.renderMode;
            rise = source.rise;
            knockout = source.knockout;
            colorSpaceFill = source.colorSpaceFill;
            colorSpaceStroke = source.colorSpaceStroke;
            fillColor = source.fillColor;
            strokeColor = source.strokeColor;
            lineWidth = source.lineWidth;
            lineCapStyle = source.lineCapStyle;
            lineJoinStyle = source.lineJoinStyle;
            miterLimit = source.miterLimit;

            if (source.lineDashPattern != null) {
                lineDashPattern = new LineDashPattern(source.lineDashPattern.DashArray, source.lineDashPattern.DashPhase);
            }
        }
Example #8
0
 /**
  * Copy constructor.
  * @param source    another GraphicsState object
  */
 public GraphicsState(GraphicsState source){
     // note: all of the following are immutable, with the possible exception of font
     // so it is safe to copy them as-is
     ctm = source.ctm;
     characterSpacing = source.characterSpacing;
     wordSpacing = source.wordSpacing;
     horizontalScaling = source.horizontalScaling;
     leading = source.leading;
     font = source.font;
     fontSize = source.fontSize;
     renderMode = source.renderMode;
     rise = source.rise;
     knockout = source.knockout;
 }
 /**
  * Create an ImageRenderInfo object based on inline image data.  This is nowhere near completely thought through
  * and really just acts as a placeholder.
  * @param ctm the coordinate transformation matrix at the time the image is rendered
  * @param imageObject the image object representing the inline image
  * @return the ImageRenderInfo representing the rendered embedded image
  * @since 5.0.1
  */
 protected internal static ImageRenderInfo CreateForEmbeddedImage(GraphicsState gs, InlineImageInfo inlineImageInfo, PdfDictionary colorSpaceDictionary)
 {
     ImageRenderInfo renderInfo = new ImageRenderInfo(gs, inlineImageInfo, colorSpaceDictionary);
     return renderInfo;
 }
        public int SaveHdc() 
        {
            HandleRef hdc = new HandleRef( this, this.Hdc);
            int state = IntUnsafeNativeMethods.SaveDC(hdc);

            if (contextStack == null) {
                contextStack = new Stack();
            }

            GraphicsState g = new GraphicsState();
            g.hBitmap = hCurrentBmp;
            g.hBrush  = hCurrentBrush;
            g.hPen    = hCurrentPen;            
            g.hFont   = hCurrentFont;

#if !DRAWING_NAMESPACE
            g.font    = new WeakReference(selectedFont);
#endif


            contextStack.Push(g);
                                   
#if TRACK_HDC
            Debug.WriteLine( DbgUtil.StackTraceToStr( String.Format("state[0]=DC.SaveHdc(hDc=0x{1:x8})", state, unchecked((int) this.hDC)) ));
#endif 

            return state;
        }
Example #11
0
 internal static extern GpStatus GdipRestoreGraphics(GpGraphics graphics, GraphicsState state);
 public int SaveHdc()
 {
     HandleRef hDC = new HandleRef(this, this.Hdc);
     int num = IntUnsafeNativeMethods.SaveDC(hDC);
     if (this.contextStack == null)
     {
         this.contextStack = new Stack();
     }
     GraphicsState state = new GraphicsState {
         hBitmap = this.hCurrentBmp,
         hBrush = this.hCurrentBrush,
         hPen = this.hCurrentPen,
         hFont = this.hCurrentFont,
         font = new WeakReference(this.selectedFont)
     };
     this.contextStack.Push(state);
     return num;
 }
Example #13
0
 public void Restore(GraphicsState gstate)
 {
     SetStatus(GdiPlus.GdipRestoreGraphics(nativeGraphics, gstate));
 }
Example #14
0
 /**
  * Used for creating sub-TextRenderInfos for each individual character
  * @param parent the parent TextRenderInfo
  * @param charIndex the index of the character that this TextRenderInfo will represent
  * @param horizontalOffset the unscaled horizontal offset of the character that this TextRenderInfo represents
  * @since 5.3.3
  */
 private TextRenderInfo(TextRenderInfo parent, int charIndex, float horizontalOffset)
 {
     this.text = parent.text.Substring(charIndex, 1);
     this.textToUserSpaceTransformMatrix = new Matrix(horizontalOffset, 0).Multiply(parent.textToUserSpaceTransformMatrix);
     this.gs = parent.gs;
     this.markedContentInfos = parent.markedContentInfos;
 }
Example #15
0
        public void HintGlyph(PointF[] glyphPoints, int[] contours, byte[] instructions)
        {
            if (instructions == null || instructions.Length == 0)
                return;

            // check if the CVT program disabled hinting
            if ((state.InstructionControl & InstructionControlFlags.InhibitGridFitting) != 0)
                return;

            // TODO: composite glyphs
            // TODO: round the phantom points?

            // save contours and points
            this.contours = contours;
            zp0 = zp1 = zp2 = points = new Zone(glyphPoints, isTwilight: false);

            // reset all of our shared state
            state = cvtState;
            callStackSize = 0;
            debugList.Clear();
            stack.Clear();
            OnVectorsUpdated();

            // normalize the round state settings
            switch (state.RoundState)
            {
                case RoundMode.Super: SetSuperRound(1.0f); break;
                case RoundMode.Super45: SetSuperRound(Sqrt2Over2); break;
            }

            Execute(new InstructionStream(instructions), false, false);
        }
Example #16
0
 GpStatus Restore(GraphicsState gstate)
 {
     return SetStatus(NativeMethods.GdipRestoreGraphics(nativeGraphics,
                                                      gstate));
 }
Example #17
0
 /**
  * Create an ImageRenderInfo object based on an XObject (this is the most common way of including an image in PDF)
  * @param ctm the coordinate transformation matrix at the time the image is rendered
  * @param ref a reference to the image XObject
  * @return the ImageRenderInfo representing the rendered XObject
  * @since 5.0.1
  */
 public static ImageRenderInfo CreateForXObject(GraphicsState gs, PdfIndirectReference refi, PdfDictionary colorSpaceDictionary)
 {
     return new ImageRenderInfo(gs, refi, colorSpaceDictionary);
 }
Example #18
0
 internal static extern GpStatus GdipSaveGraphics(GpGraphics graphics, out GraphicsState state);
 public void Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List<iTextSharp.text.pdf.PdfObject> operands)
 {
     GraphicsState gs = processor.gsStack.Peek();
     GraphicsState copy = new GraphicsState(gs);
     processor.gsStack.Push(copy);
 }