static GD CreateGifFrame(int frame) { GD img = new GD(256 + 384, 384, false); GDColor black = img.ColorAllocate(0, 0, 0); GDColor white = img.ColorAllocate(255, 255, 255); GDColor red = img.ColorAllocate(255, 0, 0); img.Rectangle(frame * 5, frame * 5, 50 + frame * 5, 50 + frame * 5, red); return(img); }
public int Blue(GDColor color) { GDImage imageData = (GDImage)Marshal.PtrToStructure(this.Handle, typeof(GDImage)); if (imageData.trueColor > 0) { return(color & 0x0000FF); } return(imageData.blue[color]); }
public int Red(GDColor color) { GDImage imageData = (GDImage)Marshal.PtrToStructure(this.Handle, typeof(GDImage)); if (imageData.trueColor > 0) { return((color & 0xFF0000) >> 16); } return(imageData.red[color]); }
public int Green(GDColor color) { GDImage imageData = (GDImage)Marshal.PtrToStructure(this.Handle, typeof(GDImage)); if (imageData.trueColor > 0) { return((color & 0x00FF00) >> 8); } return(imageData.green[color]); }
public int Alpha(GDColor color) { GDImage imageData = (GDImage)Marshal.PtrToStructure(this.Handle, typeof(GDImage)); if (imageData.trueColor > 0) { return((color & 0x7F000000) >> 24); } return(imageData.alpha[color]); }
public void DashedLine(int x1, int y1, int x2, int y2, GDColor color) { GDImport.gdImageDashedLine(this.Handle, x1, y1, x2, y2, color); }
public void Rectangle( int x1, int y1, int x2, int y2, GDColor color) { GDImport.gdImageRectangle( this.Handle, x1, y1, x2, y2, color); }
public void FilledPolygon(ArrayList list, GDColor color) { int[] intList = Point.GetIntArray(list); GDImport.gdImageFilledPolygon(this.Handle, intList, list.Count, color); }
public void Fill( int x, int y, GDColor color ) { GDImport.gdImageFill( this.Handle, x, y, color ); }
public void ColorTransparent( GDColor color ) { GDImport.gdImageColorTransparent( this.Handle, color ); }
public void CharUp( Font font, int x, int y, int c, GDColor color ) { HandleRef fontHandle = font.GetHandle(); GDImport.gdImageCharUp( this.Handle, fontHandle, x, y, c, color); }
public void Arc( int cx, int cy, int w, int h, int s, int e, GDColor color ) { GDImport.gdImageArc( this.Handle, cx, cy, w, h, s, e, color ); }
public void CharUp(Font font, int x, int y, int c, GDColor color) { HandleRef fontHandle = font.GetHandle(); GDImport.gdImageCharUp(this.Handle, fontHandle, x, y, c, color); }
public void SetAntiAliasedDontBlend(GDColor c) { GDImport.gdImageSetAntiAliasedDontBlend(this.Handle, c); }
public void Fill(int x, int y, GDColor color) { GDImport.gdImageFill(this.Handle, x, y, color); }
public void FillToBorder(int x, int y, int border, GDColor color) { GDImport.gdImageFillToBorder(this.Handle, x, y, border, color); }
public void FilledEllipse(int cx, int cy, int w, int h, GDColor color) { GDImport.gdImageFilledEllipse(this.Handle, cx, cy, w, h, color); }
public void FilledArc(int cx, int cy, int w, int h, int s, int e, GDColor color, int style) { GDImport.gdImageFilledArc(this.Handle, cx, cy, w, h, s, e, color, style); }
public void Arc(int cx, int cy, int w, int h, int s, int e, GDColor color) { GDImport.gdImageArc(this.Handle, cx, cy, w, h, s, e, color); }
public void ColorTransparent(GDColor color) { GDImport.gdImageColorTransparent(this.Handle, color); }
public int Alpha( GDColor color ) { GDImage imageData = (GDImage) Marshal.PtrToStructure( this.Handle, typeof( GDImage ) ); if( imageData.trueColor > 0 ) return ( ( color & 0x7F000000 ) >> 24 ); return imageData.alpha[color]; }
public void StringUp(Font font, int x, int y, string message, GDColor color) { HandleRef fontHandle = font.GetHandle(); GDImport.gdImageStringUp(this.Handle, fontHandle, x, y, message, color); }
public int Blue( GDColor color ) { GDImage imageData = (GDImage) Marshal.PtrToStructure( this.Handle, typeof( GDImage ) ); if( imageData.trueColor > 0 ) return ( color & 0x0000FF ); return imageData.blue[color]; }
public string StringFTCircle(int cx, int cy, double radius, double textRadius, double fillPortion, string font, double points, string top, string bottom, GDColor fgcolor) { return(GDImport.gdImageStringFTCircle(this.Handle, cx, cy, radius, textRadius, fillPortion, font, points, top, bottom, fgcolor)); }
public void ColorDeallocate( GDColor color ) { GDImport.gdImageColorDeallocate( this.Handle, color ); }
public void FilledEllipse( int cx, int cy, int w, int h, GDColor color ) { GDImport.gdImageFilledEllipse( this.Handle, cx, cy, w, h, color ); }
public void DashedLine( int x1, int y1, int x2, int y2, GDColor color ) { GDImport.gdImageDashedLine( this.Handle, x1, y1, x2, y2, color ); }
public int Green( GDColor color ) { GDImage imageData = (GDImage) Marshal.PtrToStructure( this.Handle, typeof( GDImage ) ); if( imageData.trueColor > 0 ) return ( ( color & 0x00FF00 ) >> 8 ); return imageData.green[color]; }
public void FilledArc( int cx, int cy, int w, int h, int s, int e, GDColor color, int style ) { GDImport.gdImageFilledArc( this.Handle, cx, cy, w, h, s, e, color, style ); }
public void FilledRectangle(int x1, int y1, int x2, int y2, GDColor color) { GDImport.gdImageFilledRectangle(this.Handle, x1, y1, x2, y2, color); }
public void FillToBorder( int x, int y, int border, GDColor color ) { GDImport.gdImageFillToBorder( this.Handle, x, y, border, color ); }
public void SetAntiAliasedDontBlend( GDColor c ) { GDImport.gdImageSetAntiAliasedDontBlend( this.Handle, c ); }
public void Polygon( ArrayList list, GDColor color ) { int[] intList = Point.GetIntArray( list ); GDImport.gdImagePolygon( this.Handle, intList, list.Count, color ); }
public string StringFTCircle( int cx, int cy, double radius, double textRadius, double fillPortion, string font, double points, string top, string bottom, GDColor fgcolor ) { return GDImport.gdImageStringFTCircle( this.Handle, cx, cy, radius, textRadius, fillPortion, font, points, top, bottom, fgcolor ); }
public int Red( GDColor color ) { GDImage imageData = (GDImage) Marshal.PtrToStructure( this.Handle, typeof( GDImage ) ); if( imageData.trueColor > 0 ) return ( ( color & 0xFF0000 ) >> 16 ); return imageData.red[color]; }
/***********************************************************************************\ * GD Drawing/Styling/Brushing/Tiling/Filling \***********************************************************************************/ public void SetPixel(int x, int y, GDColor color) { GDImport.gdImageSetPixel(this.Handle, x, y, color); }
/***********************************************************************************\ GD Drawing/Styling/Brushing/Tiling/Filling \***********************************************************************************/ public void SetPixel( int x, int y, GDColor color ) { GDImport.gdImageSetPixel( this.Handle, x, y, color ); }
// Ntx.GD.Tests.Test(); public static void Test() { GD image = new GD(256 + 384, 384, true); bool saveAlpha = image.SaveAlpha; GDColor white = image.ColorAllocate(255, 255, 255); image.FilledRectangle(0, 0, image.Width, image.Height, white); /* Set transparent color. */ image.ColorTransparent(white); GD import = new GD(GD.FileType.Png, MapPath("Img/demoin.png")); /* Now copy, and magnify as we do so */ image.CopyResampled(import, 32, 32, 0, 0, 192, 192, 255, 255); /* Now display variously rotated space shuttles in a circle of our own */ for (int a = 0; (a < 360); a += 45) { int cx = (int)Math.Floor(Math.Cos(a * .0174532925) * 127); int cy = (int)Math.Floor(-Math.Sin(a * .0174532925) * 127); image.CopyRotated(import, 256 + 192 + cx, 192 + cy, 0, 0, import.Width, import.Height, a); } GDColor red = image.ColorAllocate(255, 0, 0); GDColor green = image.ColorAllocate(0, 255, 0); GDColor blue = image.ColorAllocate(0, 0, 255); /* Fat Rectangle */ image.SetThickness(4); image.Line(16, 16, 240, 16, green); image.Line(240, 16, 240, 240, green); image.Line(240, 240, 16, 240, green); image.Line(16, 240, 16, 16, green); image.SetThickness(1); /* Circle */ image.Arc(128, 128, 60, 20, 0, 720, blue); /* Arc */ image.Arc(128, 128, 40, 40, 90, 270, blue); /* Flood fill: doesn't do much on a continuously * variable tone jpeg original. */ image.Fill(8, 8, blue); /* Polygon */ ArrayList list = new ArrayList(); list.Add(new Point(64, 0)); list.Add(new Point(0, 128)); list.Add(new Point(128, 128)); image.FilledPolygon(list, green); /* 2.0.12: Antialiased Polygon */ image.SetAntiAliased(green); for (int i = 0; (i < 3); i++) { ((Point)list[i]).X += 128; } image.FilledPolygon(list, GD.GD_ANTIALIASED); /* Brush. A fairly wild example also involving a line style! */ int[] style = new int[8]; GD brush = new GD(16, 16, true); brush.CopyResized(import, 0, 0, 0, 0, brush.Width, brush.Height, import.Width, import.Height); image.SetBrush(brush); /* With a style, so they won't overprint each other. * Normally, they would, yielding a fat-brush effect. */ style[0] = 0; style[1] = 0; style[2] = 0; style[3] = 0; style[4] = 0; style[5] = 0; style[6] = 0; style[7] = 1; image.SetStyle(style); /* Draw the styled, brushed line */ image.Line(0, 255, 255, 0, GD.GD_STYLED_BRUSHED); /* Text (non-truetype; see gdtestft for a freetype demo) */ ArrayList fonts = new ArrayList(); fonts.Add(new Font(Font.Type.Tiny)); fonts.Add(new Font(Font.Type.Small)); fonts.Add(new Font(Font.Type.MediumBold)); fonts.Add(new Font(Font.Type.Large)); fonts.Add(new Font(Font.Type.Giant)); int y = 0; for (int i = 0; (i <= 4); i++) { image.String(((Font)fonts[i]), 32, 32 + y, "hi", red); y += ((Font)fonts[i]).Height(); } y = 0; for (int i = 0; (i <= 4); i++) { image.StringUp(((Font)fonts[i]), 64 + y, 64, "hi", red); y += ((Font)fonts[i]).Height(); } /* Random antialiased lines; coordinates all over the image, * but the output will respect a small clipping rectangle */ image.SetClip(0, image.Height - 100, 100, image.Height); /* Fixed seed for reproducibility of results */ Random ran = new Random(100); for (int i = 0; (i < 100); i++) { int x1 = ran.Next() % image.Width; int y1 = ran.Next() % image.Height; int x2 = ran.Next() % image.Width; int y2 = ran.Next() % image.Height; image.SetAntiAliased(white); image.Line(x1, y1, x2, y2, GD.GD_ANTIALIASED); } /* Make output image interlaced (progressive, in the case of JPEG) */ image.Interlace = true; image.Save(GD.FileType.Png, "demoout.png", 1); /* 2.0.12: also write a paletteized version */ image.TrueColorToPalette(0, 256); image.Save(GD.FileType.Png, "demooutp.png", 1); using (FileStream fs = File.OpenWrite(@"stream.jpg")) { image.Save(Ntx.GD.GD.FileType.Jpeg, (System.IO.Stream)fs, 100); fs.Close(); } using (FileStream fs = File.OpenWrite(@"stream.png")) { image.Save(Ntx.GD.GD.FileType.Png, (System.IO.Stream)fs, 100); fs.Close(); } using (FileStream fs = File.OpenWrite(@"stream1.jpg")) { image.Save((System.IO.Stream)fs); fs.Close(); } image.Save("determinetype.jpg"); /* Free resources */ brush.Dispose(); import.Dispose(); image.Dispose(); TestGif(); MakeAnimGif(); }
public void StringUp( Font font, int x, int y, string message, GDColor color ) { HandleRef fontHandle = font.GetHandle(); GDImport.gdImageStringUp( this.Handle, fontHandle, x, y, message, color); }
public void ColorDeallocate(GDColor color) { GDImport.gdImageColorDeallocate(this.Handle, color); }