public SlideImage GetSlideThumbnail(int width, int height, bool copyTitle) { SlideImage newImage = new SlideImage(); newImage.CopyProperties(this); using(DataImageSurface thumbnail = this.GetThumbnail(width, height, copyTitle)) { newImage.FromDataImageSurface(thumbnail); } return newImage; }
protected SlideImage CreateImage(int points, double radius) { double percentage; percentage = ((1d / Frames) * CurrentFrame); SlideImage image = new SlideImage (); image.CopyProperties (Source); image.Pixels = new byte [Target.Stride * Target.Height]; SlideImage draw_image = new SlideImage (); double cx = Convert.ToInt32 ((Source.Width / 2)); double cy = Convert.ToInt32 ((Source.Height / 2)); double r1 = Target.Width * percentage; double r2 = Target.Width * percentage * 0.5; DataImageSurface draw = Source.ToDataImageSurface (); using (Context gr = new Context (draw)) { // First paint in black the image. gr.Save (); gr.MoveTo (0,0); gr.LineTo (Target.Width, 0); gr.LineTo (Target.Width, Target.Height); gr.LineTo (0, Source.Height); gr.ClosePath (); gr.Color = new Color (0,0,0); gr.Fill (); gr.Save (); double x, y; double x1, y1; // Draw the points of the star, creating a path with a line for (int i = 0; i < points; i = i + 2) { x = cx + (r1 * System.Math.Cos (i * radius - System.Math.PI / 2)); y = cy + (r1 * System.Math.Sin (i * radius - System.Math.PI / 2)); gr.LineTo (new PointD (x, y)); x1 = cx + (r2 * System.Math.Cos ((i + 1) * radius - System.Math.PI / 2)); y1 = cy + (r2 * System.Math.Sin ((i + 1) * radius - System.Math.PI / 2)); gr.LineTo (new PointD (x1, y1)); } gr.ClosePath (); // Fill the resulting polygon with a color gr.Color = new Color (1, 115, 0); gr.Fill (); gr.Restore (); draw_image.FromDataImageSurface (draw); bool sourced = percentage < 0.5; if (sourced) Array.Copy (Source.Pixels, image.Pixels, Source.Stride * Source.Height); else Array.Copy (Target.Pixels, image.Pixels, Target.Stride * Target.Height); // Draw target image to the star // Compare Target picture with the temporary // If in the temporary we have found a black pixel, draw a pixel from the Source slide // If in the temporary we have found a non-black pixel, draw a pixel from the Target slide for (int h = 0; h < Target.Height; h++) { int pos = h * Target.Stride; int pos_draw = h * draw_image.Stride; for (int w = 0; w < Target.Width; w++) { if (draw_image.Pixels[pos_draw] != 0) { if (sourced) { for (int c = 0; c < Target.Channels; c++) { image.Pixels[pos + c] = Target.Pixels[pos + c]; } } }else{ if (sourced == false) { for (int c = 0; c < Target.Channels; c++) { image.Pixels[pos + c] = Source.Pixels[pos + c]; } } } pos += Target.Channels; pos_draw += draw_image.Channels; } } } ((IDisposable) draw).Dispose (); return image; }