CardMaker.Card.DrawItem.LoadOpacityImageFromCache C# (CSharp) Метод

LoadOpacityImageFromCache() приватный статический Метод

private static LoadOpacityImageFromCache ( string sFile, ProjectLayoutElement zElement ) : Bitmap
sFile string
zElement CardMaker.XML.ProjectLayoutElement
Результат System.Drawing.Bitmap
        private static Bitmap LoadOpacityImageFromCache(string sFile, ProjectLayoutElement zElement)
        {
            Bitmap zBitmap;
            string sKey = sFile.ToLower() + ":" + zElement.opacity;
            if (!s_dictionaryOpacityImages.TryGetValue(sKey, out zBitmap))
            {
                // only buffer 20 opacity images max (make this an option?)
                if (s_dictionaryOpacityImages.Count > IMAGE_CACHE_MAX)
                {
                    DumpOpacityImages();
                }
                var zColor = new ColorMatrix
                {
                    Matrix33 = (float) zElement.opacity/255.0f
                };
                var zAttrib = new ImageAttributes();
                zAttrib.SetColorMatrix(zColor);
                var zSourceImage = LoadImageFromCache(sFile);
                zBitmap = new Bitmap(zSourceImage.Width, zSourceImage.Height); // target image
                var zGraphics = Graphics.FromImage(zBitmap);
                // draw the source image into the destination with the desired opacity
                zGraphics.DrawImage(zSourceImage, new Rectangle(0, 0, zBitmap.Width, zBitmap.Height), 0, 0, zBitmap.Width, zBitmap.Height, GraphicsUnit.Pixel,
                    zAttrib);
                zBitmap.Tag = (float)zBitmap.Width / (float)zBitmap.Height; // backup the aspect ratio
                // cache it!
                s_dictionaryOpacityImages.Add(sKey, zBitmap);
            }
            return zBitmap;
        }