Example #1
0
 public void Mimic(BitmapCrop otherCrop)
 {
     this.Left   = otherCrop.Left;
     this.Top    = otherCrop.Top;
     this.Bottom = otherCrop.Bottom;
     this.Right  = otherCrop.Right;
 }
Example #2
0
        public int CompareTo(object obj)
        {
            BitmapCrop otherCrop = obj as BitmapCrop;

            if (otherCrop != null)
            {
                if (this.Left > otherCrop.Left)
                {
                    return(1);
                }
                else if (this.Left < otherCrop.Left)
                {
                    return(-1);
                }

                if (this.Top > otherCrop.Top)
                {
                    return(1);
                }
                else if (this.Top < otherCrop.Top)
                {
                    return(-1);
                }

                if (this.Bottom > otherCrop.Bottom)
                {
                    return(1);
                }
                else if (this.Bottom < otherCrop.Bottom)
                {
                    return(-1);
                }

                if (this.Right > otherCrop.Right)
                {
                    return(1);
                }
                else if (this.Right < otherCrop.Right)
                {
                    return(-1);
                }

                return(0);
            }
            else
            {
                throw new InvalidCastException("BitmapCrop comparable only to other BitmapCrop objects");
            }
        }
Example #3
0
        public static void GetFrameBitmap(
            IntPtr sourceFrame,
            IntPtr destinationBitmap,
            int destinationBitmapWidthPixels,
            BitmapCrop resultingBitmapCrop,
            int copyWidthPixels,
            int copyHeightPixels,
            bool addBlackBorder,
            bool copyPointlessAlphaByte,
            bool allowCrop,
            ScalingAlgorithm scalingAlgorithm,
            out int resultingWidth,
            out int resultingHeight)
        {
            var      crop = new GetFrameBitmapCrop();
            GCHandle cropHandle;

            RawSerialize(crop, out cropHandle);

            var param = new GetFrameBitmapParams();

            param.sourceFrame                  = sourceFrame;
            param.destinationBitmap            = destinationBitmap;
            param.destinationBitmapWidthPixels = destinationBitmapWidthPixels;
            param.bitmapCrop             = cropHandle.AddrOfPinnedObject();
            param.copyWidthPixels        = copyWidthPixels;
            param.copyHeightPixels       = copyHeightPixels;
            param.addBlackBorder         = (byte)(addBlackBorder ? 1 : 0);
            param.copyPointlessAlphaByte = (byte)(copyPointlessAlphaByte ? 1 : 0);
            param.allowCrop        = (byte)(allowCrop ? 1 : 0);
            param.scalingAlgorithm = (int)scalingAlgorithm;

            // Copy into locked structure.
            GCHandle paramHandle;

            RawSerialize(param, out paramHandle);

            /////////////////////
            // Run!
            FreeDoInterface((int)InterfaceFunction.FDP_GET_FRAME_BITMAP, paramHandle.AddrOfPinnedObject());
            Marshal.PtrToStructure(cropHandle.AddrOfPinnedObject(), crop);
            Marshal.PtrToStructure(paramHandle.AddrOfPinnedObject(), param);
            // Get resulting crop.

            if (!Properties.Settings.Default.WindowScale)
            {
                resultingBitmapCrop.Top    = crop.top;
                resultingBitmapCrop.Left   = crop.left;
                resultingBitmapCrop.Right  = crop.right;
                resultingBitmapCrop.Bottom = crop.bottom;
            }
            else if (param.scalingAlgorithm == 1 || Properties.Settings.Default.RenderHighResolution == true)
            {
                resultingBitmapCrop.Top    = crop.top + 32;
                resultingBitmapCrop.Left   = crop.left + 32;
                resultingBitmapCrop.Right  = crop.right + 32;
                resultingBitmapCrop.Bottom = crop.bottom + 32;
            }
            else if (param.scalingAlgorithm == 2)
            {
                resultingBitmapCrop.Top    = crop.top + 48;
                resultingBitmapCrop.Left   = crop.left + 48;
                resultingBitmapCrop.Right  = crop.right + 48;
                resultingBitmapCrop.Bottom = crop.bottom + 48;
            }
            else if (param.scalingAlgorithm == 3)
            {
                resultingBitmapCrop.Top    = crop.top + 64;
                resultingBitmapCrop.Left   = crop.left + 64;
                resultingBitmapCrop.Right  = crop.right + 64;
                resultingBitmapCrop.Bottom = crop.bottom + 64;
            }
            else
            {
                resultingBitmapCrop.Top    = crop.top + 16;
                resultingBitmapCrop.Left   = crop.left + 16;
                resultingBitmapCrop.Right  = crop.right + 16;
                resultingBitmapCrop.Bottom = crop.bottom + 16;
            }

            resultingWidth  = param.resultingWidth;
            resultingHeight = param.resultingHeight;

            // Unlock structures.
            paramHandle.Free();
            cropHandle.Free();
        }