Пример #1
0
        public static Bitmap addition(Bitmap input, Bitmap overlay)
        {
            if (input.Width == overlay.Width && input.Height == overlay.Height)
            {
                imgLowLvl.imagebits sourceImg  = imgLowLvl.fastbits(input);
                imgLowLvl.imagebits overlayImg = imgLowLvl.fastbits(overlay);

                for (int i = 0; i < sourceImg.b.Length; i++)
                {
                    int   alphaValue = overlayImg.a[i];
                    float percent    = (float)alphaValue / 255f;

                    sourceImg.b[i] = (byte)Convert.ToInt32(sourceImg.b[i] + (overlayImg.b[i] * percent)).Clamp(0, 255);
                    sourceImg.g[i] = (byte)Convert.ToInt32(sourceImg.g[i] + (overlayImg.g[i] * percent)).Clamp(0, 255);
                    sourceImg.r[i] = (byte)Convert.ToInt32(sourceImg.r[i] + (overlayImg.r[i] * percent)).Clamp(0, 255);
                }

                return(imgLowLvl.imageBitsToBitMap(sourceImg, input.Width, input.Height));
            }
            else
            {
                //throw new ArgumentException("Images were not the same dimentions, cannot operate", "overlay");
                return(input);
            }
        }
Пример #2
0
        public static Bitmap brightness(Bitmap input, float value)
        {
            imgLowLvl.imagebits sourceImg = imgLowLvl.fastbits(input);

            for (int i = 0; i < sourceImg.b.Length; i++)
            {
                sourceImg.b[i] = (byte)Convert.ToInt32(sourceImg.b[i] * value).Clamp(0, 255);
                sourceImg.g[i] = (byte)Convert.ToInt32(sourceImg.g[i] * value).Clamp(0, 255);
                sourceImg.r[i] = (byte)Convert.ToInt32(sourceImg.r[i] * value).Clamp(0, 255);
            }

            return(imgLowLvl.imageBitsToBitMap(sourceImg, input.Width, input.Height));
        }
Пример #3
0
        //Returns itself in bitmap form. All channels equals density map
        public Bitmap toBitMap()
        {
            Bitmap output = new Bitmap(width, height);

            imgLowLvl.imagebits bits = imgLowLvl.fastbits(output);

            for (int i = 0; i < bits.a.Length; i++)
            {
                bits.a[i] = 255;
                bits.r[i] = (byte)pixelDensities[i];
                bits.g[i] = (byte)pixelDensities[i];
                bits.b[i] = (byte)pixelDensities[i];
            }

            return(imgLowLvl.imageBitsToBitMap(bits, width, height));
        }
Пример #4
0
        public static Bitmap greyScaleAverage(Bitmap input)
        {
            imgLowLvl.imagebits source = imgLowLvl.fastbits(input);

            for (int i = 0; i < source.b.Length; i++)
            {
                int total = 0;
                total += source.b[i];
                total += source.g[i];
                total += source.r[i];

                int newVal = total / 3;

                source.b[i] = (byte)newVal;
                source.g[i] = (byte)newVal;
                source.r[i] = (byte)newVal;
            }

            return(imgLowLvl.imageBitsToBitMap(source, input.Width, input.Height));
        }