Example #1
0
        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);
        }
Example #2
0
        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]);
        }
Example #3
0
        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]);
        }
Example #4
0
        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]);
        }
Example #5
0
        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]);
        }
Example #6
0
 public void DashedLine(int x1, int y1, int x2, int y2, GDColor color)
 {
     GDImport.gdImageDashedLine(this.Handle, x1, y1, x2, y2, color);
 }
Example #7
0
 public void Rectangle( int x1, int y1, int x2, int y2, GDColor color)
 {
     GDImport.gdImageRectangle( this.Handle, x1, y1, x2, y2, color);
 }
Example #8
0
        public void FilledPolygon(ArrayList list, GDColor color)
        {
            int[] intList = Point.GetIntArray(list);

            GDImport.gdImageFilledPolygon(this.Handle, intList, list.Count, color);
        }
Example #9
0
 public void Fill( int x, int y, GDColor color )
 {
     GDImport.gdImageFill( this.Handle, x, y, color );
 }
Example #10
0
 public void ColorTransparent( GDColor color )
 {
     GDImport.gdImageColorTransparent( this.Handle, color );
 }
Example #11
0
        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);
        }
Example #12
0
 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 );
 }
Example #13
0
        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);
        }
Example #14
0
 public void SetAntiAliasedDontBlend(GDColor c)
 {
     GDImport.gdImageSetAntiAliasedDontBlend(this.Handle, c);
 }
Example #15
0
 public void Fill(int x, int y, GDColor color)
 {
     GDImport.gdImageFill(this.Handle, x, y, color);
 }
Example #16
0
 public void FillToBorder(int x, int y, int border, GDColor color)
 {
     GDImport.gdImageFillToBorder(this.Handle, x, y, border, color);
 }
Example #17
0
 public void FilledEllipse(int cx, int cy, int w, int h, GDColor color)
 {
     GDImport.gdImageFilledEllipse(this.Handle, cx, cy, w, h, color);
 }
Example #18
0
 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);
 }
Example #19
0
 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);
 }
Example #20
0
 public void ColorTransparent(GDColor color)
 {
     GDImport.gdImageColorTransparent(this.Handle, color);
 }
Example #21
0
        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];
        }
Example #22
0
        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);
        }
Example #23
0
        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];
        }
Example #24
0
 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));
 }
Example #25
0
 public void ColorDeallocate( GDColor color )
 {
     GDImport.gdImageColorDeallocate( this.Handle, color );
 }
Example #26
0
 public void FilledEllipse( int cx, int cy, int w, int h, GDColor color )
 {
     GDImport.gdImageFilledEllipse( this.Handle, cx, cy, w, h, color );
 }
Example #27
0
 public void DashedLine( int x1, int y1, int x2, int y2, GDColor color )
 {
     GDImport.gdImageDashedLine( this.Handle, x1, y1, x2, y2, color );
 }
Example #28
0
        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];
        }
Example #29
0
 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 );
 }
Example #30
0
 public void FilledRectangle(int x1, int y1, int x2, int y2, GDColor color)
 {
     GDImport.gdImageFilledRectangle(this.Handle, x1, y1, x2, y2, color);
 }
Example #31
0
 public void FillToBorder( int x, int y, int border, GDColor color )
 {
     GDImport.gdImageFillToBorder( this.Handle, x, y, border, color );
 }
Example #32
0
 public void SetAntiAliasedDontBlend( GDColor c )
 {
     GDImport.gdImageSetAntiAliasedDontBlend( this.Handle, c );
 }
Example #33
0
        public void Polygon( ArrayList list, GDColor color )
        {
            int[] intList = Point.GetIntArray( list );

            GDImport.gdImagePolygon( this.Handle, intList, list.Count, color );
        }
Example #34
0
 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 );
 }
Example #35
0
        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];
        }
Example #36
0
        /***********************************************************************************\
        *  GD Drawing/Styling/Brushing/Tiling/Filling
        \***********************************************************************************/

        public void SetPixel(int x, int y, GDColor color)
        {
            GDImport.gdImageSetPixel(this.Handle, x, y, color);
        }
Example #37
0
 /***********************************************************************************\
    	 GD Drawing/Styling/Brushing/Tiling/Filling
    	\***********************************************************************************/
 public void SetPixel( int x, int y, GDColor color )
 {
     GDImport.gdImageSetPixel( this.Handle, x, y, color );
 }
Example #38
0
        // 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();
        }
Example #39
0
        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);
        }
Example #40
0
 public void ColorDeallocate(GDColor color)
 {
     GDImport.gdImageColorDeallocate(this.Handle, color);
 }