Class GraphicUtils
Assembly: Reportman.Drawing.Windows.dll
Syntax
public class GraphicUtils
Constructors
GraphicUtils()
Declaration
Fields
DefaultDPI
Declaration
public static int DefaultDPI
Field Value
Properties
DPIScale
Declaration
public static float DPIScale { get; }
Property Value
DPIScaleX
Declaration
public static float DPIScaleX { get; }
Property Value
DPIScaleY
Declaration
public static float DPIScaleY { get; }
Property Value
Methods
ConvertToBitonal(Bitmap, int)
Declaration
public static Bitmap ConvertToBitonal(Bitmap original, int threshold)
Parameters
| Type |
Name |
Description |
| Bitmap |
original |
|
| int |
threshold |
|
Returns
Declaration
public static Metafile CreateWindowsMetafile(int Width, int Height)
Parameters
| Type |
Name |
Description |
| int |
Width |
|
| int |
Height |
|
Returns
DrawGrid(Graphics, int, int, int, int, Color, bool, int, int, double)
Draw a grid given a distance in twips
Declaration
public static void DrawGrid(Graphics gr, int XWidth, int XHeight, int PixelsWidth, int PixelsHeight, Color GridColor, bool Lines, int XOffset, int YOffset, double Scale)
Parameters
| Type |
Name |
Description |
| Graphics |
gr |
Destination
|
| int |
XWidth |
Width in twips (1440 twips=1 inch)
|
| int |
XHeight |
Height in twips
|
| int |
PixelsWidth |
Width in pixels
|
| int |
PixelsHeight |
Height in pixels
|
| Color |
GridColor |
Color of the points or lines drawn
|
| bool |
Lines |
Set to true to draw lines instead of points
|
| int |
XOffset |
Horizontal offset
|
| int |
YOffset |
Vertical offset
|
| double |
Scale |
Scale the grid, set to 1.0 to draw in real size
|
ExifRotate(Image)
Declaration
public static bool ExifRotate(Image img)
Parameters
| Type |
Name |
Description |
| Image |
img |
|
Returns
FontStyleFromInteger(int)
Create a FontStyle from integer
Declaration
public static FontStyle FontStyleFromInteger(int intfontstyle)
Parameters
| Type |
Name |
Description |
| int |
intfontstyle |
|
Returns
GetAvgFontSizeTwips(string, float, FontStyle)
Declaration
public static Size GetAvgFontSizeTwips(string FontFamily, float FontSize, FontStyle FStyle)
Parameters
Returns
GetBitmapGrid(int, int, int, int, Color, Color, bool, double)
Obtain a bitmap to perform fast drawing of a grid,
so consecutive calls with similar parameters will execute faster.
The implementation uses a shared bitmap.
Declaration
public static Bitmap GetBitmapGrid(int Width, int Height, int GWidth, int GHeight, Color GColor, Color BackColor, bool Lines, double Scale)
Parameters
Returns
GetEncoderInfo(string)
Declaration
public static ImageCodecInfo GetEncoderInfo(string mimeType)
Parameters
| Type |
Name |
Description |
| string |
mimeType |
|
Returns
GetImageCodec(string)
Retuns a codec with the mime type or null if not found
Declaration
public static ImageCodecInfo GetImageCodec(string mimeType)
Parameters
| Type |
Name |
Description |
| string |
mimeType |
Codec string, example "image/jpeg"
|
Returns
GetImageCodecFromExtension(string)
Retuns a codec with the mime type or null if not found
Declaration
public static ImageCodecInfo GetImageCodecFromExtension(string extension)
Parameters
| Type |
Name |
Description |
| string |
extension |
|
Returns
GetImageCodecs()
Obtain a list of available image codecs
Declaration
public static Strings GetImageCodecs()
Returns
| Type |
Description |
| Strings |
A list, string collection of image codecs
|
GetImageGrid(int, int, int, int, Color, Color, bool, double)
Obtain a Image (Metafile or Bitmap) to perform fast drawing of a grid,
so consecutive calls with similar parameters will execute faster.
The implementation uses a shared bitmap or metafile.
Declaration
public static Image GetImageGrid(int Width, int Height, int GWidth, int GHeight, Color GColor, Color BackColor, bool Lines, double Scale)
Parameters
Returns
GetInvertedBlackWhite(Color)
Declaration
public static Color GetInvertedBlackWhite(Color c)
Parameters
| Type |
Name |
Description |
| Color |
c |
|
Returns
Obtain a metafile to perform fast drawing of a grid,
so consecutive calls with similar parameters will execute faster.
The implementation uses a shared metafile.
Declaration
public static Metafile GetMetafileGrid(int Width, int Height, int GWidth, int GHeight, Color GColor, Color BackColor, bool Lines, double Scale)
Parameters
Returns
GetMimeType(Image)
Declaration
public static string GetMimeType(Image i)
Parameters
| Type |
Name |
Description |
| Image |
i |
|
Returns
GetRotateFlipTypeByExifOrientationData(int)
Declaration
public static RotateFlipType GetRotateFlipTypeByExifOrientationData(int orientation)
Parameters
| Type |
Name |
Description |
| int |
orientation |
|
Returns
GetRoundedLine(PointF[], float)
Declaration
public static GraphicsPath GetRoundedLine(PointF[] points, float cornerRadius)
Parameters
| Type |
Name |
Description |
| PointF[] |
points |
|
| float |
cornerRadius |
|
Returns
ImageFromStream(Stream)
Returns a Image from stream. Do rotation for jpeg camera images
Declaration
public static Image ImageFromStream(Stream mstream)
Parameters
| Type |
Name |
Description |
| Stream |
mstream |
Memory stream to read Image from
|
Returns
| Type |
Description |
| Image |
Image object
|
ImageToByteArray(Image)
Declaration
public static byte[] ImageToByteArray(Image nimage)
Parameters
| Type |
Name |
Description |
| Image |
nimage |
|
Returns
ImageToStream(Image)
Declaration
public static MemoryStream ImageToStream(Image nimage)
Parameters
| Type |
Name |
Description |
| Image |
nimage |
|
Returns
IntegerFromFontStyle(FontStyle)
Declaration
public static int IntegerFromFontStyle(FontStyle astyle)
Parameters
Returns
IntegerFromStringFontStyle(string)
Declaration
public static int IntegerFromStringFontStyle(string sfontstyle)
Parameters
| Type |
Name |
Description |
| string |
sfontstyle |
|
Returns
LengthenLine(PointF, ref PointF, float)
Declaration
public static void LengthenLine(PointF startPoint, ref PointF endPoint, float pixelCount)
Parameters
MeasureDisplayStringWidth(Graphics, string, Font)
Calculates the with in current graphics units of a text
Declaration
public static double MeasureDisplayStringWidth(Graphics graphics, string text, Font font)
Parameters
| Type |
Name |
Description |
| Graphics |
graphics |
Graphics object where the measurement will be done
|
| string |
text |
Text to be measured
|
| Font |
font |
Font used for the measurement
|
Returns
| Type |
Description |
| double |
Width in graphic units of the measured text
|
RemapImageTransparentColor(Image, Color)
Declaration
public static Image RemapImageTransparentColor(Image img, Color OldColor)
Parameters
Returns
ScaleBitmapDPI(Image)
Declaration
public static Image ScaleBitmapDPI(Image image)
Parameters
| Type |
Name |
Description |
| Image |
image |
|
Returns
ScaleToDPI(int)
Declaration
public static int ScaleToDPI(int pixels)
Parameters
| Type |
Name |
Description |
| int |
pixels |
|
Returns
ScaledBitmapRatio(Image, int, int, bool)
Scale bitmap to a maximum of width and height
Declaration
public static Image ScaledBitmapRatio(Image image, int width, int height, bool highquality)
Parameters
Returns
ScaledBitmapRatio(Image, int, int, bool, bool)
Declaration
public static Image ScaledBitmapRatio(Image image, int width, int height, bool highquality, bool allowexpand)
Parameters
Returns
ScreenDPI()
Declaration
public static int ScreenDPI()
Returns
ScreenDPIX()
Declaration
public static int ScreenDPIX()
Returns
ScreenDPIY()
Declaration
public static int ScreenDPIY()
Returns
SimpleThresholdBW(byte[], int, int, int, int, int)
Declaration
public static byte[] SimpleThresholdBW(byte[] sourceBuffer, int width, int height, int srcStride, int dstStride, int threshold)
Parameters
| Type |
Name |
Description |
| byte[] |
sourceBuffer |
|
| int |
width |
|
| int |
height |
|
| int |
srcStride |
|
| int |
dstStride |
|
| int |
threshold |
|
Returns
StringFontStyleFromInteger(int)
Declaration
public static string StringFontStyleFromInteger(int intstyle)
Parameters
| Type |
Name |
Description |
| int |
intstyle |
|
Returns
StringFromFontStyle(FontStyle)
Declaration
public static string StringFromFontStyle(FontStyle astyle)
Parameters
Returns
TextToBitmap(int, string, string, float)
Converts a text to his representation in bitmap form
Declaration
public static Bitmap TextToBitmap(int width, string text, string fontfamily, float fontsize)
Parameters
| Type |
Name |
Description |
| int |
width |
Witdh of the resulting bitmap
|
| string |
text |
Text to be printed into the bitmap
|
| string |
fontfamily |
Font family
|
| float |
fontsize |
Font size
|
Returns
| Type |
Description |
| Bitmap |
Returns a bitmap with the text drawn on it
|
Write a Windows Metafile into a stream
Declaration
public static void WriteWindowsMetaFile(Metafile metaf, Stream destination, float Scale)
Parameters
| Type |
Name |
Description |
| Metafile |
metaf |
Metafile to write
|
| Stream |
destination |
Stream destination
|
| float |
Scale |
Scale of the Windows Metafile
|
Convert a windows metafile to a image format saved into a stream
Declaration
public static void WriteWindowsMetaFileCodec(Metafile metaf, Stream destination, float Scale, string codecstring, out string mimetype)
Parameters
| Type |
Name |
Description |
| Metafile |
metaf |
Windows Metafile to be converted
|
| Stream |
destination |
Destination stream
|
| float |
Scale |
Scale of the metafile
|
| string |
codecstring |
Codec to be used you can obtain a list by using GetImageCodecs
|
| string |
mimetype |
Mimetype of the selected codec
|