private bool RenderArtistImage(string imagePath, CellContext context)
        {
            // majority of artist images has size 400 * 155
            int originalImageWidth = 400;
            int orginalImageHeight = 155;

            double scale = 0.22;

            // calculate size:
            int spacing      = 0;
            int thumb_height = (int)(orginalImageHeight * scale);
            int thumb_width  = (int)(originalImageWidth * scale);

            Gdk.Pixbuf artistPixbuf = null;
            artistPixbuf = new Gdk.Pixbuf(imagePath);

            if (artistPixbuf != null)
            {
                artistPixbuf = artistPixbuf.ScaleSimple(thumb_width, thumb_height, Gdk.InterpType.Bilinear);
                bool has_border = false;
                using (var artistImage = PixbufImageSurface.Create(artistPixbuf)) {
                    // display get artist image:
                    ArtworkRenderer.RenderThumbnail(context.Context, artistImage, false,
                                                    spacing, spacing,
                                                    thumb_width, thumb_height,
                                                    has_border, context.Theme.Context.Radius);
                }
                return(true);
            }
            return(false);
        }
Beispiel #2
0
        protected override void RenderIdle(Cairo.Context cr)
        {
            idle_album = idle_album ?? PixbufImageSurface.Create(Banshee.Gui.IconThemeUtils.LoadIcon(
                                                                     ArtworkSizeRequest, MissingAudioIconName), true);

            ArtworkRenderer.RenderThumbnail(cr, idle_album, false, 0, 0,
                                            ArtworkSizeRequest, ArtworkSizeRequest,
                                            false, 0, true, BackgroundColor);
        }
Beispiel #3
0
        protected override void RenderIdle(Cairo.Context cr)
        {
            idle_album = idle_album ?? PixbufImageSurface.Create(Banshee.Gui.IconThemeUtils.LoadIcon(
                                                                     ArtworkSizeRequest, "media-optical"), true);

            ArtworkRenderer.RenderThumbnail(cr, idle_album, false, Allocation.X, Allocation.Y,
                                            ArtworkSizeRequest, ArtworkSizeRequest,
                                            false, 0, true, BackgroundColor);
        }
Beispiel #4
0
        public Cairo.ImageSurface LookupScaleSurface(string id, int size, bool useCache)
        {
            SurfaceCache cache = null;

            Cairo.ImageSurface surface = null;

            if (id == null)
            {
                return(null);
            }

            if (useCache && scale_caches.TryGetValue(size, out cache) && cache.TryGetValue(id, out surface))
            {
                return(surface);
            }

            if (null_artwork_ids.Contains(id))
            {
                return(null);
            }

            Pixbuf pixbuf = LookupScalePixbuf(id, size);

            if (pixbuf == null || pixbuf.Handle == IntPtr.Zero)
            {
                null_artwork_ids.Add(id);
                return(null);
            }

            try {
                surface = PixbufImageSurface.Create(pixbuf);
                if (surface == null)
                {
                    return(null);
                }

                if (!useCache)
                {
                    return(surface);
                }

                if (cache == null)
                {
                    int bytes = 4 * size * size;
                    int max   = (1 << 20) / bytes;

                    ChangeCacheSize(size, max);
                    cache = scale_caches[size];
                }

                cache.Add(id, surface);
                return(surface);
            } finally {
                DisposePixbuf(pixbuf);
            }
        }
        public Cairo.ImageSurface LookupScaleSurface(string id, int size, bool useCache)
        {
            SurfaceCache cache = null;

            Cairo.ImageSurface surface = null;

            if (id == null)
            {
                return(null);
            }

            if (useCache && scale_caches.TryGetValue(size, out cache) && cache.TryGetValue(id, out surface))
            {
                return(surface);
            }

            Pixbuf pixbuf = LookupScalePixbuf(id, size);

            if (pixbuf == null || pixbuf.Handle == IntPtr.Zero)
            {
                return(null);
            }

            try {
                surface = PixbufImageSurface.Create(pixbuf);
                if (surface == null)
                {
                    return(null);
                }

                if (!useCache)
                {
                    return(surface);
                }

                if (cache == null)
                {
                    int bytes = 4 * size * size;
                    int max   = (1 << 20) / bytes;

                    Log.DebugFormat("Creating new surface cache for {0} KB (max) images, capped at 1 MB ({1} items)",
                                    bytes, max);

                    cache = new SurfaceCache(max);
                    scale_caches.Add(size, cache);
                }

                cache.Add(id, surface);
                return(surface);
            } finally {
                DisposePixbuf(pixbuf);
            }
        }
        public ColumnCellArtistCover(bool smallImagesUsed) : base(null, true)
        {
            use_small_images    = smallImagesUsed;
            artwork_initialized = false;

            image_size = use_small_images ? small_image_size : normal_image_size;

            default_cover_image
                = PixbufImageSurface.Create(IconThemeUtils.LoadIcon(image_size, "media-optical", "browser-album-cover"));

            column_controller = new ColumnController();
            var current_layout = new Column("Artist", this, 1.0);

            column_controller.Add(current_layout);

            ServiceManager.SourceManager.ActiveSourceChanged += HandleActiveSourceChanged;
        }