// mistelixvideosrc expects images in 24 bits (3 channels) public void FromDataImageSurface(DataImageSurface img) { if (img.Format != Cairo.Format.Argb32) throw new InvalidOperationException (String.Format ("SlideImage.FromCairo: unsupported format {0}", img.Format)); width = img.Width; height = img.Height; pixels = img.Get24bitsPixBuf (); channels = 3; stride = ((img.Width * channels) + 3) & ~3; alpha = false; }
void ProcessImage() { Logger.Debug ("SlideImage.ProcessImage. {0} Channels {1}", image, Channels); if (Title == null || Title == string.Empty) return; Logger.Debug ("SlideImage.ProcessImage. Image {0}", image); byte[] pix; if (channels == 3) { int src = 0; byte [] source; int stride_trg = 4 * width; int len_trg = stride_trg * height; source = Pixels; pix = new byte [len_trg]; for (int trg = 0; trg < len_trg; trg = trg + 4) { pix [trg] = source [src + 2]; pix [trg + 1] = source [src + 1]; pix [trg + 2] = source [src + 0]; pix [trg + 3] = 0xff; src += 3; } } else pix = Pixels; DataImageSurface surface = new DataImageSurface (DataImageSurface.Allocate (pix), Cairo.Format.Argb32, width, height, stride); Cairo.Context gr = new Cairo.Context (surface); DrawImageLegend (gr, Title, offset_x, offset_y, w, h); FromDataImageSurface (surface); ((IDisposable)gr).Dispose (); ((IDisposable)surface).Dispose (); }
void ShowImage(DataImageSurface imageToShow) { using(Cairo.Context context = Gdk.CairoHelper.Create(this.GdkWindow)) { Pattern pattern = new Pattern (imageToShow); context.Source = pattern; context.Paint (); ((IDisposable)pattern).Dispose (); } }