#region MIT License /*Copyright (c) 2012 Robert Rouhani SharpFont based on Tao.FreeType, Copyright (c) 2003-2007 Tao Framework Team Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #endregion using System; using System.Runtime.InteropServices; using SharpFont.Internal; namespace SharpFont { /// /// A function used as a call-back by the anti-aliased renderer in order to let client applications draw themselves /// the gray pixel spans on each scan line. /// /// /// This callback allows client applications to directly render the gray spans of the anti-aliased bitmap to any /// kind of surfaces. /// /// This can be used to write anti-aliased outlines directly to a given background bitmap, and even perform /// translucency. /// /// Note that the ‘count’ field cannot be greater than a fixed value defined by the ‘FT_MAX_GRAY_SPANS’ /// configuration macro in ‘ftoption.h’. By default, this value is set to 32, which means that if there are more /// than 32 spans on a given scanline, the callback is called several times with the same ‘y’ parameter in order to /// draw all callbacks. /// /// Otherwise, the callback is only called once per scan-line, and only for those scanlines that do have ‘gray’ /// pixels on them. /// /// The scanline's y coordinate. /// The number of spans to draw on this scanline. /// A table of ‘count’ spans to draw on the scanline. /// User-supplied data that is passed to the callback. [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void RasterSpanFunc(int y, int count, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(SpanMarshaler))] Span spans, IntPtr user); /// /// THIS TYPE IS DEPRECATED. DO NOT USE IT. /// /// A function used as a call-back by the monochrome scan-converter to test whether a given target pixel is already /// set to the drawing ‘color’. These tests are crucial to implement drop-out control per-se the TrueType spec. /// /// The pixel's y coordinate. /// The pixel's x coordinate. /// User-supplied data that is passed to the callback. /// 1 if the pixel is ‘set’, 0 otherwise. [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate int RasterBitTestFunc(int y, int x, IntPtr user); /// /// THIS TYPE IS DEPRECATED. DO NOT USE IT. /// /// A function used as a call-back by the monochrome scan-converter to set an individual target pixel. This is /// crucial to implement drop-out control according to the TrueType specification. /// /// The pixel's y coordinate. /// The pixel's x coordinate. /// User-supplied data that is passed to the callback. [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void RasterBitSetFunc(int y, int x, IntPtr user); /// /// A structure to hold the arguments used by a raster's render function. /// /// /// An anti-aliased glyph bitmap is drawn if the bit flag is set in the ‘flags’ /// field, otherwise a monochrome bitmap is generated. /// /// If the bit flag is set in ‘flags’, the raster will call the ‘gray_spans’ /// callback to draw gray pixel spans, in the case of an aa glyph bitmap, it will call ‘black_spans’, and /// ‘bit_test’ and ‘bit_set’ in the case of a monochrome bitmap. This allows direct composition over a pre-existing /// bitmap through user-provided callbacks to perform the span drawing/composition. /// /// Note that the ‘bit_test’ and ‘bit_set’ callbacks are required when rendering a monochrome bitmap, as they are /// crucial to implement correct drop-out control as defined in the TrueType specification. /// public class RasterParams { #region Fields private IntPtr reference; private RasterParamsRec rec; #endregion #region Constructors internal RasterParams(IntPtr reference) { Reference = reference; } #endregion #region Properties /// /// Gets the target bitmap. /// public FTBitmap Target { get { return new FTBitmap(rec.target); } } /// /// Gets a pointer to the source glyph image (e.g., an ). /// public IntPtr Source { get { return rec.source; } } /// /// Gets the rendering flags. /// public RasterFlags Flags { get { return rec.flags; } } /// /// Gets the gray span drawing callback. /// public RasterSpanFunc GraySpans { get { return rec.gray_spans; } } /// /// Gets the black span drawing callback. UNIMPLEMENTED! /// public RasterSpanFunc BlackSpans { get { return rec.black_spans; } } /// /// Gets the bit test callback. UNIMPLEMENTED! /// public RasterBitTestFunc BitTest { get { return rec.bit_test; } } /// /// Gets the bit set callback. UNIMPLEMENTED! /// public RasterBitSetFunc BitSet { get { return rec.bit_set; } } /// /// Gets the user-supplied data that is passed to each drawing callback. /// public IntPtr User { get { return rec.user; } } /// /// Gets an optional clipping box. It is only used in direct rendering mode. Note that coordinates here should /// be expressed in integer pixels (and not in 26.6 fixed-point units). /// public BBox ClipBox { get { return new BBox(rec.clip_box); } } internal IntPtr Reference { get { return reference; } set { reference = value; rec = PInvokeHelper.PtrToStructure(reference); } } #endregion } }