public static void DrawBackgroundImage(Graphics g, Image backgroundImage, Color backColor, ImageLayout backgroundImageLayout, Rectangle bounds, Rectangle clipRect, Point scrollOffset, RightToLeft rightToLeft)
 {
     if (g == null)
     {
         throw new ArgumentNullException("g");
     }
     if (backgroundImageLayout == ImageLayout.Tile)
     {
         using (TextureBrush brush = new TextureBrush(backgroundImage, WrapMode.Tile))
         {
             if (scrollOffset != Point.Empty)
             {
                 Matrix transform = brush.Transform;
                 transform.Translate((float) scrollOffset.X, (float) scrollOffset.Y);
                 brush.Transform = transform;
             }
             g.FillRectangle(brush, clipRect);
             return;
         }
     }
     Rectangle rect = CalculateBackgroundImageRectangle(bounds, backgroundImage, backgroundImageLayout);
     if ((rightToLeft == RightToLeft.Yes) && (backgroundImageLayout == ImageLayout.None))
     {
         rect.X += clipRect.Width - rect.Width;
     }
     using (SolidBrush brush2 = new SolidBrush(backColor))
     {
         g.FillRectangle(brush2, clipRect);
     }
     if (!clipRect.Contains(rect))
     {
         if ((backgroundImageLayout == ImageLayout.Stretch) || (backgroundImageLayout == ImageLayout.Zoom))
         {
             rect.Intersect(clipRect);
             g.DrawImage(backgroundImage, rect);
         }
         else if (backgroundImageLayout == ImageLayout.None)
         {
             rect.Offset(clipRect.Location);
             Rectangle destRect = rect;
             destRect.Intersect(clipRect);
             Rectangle rectangle3 = new Rectangle(Point.Empty, destRect.Size);
             g.DrawImage(backgroundImage, destRect, rectangle3.X, rectangle3.Y, rectangle3.Width, rectangle3.Height, GraphicsUnit.Pixel);
         }
         else
         {
             Rectangle rectangle4 = rect;
             rectangle4.Intersect(clipRect);
             Rectangle rectangle5 = new Rectangle(new Point(rectangle4.X - rect.X, rectangle4.Y - rect.Y), rectangle4.Size);
             g.DrawImage(backgroundImage, rectangle4, rectangle5.X, rectangle5.Y, rectangle5.Width, rectangle5.Height, GraphicsUnit.Pixel);
         }
     }
     else
     {
         ImageAttributes imageAttr = new ImageAttributes();
         imageAttr.SetWrapMode(WrapMode.TileFlipXY);
         g.DrawImage(backgroundImage, rect, 0, 0, backgroundImage.Width, backgroundImage.Height, GraphicsUnit.Pixel, imageAttr);
         imageAttr.Dispose();
     }
 }
Exemple #2
0
    ///////////////////////////////////////////////////////////////////////////////
    // Defining Constants                                                        //
    ///////////////////////////////////////////////////////////////////////////////
    #region CONSTANTS

    #endregion //CONSTANTS

    ///////////////////////////////////////////////////////////////////////////////
    // Defining Variables, Enumerations, Events                                  //
    ///////////////////////////////////////////////////////////////////////////////
    #region FIELDS
    #endregion //FIELDS

    ///////////////////////////////////////////////////////////////////////////////
    // Construction and Initializing methods                                     //
    ///////////////////////////////////////////////////////////////////////////////
    #region CONSTRUCTION

    /// <summary>
    /// Initializes a new instance of the VGScrollImage class.
    /// When newShapeDrawAction is set to None, only the image will
    /// be drawn, with Edge an additional border is drawn,
    /// with fill an additional (hopefully transparent) fill is drawn over the image.
    /// </summary>
    /// <param name="newShapeDrawAction">Drawing action: Edge, Fill, Both, None</param>
    /// <param name="newPen">Pen for additional borderline.</param>
    /// <param name="newBrush">Brush for additional fills.</param>
    /// <param name="newFont">Font for drawing name</param>
    /// <param name="newFontColor">Font color for drawing name.</param>
    /// <param name="newImageFile">filename without path</param>
    /// <param name="newPath">path to image file</param>
    /// <param name="newLayout"><see cref="ImageLayout"/> of the image</param>
    /// <param name="newAlpha">The transparency alpha for this image.0=transparent,1=opaque</param>
    /// <param name="newCanvas"><see cref="Size"/> of the owning original canvas</param>
    /// <param name="newStyleGroup">Group Enumeration, <see cref="VGStyleGroup"/></param>
    /// <param name="newName">Name of Element</param>
    /// <param name="newElementGroup">Element group description</param>
    public VGScrollImage(
      ShapeDrawAction newShapeDrawAction,
      Pen newPen,
      Brush newBrush,
      Font newFont,
      Color newFontColor,
      string newImageFile,
      string newPath,
      ImageLayout newLayout,
      float newAlpha,
      Size newCanvas,
      VGStyleGroup newStyleGroup,
      string newName,
      string newElementGroup)
      : base(
      newShapeDrawAction,
      newPen,
      newBrush,
      newFont,
      newFontColor,
      newImageFile,
      newPath,
      newLayout,
      newAlpha,
      newCanvas,
      newStyleGroup,
      newName,
      newElementGroup,
      false)
    {
    }
        internal static Rectangle CalculateBackgroundImageRectangle(Rectangle bounds, Image backgroundImage, ImageLayout imageLayout)
        {
            Rectangle rectangle = bounds;
            if (backgroundImage != null)
            {
                switch (imageLayout)
                {
                    case ImageLayout.None:
                        rectangle.Size = backgroundImage.Size;
                        return rectangle;

                    case ImageLayout.Tile:
                        return rectangle;

                    case ImageLayout.Center:
                    {
                        rectangle.Size = backgroundImage.Size;
                        Size size = bounds.Size;
                        if (size.Width > rectangle.Width)
                        {
                            rectangle.X = (size.Width - rectangle.Width) / 2;
                        }
                        if (size.Height > rectangle.Height)
                        {
                            rectangle.Y = (size.Height - rectangle.Height) / 2;
                        }
                        return rectangle;
                    }
                    case ImageLayout.Stretch:
                        rectangle.Size = bounds.Size;
                        return rectangle;

                    case ImageLayout.Zoom:
                    {
                        Size size2 = backgroundImage.Size;
                        float num = ((float) bounds.Width) / ((float) size2.Width);
                        float num2 = ((float) bounds.Height) / ((float) size2.Height);
                        if (num >= num2)
                        {
                            rectangle.Height = bounds.Height;
                            rectangle.Width = (int) ((size2.Width * num2) + 0.5);
                            if (bounds.X >= 0)
                            {
                                rectangle.X = (bounds.Width - rectangle.Width) / 2;
                            }
                            return rectangle;
                        }
                        rectangle.Width = bounds.Width;
                        rectangle.Height = (int) ((size2.Height * num) + 0.5);
                        if (bounds.Y >= 0)
                        {
                            rectangle.Y = (bounds.Height - rectangle.Height) / 2;
                        }
                        return rectangle;
                    }
                }
            }
            return rectangle;
        }
        internal static Rectangle CalculateBackgroundImageRectangle(Rectangle bounds, Image backgroundImage, ImageLayout imageLayout) {

           Rectangle result = bounds;

           if (backgroundImage != null) {
               switch (imageLayout) {
                   case ImageLayout.Stretch:
                       result.Size = bounds.Size;
                       break;

                   case ImageLayout.None:
                       result.Size = backgroundImage.Size;
                       break;

                   case ImageLayout.Center:
                       result.Size = backgroundImage.Size;
                       Size szCtl = bounds.Size;
                       
                       if (szCtl.Width > result.Width) {
                           result.X = (szCtl.Width - result.Width) / 2;
                       }
                       if (szCtl.Height > result.Height) {
                           result.Y = (szCtl.Height - result.Height) / 2;
                       }
                       break;

                   case ImageLayout.Zoom:
                        Size imageSize = backgroundImage.Size;
                        float xRatio = (float)bounds.Width / (float)imageSize.Width;
                        float yRatio = (float)bounds.Height / (float)imageSize.Height;
                        if (xRatio < yRatio) {
                            //width should fill the entire bounds.
                            result.Width = bounds.Width;
                            // preserve the aspect ratio by multiplying the xRatio by the height
                            // adding .5 to round to the nearest pixel
                            result.Height = (int) ((imageSize.Height * xRatio) +.5);
                            if (bounds.Y >= 0)
                            {                               
                                result.Y = (bounds.Height - result.Height) /2;
                            }
                        }
                        else {
                            // width should fill the entire bounds
                            result.Height = bounds.Height;                       
                            // preserve the aspect ratio by multiplying the xRatio by the height
                            // adding .5 to round to the nearest pixel
                            result.Width = (int) ((imageSize.Width * yRatio) +.5);
                            if (bounds.X >= 0)
                            {
                                result.X = (bounds.Width - result.Width) /2;
                            }
                        }
                                              
                        break;
               }
           }
           return result;
       }
 public static PictureBox layout(this PictureBox pictureBox, ImageLayout imageLayout)
 {
     return pictureBox.invokeOnThread(
         () =>
             {
                 pictureBox.BackgroundImageLayout = imageLayout;
                 return pictureBox;
             });
 }
Exemple #6
0
 public void ConstructSpecial(string bitmapResName, ImageLayout bitmapLayout, string tagLine, Color tagColor)
 {
     GeneralLooks = SplashLooks.Special;
     lblMainVersion.Visible = false;
     picCup.Visible = false;
     lblTitle.Visible = false;
     lblSeparator.Visible = false;
     lblTagLine.Visible = false;
     ArrangeSpecial(bitmapResName, bitmapLayout, tagLine, tagColor);
 }
 public ImageMemoryBarrier(Image image, ImageLayout oldLayout, ImageLayout newLayout, AccessFlags sourceAccesMask, AccessFlags destinationAccessMask, uint sourceQueueFamilyIndex, uint destinationQueueFamilyIndex, ImageSubresourceRange subresourceRange)
 {
     StructureType = StructureType.ImageMemoryBarrier;
     Next = IntPtr.Zero;
     Image = image;
     SubresourceRange = subresourceRange;
     OldLayout = oldLayout;
     NewLayout = newLayout;
     SourceAccessMask = sourceAccesMask;
     DestinationAccessMask = destinationAccessMask;
     SourceQueueFamilyIndex = sourceQueueFamilyIndex;
     DestinationQueueFamilyIndex = destinationQueueFamilyIndex;
 }
Exemple #8
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="imageStreamCreator">The PE stream creator</param>
 /// <param name="imageLayout">Image layout</param>
 /// <param name="verify">Verify PE file data</param>
 public PEImage(IImageStreamCreator imageStreamCreator, ImageLayout imageLayout, bool verify)
 {
     try {
         this.imageStreamCreator = imageStreamCreator;
         this.peType = ConvertImageLayout(imageLayout);
         ResetReader();
         this.peInfo = new PEInfo(imageStream, verify);
         Initialize();
     }
     catch {
         Dispose();
         throw;
     }
 }
        /// <summary>
        /// Shows the dialog.
        /// </summary>
        /// <param name="labelText">The label text.</param>
        /// <param name="title">The title.</param>
        /// <param name="i">The i.</param>
        /// <param name="maxlen">The maxlen.</param>
        /// <param name="il">The il.</param>
        /// <returns></returns>
        public string[] ShowDialog(string labelText, string title, Image i, int maxlen = -1,
            ImageLayout il = ImageLayout.Center)
        {
            Text = title;
            label.Text = labelText;
            imagepanel.BackgroundImage = i;
            imagepanel.BackgroundImageLayout = il;

            if (maxlen >= 0)
                textbox.MaxLength = maxlen;

            ShowDialog();
            return returnvalue;
        }
Exemple #10
0
 public static void DrawBackgroundImage(
     Graphics g,
     Image backgroundImage,
     Color backColor,
     ImageLayout backgroundImageLayout,
     Rectangle bounds,
     Rectangle clipRect)
 {
     DrawBackgroundImage(
         g,
         backgroundImage,
         backColor,
         backgroundImageLayout,
         bounds,
         clipRect,
         Point.Empty,
         RightToLeft.No);
 }
 public static void DrawBackgroundImage(
     System.Drawing.Graphics g,
     Image backgroundImage,
     Color backColor,
     ImageLayout backgroundImageLayout,
     Rectangle bounds,
     Rectangle clipRect,
     Point scrollOffset)
 {
     DrawBackgroundImage(
         g,
         backgroundImage,
         backColor,
         backgroundImageLayout,
         bounds,
         clipRect,
         scrollOffset,
         RightToLeft.No);
 }
        public static void RenderBackgroundImage(this Graphics Graphics, Rectangle ClientRectangle, Color BackColor, Int32 Width, Int32 Height, ImageLayout ImageLayout, Image BackgroundImage)
        {
            Graphics.SetClip(ClientRectangle);
            Graphics.SmoothingMode = SmoothingMode.HighQuality;
            Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;

            Graphics.FillRectangle(new SolidBrush(BackColor), ClientRectangle);

            if (BackgroundImage != null) {
                switch (ImageLayout) {
                    case ImageLayout.Center:
                        Graphics.DrawImageUnscaled(BackgroundImage, Width / 2 - BackgroundImage.Width / 2, Height / 2 - BackgroundImage.Height / 2);
                        break;
                    case ImageLayout.None:
                        Graphics.DrawImageUnscaled(BackgroundImage, 0, 0);
                        break;
                    case ImageLayout.Stretch:
                        Graphics.DrawImage(BackgroundImage, 0, 0, Width, Height);
                        break;
                    case ImageLayout.Tile:
                        var pixelOffsetX = 0;
                        var pixelOffsetY = 0;
                        while (pixelOffsetX < Width) {
                            pixelOffsetY = 0;
                            while (pixelOffsetY < Height) {
                                Graphics.DrawImageUnscaled(BackgroundImage, pixelOffsetX, pixelOffsetY);
                                pixelOffsetY += BackgroundImage.Height;
                            }
                            pixelOffsetX += BackgroundImage.Width;
                        }
                        break;
                    case ImageLayout.Zoom:
                        if ((Single)(BackgroundImage.Width / Width) < (Single)(BackgroundImage.Height / Height))
                            Graphics.DrawImage(BackgroundImage, 0, 0, Height, Height);
                        else
                            Graphics.DrawImage(BackgroundImage, 0, 0, Width, Width);
                        break;
                }
            }
        }
Exemple #13
0
        public virtual void BejelformAlapInit(Bejelentkezo bejel, Bitmap bitmap, ImageLayout layout, string formszov, Icon icon)
        {
            InitializeComponent();
//            ErrorProvider.ContainerControl = containerControl1;
            this.panel1.BackgroundImage = bitmap;
            this.panel1.BackgroundImageLayout = layout;
            Bejel = bejel;
            alkid = Bejel.alkid;
            kezeloidkar = bejel.KezeloIdkArray;
            Sqlinterface.RendszerUserConn(Bejel.Rendszerconn, Bejel.Userconn);
            Sqlinterface.Select(kezelok, Bejel.Userconn, "KEZELOK", "", "", false);
            string maidat = DateTime.Today.ToShortDateString();
            if (maidat.EndsWith("."))
                maidat = maidat.Substring(0, maidat.Length - 1);
            if (bejel.Rgazdaid=="-1")             // kell egy rendszergazda
            {
                label2.Text = "Rendszergazda:";
                textBox2.UseSystemPasswordChar = false;
                kezelorow = null;
            }
            else
                textBox2.UseSystemPasswordChar = true;
            label5.Text = formszov;
            if (icon != null)
                this.Icon = icon;
            vanujceg = Bejel.Vanujceg;
            label4.Visible=vanujceg;
            comboBox1.Visible=vanujceg;
            if (vanujceg)
            {
                string ho_nap = ".01.01";
                int jelenev = DateTime.Today.Year;
                string[] itemek = new string[] { (jelenev - 1).ToString() + ho_nap, jelenev.ToString() + ho_nap, (jelenev + 1).ToString() + ho_nap };
                comboBox1.Items.AddRange(itemek);
                comboBox1.SelectedIndex = 1;
            }
 //           this.Focus();
            textBox1.Focus();
        }
Exemple #14
0
        /// <summary>
        /// Default constructor of the FreeDraw form.
        /// </summary>
        public FreeDrawing(Image background, ImageLayout layout, Size imageSize)
        {
            InitializeComponent();

            panelDrawing.BackgroundImage = background;
            panelDrawing.BackgroundImageLayout = layout;

            if (layout == ImageLayout.Tile)
            {
                panelDrawing.Width = imageSize.Width;
                panelDrawing.Height = imageSize.Height;

                this.BackgroundImage = null;
            }
            else
            {
                panelDrawing.Width = background.Width;
                panelDrawing.Height = background.Height;
            }

            //TODO: Get the real values.
            this.Width = panelDrawing.Width + 40;
            this.Height = panelDrawing.Height + 66 + 20;

            if (this.Width < 400) this.Width = 400;
            if (this.Height < 215) this.Height = 215;

            panelDrawing.EraseAll();

            #region Localize Labels

            this.Text = Resources.Title_FreeDrawing;
            lblBrushSize.Text = Resources.Label_BrushSize;
            lblEraserSize.Text = Resources.Label_EraserSize;

            #endregion
        }
Exemple #15
0
 /// <summary>
 /// Creates a <see cref="ModuleDefMD"/> instance from a reflection module
 /// </summary>
 /// <param name="mod">An existing reflection module</param>
 /// <param name="context">Module context or <c>null</c></param>
 /// <param name="imageLayout">Image layout of the module in memory</param>
 /// <returns>A new <see cref="ModuleDefMD"/> instance</returns>
 public static ModuleDefMD Load(System.Reflection.Module mod, ModuleContext context, ImageLayout imageLayout)
 {
     return Load(mod, new ModuleCreationOptions(context), imageLayout);
 }
Exemple #16
0
		static IPEType ConvertImageLayout(ImageLayout imageLayout) {
			switch (imageLayout) {
			case ImageLayout.File: return FileLayout;
			case ImageLayout.Memory: return MemoryLayout;
			default: throw new ArgumentException("imageLayout");
			}
		}
Exemple #17
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="baseAddr">Address of PE image</param>
		/// <param name="length">Length of PE image</param>
		/// <param name="imageLayout">Image layout</param>
		/// <param name="verify">Verify PE file data</param>
		public PEImage(IntPtr baseAddr, long length, ImageLayout imageLayout, bool verify)
			: this(new UnmanagedMemoryStreamCreator(baseAddr, length), imageLayout, verify) {
		}
Exemple #18
0
 /// <summary>
 /// 直接从内存中复制模块,不执行格式转换操作
 /// </summary>
 /// <param name="processId">进程ID</param>
 /// <param name="moduleHandle">模块句柄</param>
 /// <param name="imageLayout">模块在内存中的格式</param>
 /// <returns></returns>
 public static byte[] DirectCopy(uint processId, void *moduleHandle, ImageLayout imageLayout)
 {
     return(DirectCopy(processId, moduleHandle, imageLayout, false, null));
 }
Exemple #19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AttachmentReference"/> structure.
 /// </summary>
 /// <param name="attachment">
 /// The index of the attachment of the render pass, and corresponds to the index of the
 /// corresponding element in the <see cref="RenderPassCreateInfo.Attachments"/> array. If any
 /// color or depth/stencil attachments are <see cref="Constant.AttachmentUnused"/>, then no
 /// writes occur for those attachments.
 /// </param>
 /// <param name="layout">Specifies the layout the attachment uses during the subpass.</param>
 public AttachmentReference(int attachment, ImageLayout layout)
 {
     Attachment = attachment;
     Layout     = layout;
 }
		/// <summary>
		/// Create a <see cref="DotNetFile"/> instance
		/// </summary>
		/// <param name="addr">Address of a .NET file in memory</param>
		/// <param name="imageLayout">Image layout of the file in memory</param>
		/// <returns>A new <see cref="DotNetFile"/> instance</returns>
		public static DotNetFile Load(IntPtr addr, ImageLayout imageLayout) {
			IPEImage peImage = null;
			try {
				return Load(peImage = new PEImage(addr, imageLayout, true));
			}
			catch {
				if (peImage != null)
					peImage.Dispose();
				throw;
			}
		}
        /// <summary>
        /// 转换模块布局
        /// </summary>
        /// <param name="peImage"></param>
        /// <param name="fromImageLayout"></param>
        /// <param name="toImageLayout"></param>
        /// <returns></returns>
        public static byte[] ConvertImageLayout(byte[] peImage, ImageLayout fromImageLayout, ImageLayout toImageLayout)
        {
            switch (fromImageLayout)
            {
            case ImageLayout.File:
            case ImageLayout.Memory:
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(fromImageLayout));
            }
            switch (toImageLayout)
            {
            case ImageLayout.File:
            case ImageLayout.Memory:
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(toImageLayout));
            }
            if (peImage is null)
            {
                throw new ArgumentNullException(nameof(peImage));
            }

            if (fromImageLayout == toImageLayout)
            {
                return(peImage);
            }
            byte[] newPEImageData = new byte[GetImageSize(peImage, toImageLayout)];
            using (var peHeader = new PEImage(peImage, false)) {
                Buffer.BlockCopy(peImage, 0, newPEImageData, 0, (int)peHeader.ImageSectionHeaders.Last().EndOffset);
                // 复制PE头
                foreach (var sectionHeader in peHeader.ImageSectionHeaders)
                {
                    switch (toImageLayout)
                    {
                    case ImageLayout.File:
                        // ImageLayout.Memory -> ImageLayout.File
                        Buffer.BlockCopy(peImage, (int)sectionHeader.VirtualAddress, newPEImageData, (int)sectionHeader.PointerToRawData, (int)sectionHeader.SizeOfRawData);
                        break;

                    case ImageLayout.Memory:
                        // ImageLayout.File -> ImageLayout.Memory
                        Buffer.BlockCopy(peImage, (int)sectionHeader.PointerToRawData, newPEImageData, (int)sectionHeader.VirtualAddress, (int)sectionHeader.SizeOfRawData);
                        break;

                    default:
                        throw new NotSupportedException();
                    }
                }
            }
            return(newPEImageData);
        }
Exemple #22
0
        internal static void DrawBackgroundImage(Graphics g, Image backgroundImage, Color backColor, ImageLayout backgroundImageLayout, Rectangle bounds, Rectangle clipRect, Point scrollOffset, RightToLeft rightToLeft)
        {
            if (g == null)
            {
                throw new ArgumentNullException("g");
            }

            if (backgroundImageLayout == ImageLayout.Tile)
            {
                // tile

                using (TextureBrush textureBrush = new TextureBrush(backgroundImage, WrapMode.Tile)) {
                    // Make sure the brush origin matches the display rectangle, not the client rectangle,
                    // so the background image scrolls on AutoScroll forms.
                    if (scrollOffset != Point.Empty)
                    {
                        Matrix transform = textureBrush.Transform;
                        transform.Translate(scrollOffset.X, scrollOffset.Y);
                        textureBrush.Transform = transform;
                    }

                    g.FillRectangle(textureBrush, clipRect);
                }
            }
            else
            {
                // Center, Stretch, Zoom

                Rectangle imageRectangle = CalculateBackgroundImageRectangle(bounds, backgroundImage, backgroundImageLayout);

                //flip the coordinates only if we don't do any layout, since otherwise the image should be at the center of the
                //displayRectangle anyway.

                if (rightToLeft == RightToLeft.Yes && backgroundImageLayout == ImageLayout.None)
                {
                    imageRectangle.X += clipRect.Width - imageRectangle.Width;
                }

                // We fill the entire cliprect with the backcolor in case the image is transparent.
                // Also, if gdi+ can't quite fill the rect with the image, they will interpolate the remaining
                // pixels, and make them semi-transparent. This is another reason why we need to fill the entire rect.
                // If we didn't where ever the image was transparent, we would get garbage. VS Whidbey #504388
                using (SolidBrush brush = new SolidBrush(backColor)) {
                    g.FillRectangle(brush, clipRect);
                }

                if (!clipRect.Contains(imageRectangle))
                {
                    if (backgroundImageLayout == ImageLayout.Stretch || backgroundImageLayout == ImageLayout.Zoom)
                    {
                        imageRectangle.Intersect(clipRect);
                        g.DrawImage(backgroundImage, imageRectangle);
                    }
                    else if (backgroundImageLayout == ImageLayout.None)
                    {
                        imageRectangle.Offset(clipRect.Location);
                        Rectangle imageRect = imageRectangle;
                        imageRect.Intersect(clipRect);
                        Rectangle partOfImageToDraw = new Rectangle(Point.Empty, imageRect.Size);
                        g.DrawImage(backgroundImage, imageRect, partOfImageToDraw.X, partOfImageToDraw.Y, partOfImageToDraw.Width,
                                    partOfImageToDraw.Height, GraphicsUnit.Pixel);
                    }
                    else
                    {
                        Rectangle imageRect = imageRectangle;
                        imageRect.Intersect(clipRect);
                        Rectangle partOfImageToDraw = new Rectangle(new Point(imageRect.X - imageRectangle.X, imageRect.Y - imageRectangle.Y)
                                                                    , imageRect.Size);

                        g.DrawImage(backgroundImage, imageRect, partOfImageToDraw.X, partOfImageToDraw.Y, partOfImageToDraw.Width,
                                    partOfImageToDraw.Height, GraphicsUnit.Pixel);
                    }
                }
                else
                {
                    ImageAttributes imageAttrib = new ImageAttributes();
                    imageAttrib.SetWrapMode(WrapMode.TileFlipXY);
                    g.DrawImage(backgroundImage, imageRectangle, 0, 0, backgroundImage.Width, backgroundImage.Height, GraphicsUnit.Pixel, imageAttrib);
                    imageAttrib.Dispose();
                }
            }
        }
Exemple #23
0
        /// <summary>
        /// 直接从内存中复制模块,不执行格式转换操作
        /// </summary>
        /// <param name="processId">进程ID</param>
        /// <param name="moduleHandle">模块句柄</param>
        /// <param name="imageLayout">模块在内存中的格式</param>
        /// <param name="useSectionHeadersInFile">是否使用文件中的节头</param>
        /// <param name="alternativeToImagePath">如果无法正常获取模块路径,可提供备选模块路径</param>
        /// <returns></returns>
        public static byte[] DirectCopy(uint processId, void *moduleHandle, ImageLayout imageLayout, bool useSectionHeadersInFile, string alternativeToImagePath)
        {
            if (processId == 0)
            {
                throw new ArgumentNullException(nameof(processId));
            }
            if (moduleHandle is null)
            {
                throw new ArgumentNullException(nameof(moduleHandle));
            }
            if (useSectionHeadersInFile)
            {
                if (string.IsNullOrEmpty(alternativeToImagePath))
                {
                    alternativeToImagePath = null;
                }
                else
                {
                    if (!File.Exists(alternativeToImagePath))
                    {
                        throw new FileNotFoundException(nameof(alternativeToImagePath));
                    }
                }
            }

            using (NativeProcess process = NativeProcess.Open(processId)) {
                PageInfo firstPageInfo;
                string   imagePath;
                byte[]   peImageData;
                uint     imageSize;

                firstPageInfo = process.EnumeratePageInfos(moduleHandle, moduleHandle).First();
                if (useSectionHeadersInFile)
                {
                    imagePath = process.UnsafeGetModule(moduleHandle).ImagePath;
                    if (string.IsNullOrEmpty(imagePath) || !File.Exists(imagePath))
                    {
                        imagePath = alternativeToImagePath;
                    }
                }
                else
                {
                    imagePath = default;
                }
                // 获取模块路径(如果需要使用文件中的节头)
                if (useSectionHeadersInFile)
                {
                    imageSize = GetImageSize(File.ReadAllBytes(imagePath), imageLayout);
                }
                else
                {
                    byte[] peHeaderData;

                    peHeaderData = new byte[(uint)firstPageInfo.Size];
                    process.ReadBytes(moduleHandle, peHeaderData);
                    imageSize = GetImageSize(peHeaderData, imageLayout);
                }
                // 获取模块在内存中的大小
                peImageData = new byte[imageSize];
                switch (imageLayout)
                {
                case ImageLayout.File:
                    if (!process.TryReadBytes(firstPageInfo.Address, peImageData, 0, imageSize))
                    {
                        throw new InvalidOperationException();
                    }
                    break;

                case ImageLayout.Memory:
                    foreach (PageInfo pageInfo in process.EnumeratePageInfos(moduleHandle, (byte *)moduleHandle + imageSize))
                    {
                        uint offset;

                        offset = (uint)((ulong)pageInfo.Address - (ulong)moduleHandle);
                        process.TryReadBytes(pageInfo.Address, peImageData, offset, (uint)pageInfo.Size);
                    }
                    break;

                default:
                    throw new NotSupportedException();
                }
                // 转储
                if (useSectionHeadersInFile)
                {
                    using (PEImage peHeader = new PEImage(imagePath, false)) {
                        int    startOffset;
                        int    endOffset;
                        byte[] sectionHeadersData;

                        startOffset        = (int)peHeader.ImageSectionHeaders.First().StartOffset;
                        endOffset          = (int)peHeader.ImageSectionHeaders.Last().EndOffset;
                        sectionHeadersData = peHeader.CreateReader((FileOffset)startOffset).ReadBytes(endOffset - startOffset);
                        Buffer.BlockCopy(sectionHeadersData, 0, peImageData, startOffset, endOffset - startOffset);
                    }
                }
                // 替换节头(如果需要使用文件中的节头)
                return(peImageData);
            }
        }
Exemple #24
0
 internal static unsafe extern void vkCmdCopyBufferToImage(IntPtr commandBuffer, UInt64 srcBuffer, UInt64 dstImage, ImageLayout dstImageLayout, UInt32 regionCount, BufferImageCopy *pRegions);
Exemple #25
0
 internal static unsafe extern void vkCmdCopyImageToBuffer(IntPtr commandBuffer, UInt64 srcImage, ImageLayout srcImageLayout, UInt64 dstBuffer, UInt32 regionCount, BufferImageCopy *pRegions);
Exemple #26
0
 internal static unsafe extern void vkCmdBlitImage(IntPtr commandBuffer, UInt64 srcImage, ImageLayout srcImageLayout, UInt64 dstImage, ImageLayout dstImageLayout, UInt32 regionCount, ImageBlit *pRegions, Filter filter);
Exemple #27
0
 public PEImage(void *rawData, ImageLayout layout)
 {
     _rawData = rawData;
     _layout  = layout;
     Initialize();
 }
Exemple #28
0
 /// <summary>
 /// 创建 <see cref="IPEImage"/> 实例
 /// </summary>
 /// <param name="pPEImage"></param>
 /// <param name="imageLayout"></param>
 /// <returns></returns>
 public static IPEImage Create(IntPtr pPEImage, ImageLayout imageLayout)
 {
     return(Create((void *)pPEImage, imageLayout));
 }
Exemple #29
0
 /// <summary>
 /// Creates a <see cref="ModuleDefMD"/> instance from a memory location
 /// </summary>
 /// <param name="addr">Address of a .NET module/assembly</param>
 /// <param name="context">Module context or <c>null</c></param>
 /// <param name="imageLayout">Image layout of the file in memory</param>
 /// <returns>A new <see cref="ModuleDefMD"/> instance</returns>
 public static ModuleDefMD Load(IntPtr addr, ModuleContext context, ImageLayout imageLayout)
 {
     return Load(MetaDataCreator.Load(addr, imageLayout), new ModuleCreationOptions(context));
 }
Exemple #30
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="data">The PE file data</param>
 /// <param name="filename">Filename or null</param>
 /// <param name="imageLayout">Image layout</param>
 /// <param name="verify">Verify PE file data</param>
 public PEImage(byte[] data, string filename, ImageLayout imageLayout, bool verify)
     : this(new MemoryStreamCreator(data) { FileName = filename }, imageLayout, verify)
 {
 }
Exemple #31
0
        internal static Rectangle CalculateBackgroundImageRectangle(Rectangle bounds, Image backgroundImage, ImageLayout imageLayout)
        {
            Rectangle result = bounds;

            if (backgroundImage != null)
            {
                switch (imageLayout)
                {
                case ImageLayout.Stretch:
                    result.Size = bounds.Size;
                    break;

                case ImageLayout.None:
                    result.Size = backgroundImage.Size;
                    break;

                case ImageLayout.Center:
                    result.Size = backgroundImage.Size;
                    Size szCtl = bounds.Size;

                    if (szCtl.Width > result.Width)
                    {
                        result.X = (szCtl.Width - result.Width) / 2;
                    }

                    if (szCtl.Height > result.Height)
                    {
                        result.Y = (szCtl.Height - result.Height) / 2;
                    }

                    break;

                case ImageLayout.Zoom:
                    Size  imageSize = backgroundImage.Size;
                    float xRatio    = bounds.Width / (float)imageSize.Width;
                    float yRatio    = bounds.Height / (float)imageSize.Height;
                    if (xRatio < yRatio)
                    {
                        //width should fill the entire bounds.
                        result.Width = bounds.Width;
                        // preserve the aspect ratio by multiplying the xRatio by the height
                        // adding .5 to round to the nearest pixel
                        result.Height = (int)((imageSize.Height * xRatio) + .5);
                        if (bounds.Y >= 0)
                        {
                            result.Y = (bounds.Height - result.Height) / 2;
                        }
                    }
                    else
                    {
                        // width should fill the entire bounds
                        result.Height = bounds.Height;
                        // preserve the aspect ratio by multiplying the xRatio by the height
                        // adding .5 to round to the nearest pixel
                        result.Width = (int)((imageSize.Width * yRatio) + .5);
                        if (bounds.X >= 0)
                        {
                            result.X = (bounds.Width - result.Width) / 2;
                        }
                    }

                    break;
                }
            }

            return(result);
        }
Exemple #32
0
 protected eStyleBackgroundImage GetBackgroundImagePosition(ImageLayout layout)
 {
     if (layout == ImageLayout.Center)
         return eStyleBackgroundImage.Center;
     else if (layout == ImageLayout.None)
         return eStyleBackgroundImage.TopLeft;
     else if (layout == ImageLayout.Stretch)
         return eStyleBackgroundImage.Stretch;
     else if (layout == ImageLayout.Tile)
         return eStyleBackgroundImage.Tile;
     else if (layout == ImageLayout.Zoom)
         return eStyleBackgroundImage.Zoom;
     return eStyleBackgroundImage.TopLeft;
 }
Exemple #33
0
 internal static unsafe extern void vkCmdClearColorImage(IntPtr commandBuffer, UInt64 image, ImageLayout imageLayout, ClearColorValue *pColor, UInt32 rangeCount, ImageSubresourceRange *pRanges);
Exemple #34
0
 public void SetImageButtonInfo(ICollection <Image> images, int selectedIndex, String Text, ImageLayout mode = ImageLayout.Stretch, int fixedWidth = 0, int fixedHeight = 0)
 {
     this.ItemType         = ItemTypes.ImageButton;
     this.SelectedIndex    = selectedIndex;
     this.Images           = images;
     this.Text             = Text;
     this.ImageLayout      = mode;
     this.ImageFixedWidth  = fixedWidth;
     this.ImageFixedHeight = fixedHeight;
 }
Exemple #35
0
 public static void DrawBackgroundImage(Graphics g, Image backgroundImage, Color backColor, ImageLayout backgroundImageLayout, Rectangle bounds, Rectangle clipRect, Point scrollOffset)
 {
     ControlPaintEx.DrawBackgroundImage(g, backgroundImage, backColor, backgroundImageLayout, bounds, clipRect, scrollOffset, RightToLeft.No);
 }
Exemple #36
0
 internal static unsafe extern void vkCmdClearDepthStencilImage(IntPtr commandBuffer, UInt64 image, ImageLayout imageLayout, ClearDepthStencilValue *pDepthStencil, UInt32 rangeCount, ImageSubresourceRange *pRanges);
Exemple #37
0
 internal static unsafe extern void vkCmdResolveImage(IntPtr commandBuffer, UInt64 srcImage, ImageLayout srcImageLayout, UInt64 dstImage, ImageLayout dstImageLayout, UInt32 regionCount, ImageResolve *pRegions);
Exemple #38
0
        public string ExportImageFile(UndirectedGraph <int, Edge <int> > graph, GraphvizImageType imageType, string filepath, ImageLayout layout)
        {
            var graphviz = new GraphvizAlgorithm <int, Edge <int> >(graph)
            {
                ImageType = imageType
            };

            graphviz.FormatVertex += VertexFormatter;

            string fileInfo = $"{filepath} {layout}";

            graphviz.Generate(new FileDotEngine(), fileInfo);
            return(filepath);
        }
		/// <summary>
		/// Creates a <see cref="ModuleDefMD"/> instance from a memory location
		/// </summary>
		/// <param name="addr">Address of a .NET module/assembly</param>
		/// <param name="context">Module context or <c>null</c></param>
		/// <param name="imageLayout">Image layout of the file in memory</param>
		/// <returns>A new <see cref="ModuleDefMD"/> instance</returns>
		public static ModuleDefMD Load(IntPtr addr, ModuleContext context, ImageLayout imageLayout) {
			DotNetFile dnFile = null;
			try {
				return Load(dnFile = DotNetFile.Load(addr, imageLayout), context);
			}
			catch {
				if (dnFile != null)
					dnFile.Dispose();
				throw;
			}
		}
Exemple #40
0
        public string ExportImageFile(UndirectedGraph <string, TaggedEdge <string, string> > graph, GraphvizImageType imageType, string imageFilepath, ImageLayout layout)
        {
            var graphviz = new GraphvizAlgorithm <string, TaggedEdge <string, string> >(graph)
            {
                ImageType = imageType
            };

            graphviz.FormatVertex += FormatVertexHandler;
            graphviz.FormatEdge   += EdgeFormatter;

            string fileInfo = $"{imageFilepath} {layout}";

            graphviz.Generate(new FileDotEngine(), fileInfo);
            return(imageFilepath);
        }
Exemple #41
0
        private void SetImageLayout(Image image, ImageAspectFlags imageAspect, ImageLayout oldLayout, ImageLayout newLayout)
        {
            if (setupCommanBuffer == CommandBuffer.Null)
            {
                // Create command buffer
                CommandBuffer setupCommandBuffer;
                var allocateInfo = new CommandBufferAllocateInfo
                {
                    StructureType = StructureType.CommandBufferAllocateInfo,
                    CommandPool = commandPool,
                    Level = CommandBufferLevel.Primary,
                    CommandBufferCount = 1,
                };
                device.AllocateCommandBuffers(ref allocateInfo, &setupCommandBuffer);
                setupCommanBuffer = setupCommandBuffer;

                // Begin command buffer
                var inheritanceInfo = new CommandBufferInheritanceInfo { StructureType = StructureType.CommandBufferInheritanceInfo };
                var beginInfo = new CommandBufferBeginInfo
                {
                    StructureType = StructureType.CommandBufferBeginInfo,
                    InheritanceInfo = new IntPtr(&inheritanceInfo)
                };
                setupCommanBuffer.Begin(ref beginInfo);
            }

            var imageMemoryBarrier = new ImageMemoryBarrier
            {
                StructureType = StructureType.ImageMemoryBarrier,
                OldLayout = oldLayout,
                NewLayout = newLayout,
                Image = image,
                SubresourceRange = new ImageSubresourceRange(imageAspect, 0, 1, 0, 1)
            };

            switch (newLayout)
            {
                case ImageLayout.TransferDestinationOptimal:
                    imageMemoryBarrier.DestinationAccessMask = AccessFlags.TransferRead;
                    break;
                case ImageLayout.ColorAttachmentOptimal:
                    imageMemoryBarrier.DestinationAccessMask = AccessFlags.ColorAttachmentWrite;
                    break;
                case ImageLayout.DepthStencilAttachmentOptimal:
                    imageMemoryBarrier.DestinationAccessMask = AccessFlags.DepthStencilAttachmentWrite;
                    break;
                case ImageLayout.ShaderReadOnlyOptimal:
                    imageMemoryBarrier.DestinationAccessMask = AccessFlags.ShaderRead | AccessFlags.InputAttachmentRead;
                    break;
            }

            var sourceStages = PipelineStageFlags.TopOfPipe;
            var destinationStages = PipelineStageFlags.TopOfPipe;

            setupCommanBuffer.PipelineBarrier(sourceStages, destinationStages, DependencyFlags.None, 0, null, 0, null, 1, &imageMemoryBarrier);
        }
Exemple #42
0
            public string Run(GraphvizImageType imageType, string dot, string outputFilePath, ImageLayout layout)
            {
                File.WriteAllText(outputFilePath + ".dot", dot);
                string type = imageType.ToString().ToLower();

                if (layout != ImageLayout.none)
                {
                    // assumes graphviz is on the path:
                    string args = string.Format(CultureInfo.InvariantCulture, $"{outputFilePath}.dot -T{type} -o {outputFilePath}_{layout}.{type}");
                    System.Diagnostics.Process process = System.Diagnostics.Process.Start($"{layout}.exe", args);
                    if (true)
                    {
                        process.WaitForExit();
                    }
                }

                return(outputFilePath);
            }
 public ImageMemoryBarrier(Image image, ImageLayout oldLayout, ImageLayout newLayout, AccessFlags sourceAccesMask, AccessFlags destinationAccessMask, ImageSubresourceRange subresourceRange)
     : this(image, oldLayout, newLayout, sourceAccesMask, destinationAccessMask, Vulkan.QueueFamilyIgnored, Vulkan.QueueFamilyIgnored, subresourceRange)
 {
 }
Exemple #44
0
        public static void DrawBackgroundImage(
            Graphics g,
            Image backgroundImage,
            Color backColor,
            ImageLayout backgroundImageLayout,
            Rectangle bounds,
            Rectangle clipRect,
            Point scrollOffset,
            RightToLeft rightToLeft)
        {
            if (g == null)
            {
                throw new ArgumentNullException("g");
            }
            if (backgroundImageLayout == ImageLayout.Tile)
            {
                using (TextureBrush brush = new TextureBrush(backgroundImage, WrapMode.Tile))
                {
                    if (scrollOffset != Point.Empty)
                    {
                        Matrix transform = brush.Transform;
                        transform.Translate((float)scrollOffset.X, (float)scrollOffset.Y);
                        brush.Transform = transform;
                    }
                    g.FillRectangle(brush, clipRect);
                    return;
                }
            }
            Rectangle rect = CalculateBackgroundImageRectangle(
                bounds,
                backgroundImage,
                backgroundImageLayout);

            if ((rightToLeft == RightToLeft.Yes) &&
                (backgroundImageLayout == ImageLayout.None))
            {
                rect.X += clipRect.Width - rect.Width;
            }
            using (SolidBrush brush2 = new SolidBrush(backColor))
            {
                g.FillRectangle(brush2, clipRect);
            }
            if (!clipRect.Contains(rect))
            {
                if ((backgroundImageLayout == ImageLayout.Stretch) ||
                    (backgroundImageLayout == ImageLayout.Zoom))
                {
                    rect.Intersect(clipRect);
                    g.DrawImage(backgroundImage, rect);
                }
                else if (backgroundImageLayout == ImageLayout.None)
                {
                    rect.Offset(clipRect.Location);
                    Rectangle destRect = rect;
                    destRect.Intersect(clipRect);
                    Rectangle rectangle3 = new Rectangle(Point.Empty, destRect.Size);
                    g.DrawImage(
                        backgroundImage,
                        destRect,
                        rectangle3.X,
                        rectangle3.Y,
                        rectangle3.Width,
                        rectangle3.Height,
                        GraphicsUnit.Pixel);
                }
                else
                {
                    Rectangle rectangle4 = rect;
                    rectangle4.Intersect(clipRect);
                    Rectangle rectangle5 = new Rectangle(
                        new Point(rectangle4.X - rect.X, rectangle4.Y - rect.Y),
                        rectangle4.Size);
                    g.DrawImage(
                        backgroundImage,
                        rectangle4,
                        rectangle5.X,
                        rectangle5.Y,
                        rectangle5.Width,
                        rectangle5.Height,
                        GraphicsUnit.Pixel);
                }
            }
            else
            {
                ImageAttributes imageAttr = new ImageAttributes();
                imageAttr.SetWrapMode(WrapMode.TileFlipXY);
                g.DrawImage(
                    backgroundImage,
                    rect,
                    0,
                    0,
                    backgroundImage.Width,
                    backgroundImage.Height,
                    GraphicsUnit.Pixel,
                    imageAttr);
                imageAttr.Dispose();
            }
        }
		protected ToolStripItem (string text, Image image, EventHandler onClick, string name)
		{
			this.alignment = ToolStripItemAlignment.Left;
			this.anchor = AnchorStyles.Left | AnchorStyles.Top;
			this.auto_size = true;
			this.auto_tool_tip = this.DefaultAutoToolTip;
			this.available = true;
			this.back_color = Color.Empty;
			this.background_image_layout = ImageLayout.Tile;
			this.can_select = true;
			this.display_style = this.DefaultDisplayStyle;
			this.dock = DockStyle.None;
			this.enabled = true;
			this.fore_color = Color.Empty;
			this.image = image;
			this.image_align = ContentAlignment.MiddleCenter;
			this.image_index = -1;
			this.image_key = string.Empty;
			this.image_scaling = ToolStripItemImageScaling.SizeToFit;
			this.image_transparent_color = Color.Empty;
			this.margin = this.DefaultMargin;
			this.merge_action = MergeAction.Append;
			this.merge_index = -1;
			this.name = name;
			this.overflow = ToolStripItemOverflow.AsNeeded;
			this.padding = this.DefaultPadding;
			this.placement = ToolStripItemPlacement.None;
			this.right_to_left = RightToLeft.Inherit;
			this.bounds.Size = this.DefaultSize;
			this.text = text;
			this.text_align = ContentAlignment.MiddleCenter;
			this.text_direction = DefaultTextDirection;
			this.text_image_relation = TextImageRelation.ImageBeforeText;
			this.visible = true;

			this.Click += onClick;
			OnLayout (new LayoutEventArgs (null, string.Empty));
		}
Exemple #46
0
        public void AxHost_BackgroundImageLayout_SetInvalid_ThrowsInvalidEnumArgumentException(ImageLayout value)
        {
            var control = new SubAxHost("00000000-0000-0000-0000-000000000000");

            Assert.Throws <InvalidEnumArgumentException>("value", () => control.BackgroundImageLayout = value);
        }
Exemple #47
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="data">The PE file data</param>
		/// <param name="imageLayout">Image layout</param>
		/// <param name="verify">Verify PE file data</param>
		public PEImage(byte[] data, ImageLayout imageLayout, bool verify)
			: this(new MemoryStreamCreator(data), imageLayout, verify) {
		}
 /// <param name="Sampler">Sampler to write to the descriptor in case it's a SAMPLER or COMBINED_IMAGE_SAMPLER descriptor. Ignored otherwise.</param>
 /// <param name="ImageView">Image view to write to the descriptor in case it's a SAMPLED_IMAGE, STORAGE_IMAGE, COMBINED_IMAGE_SAMPLER, or INPUT_ATTACHMENT descriptor. Ignored otherwise.</param>
 /// <param name="ImageLayout">Layout the image is expected to be in when accessed using this descriptor (only used if imageView is not VK_NULL_HANDLE).</param>
 public DescriptorImageInfo(Sampler Sampler, ImageView ImageView, ImageLayout ImageLayout) : this()
 {
     this.Sampler     = Sampler;
     this.ImageView   = ImageView;
     this.ImageLayout = ImageLayout;
 }
Exemple #49
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="baseAddr">Address of PE image</param>
		/// <param name="imageLayout">Image layout</param>
		/// <param name="verify">Verify PE file data</param>
		public PEImage(IntPtr baseAddr, ImageLayout imageLayout, bool verify)
			: this(new UnmanagedMemoryStreamCreator(baseAddr, 0x10000), imageLayout, verify) {
			try {
				((UnmanagedMemoryStreamCreator)imageStreamCreator).Length = peInfo.GetImageSize();
				ResetReader();
			}
			catch {
				Dispose();
				throw;
			}
		}
Exemple #50
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="data">The PE file data</param>
 /// <param name="imageLayout">Image layout</param>
 /// <param name="verify">Verify PE file data</param>
 public PEImage(byte[] data, ImageLayout imageLayout, bool verify)
     : this(data, null, imageLayout, verify)
 {
 }
Exemple #51
0
 /// <summary>
 /// Creates a <see cref="ModuleDefMD"/> instance from a reflection module
 /// </summary>
 /// <param name="mod">An existing reflection module</param>
 /// <param name="options">Module creation options or <c>null</c></param>
 /// <param name="imageLayout">Image layout of the module in memory</param>
 /// <returns>A new <see cref="ModuleDefMD"/> instance</returns>
 public static ModuleDefMD Load(System.Reflection.Module mod, ModuleCreationOptions options, ImageLayout imageLayout)
 {
     IntPtr addr = Marshal.GetHINSTANCE(mod);
     if (addr == new IntPtr(-1))
         throw new InvalidOperationException(string.Format("Module {0} has no HINSTANCE", mod));
     return Load(addr, options, imageLayout);
 }
Exemple #52
0
        public void BackgroundImageLayout_SetInvalid_ThrowsInvalidEnumArgumentException(ImageLayout value)
        {
            var control = new ComboBox();

            Assert.Throws <InvalidEnumArgumentException>("value", () => control.BackgroundImageLayout = value);
        }
Exemple #53
0
 /// <summary>
 /// Creates a <see cref="ModuleDefMD"/> instance from a memory location
 /// </summary>
 /// <param name="addr">Address of a .NET module/assembly</param>
 /// <param name="options">Module creation options or <c>null</c></param>
 /// <param name="imageLayout">Image layout of the file in memory</param>
 /// <returns>A new <see cref="ModuleDefMD"/> instance</returns>
 public static ModuleDefMD Load(IntPtr addr, ModuleCreationOptions options, ImageLayout imageLayout)
 {
     return Load(MetaDataCreator.Load(addr, imageLayout), options);
 }
Exemple #54
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="data">The PE file data</param>
 /// <param name="imageLayout">Image layout</param>
 /// <param name="verify">Verify PE file data</param>
 public PEImage(byte[] data, ImageLayout imageLayout, bool verify)
     : this(new MemoryStreamCreator(data), imageLayout, verify)
 {
 }
		private void DrawBackground (Graphics g, Rectangle bounds, Image image, ImageLayout layout)
		{
			// Center and Tile don't matter if the image is larger than the control
			if (layout == ImageLayout.Center || layout == ImageLayout.Tile)
				if (image.Size.Width >= bounds.Size.Width && image.Size.Height >= bounds.Size.Height)
					layout = ImageLayout.None;
					
			switch (layout) {
				case ImageLayout.None:
					g.DrawImageUnscaledAndClipped (image, bounds);
					break;
				case ImageLayout.Tile:
					int x = 0;
					int y = 0;
					
					while (y < bounds.Height) {
						while (x < bounds.Width) {
							g.DrawImageUnscaledAndClipped (image, bounds);
							x += image.Width;	
						}
						x = 0;
						y += image.Height;
					}
					break;
				case ImageLayout.Center:
					Rectangle r = new Rectangle ((bounds.Size.Width - image.Size.Width) / 2, (bounds.Size.Height - image.Size.Height) / 2, image.Width, image.Height);
					g.DrawImageUnscaledAndClipped (image, r);
					break;
				case ImageLayout.Stretch:
					g.DrawImage (image, bounds);
					break;
				case ImageLayout.Zoom:
					if (((float)image.Height / (float)image.Width) < ((float)bounds.Height / (float)bounds.Width)) {
						Rectangle rzoom = new Rectangle (0, 0, bounds.Width, (int)((float)bounds.Width * ((float)image.Height / (float)image.Width)));
						rzoom.Y = (bounds.Height - rzoom.Height)/ 2;
						g.DrawImage (image, rzoom);
					} else {
						Rectangle rzoom = new Rectangle (0, 0, (int)((float)bounds.Height * ((float)image.Width / (float)image.Height)), bounds.Height);
						rzoom.X = (bounds.Width - rzoom.Width) / 2;
						g.DrawImage (image, rzoom);
					}
					break;
			}
		}
Exemple #56
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="baseAddr">Address of PE image</param>
 /// <param name="length">Length of PE image</param>
 /// <param name="imageLayout">Image layout</param>
 /// <param name="verify">Verify PE file data</param>
 public PEImage(IntPtr baseAddr, long length, ImageLayout imageLayout, bool verify)
     : this(new UnmanagedMemoryStreamCreator(baseAddr, length), imageLayout, verify)
 {
 }
Exemple #57
0
 public BejelformAlap (Bejelentkezo bejel, Bitmap bitmap, ImageLayout layout, string formszov,Icon icon)
 {
     BejelformAlapInit(bejel, bitmap, layout, formszov, icon);
 }
Exemple #58
0
        internal static Rectangle CalculateBackgroundImageRectangle(Rectangle bounds, Image backgroundImage, ImageLayout imageLayout)
        {
            Rectangle rectangle = bounds;

            checked
            {
                Rectangle result;
                if (backgroundImage != null)
                {
                    switch (imageLayout)
                    {
                    case ImageLayout.None:
                        rectangle.Size = backgroundImage.Size;
                        result         = rectangle;
                        return(result);

                    case ImageLayout.Tile:
                        result = rectangle;
                        return(result);

                    case ImageLayout.Center:
                    {
                        rectangle.Size = backgroundImage.Size;
                        Size size = bounds.Size;
                        if (size.Width > rectangle.Width)
                        {
                            rectangle.X = (size.Width - rectangle.Width) / 2;
                        }
                        if (size.Height > rectangle.Height)
                        {
                            rectangle.Y = (size.Height - rectangle.Height) / 2;
                        }
                        result = rectangle;
                        return(result);
                    }

                    case ImageLayout.Stretch:
                        rectangle.Size = bounds.Size;
                        result         = rectangle;
                        return(result);

                    case ImageLayout.Zoom:
                    {
                        Size  size2 = backgroundImage.Size;
                        float num   = (float)bounds.Width / (float)size2.Width;
                        float num2  = (float)bounds.Height / (float)size2.Height;
                        if (num >= num2)
                        {
                            rectangle.Height = bounds.Height;
                            rectangle.Width  = (int)unchecked ((double)((float)size2.Width * num2) + 0.5);
                            if (bounds.X >= 0)
                            {
                                rectangle.X = (bounds.Width - rectangle.Width) / 2;
                            }
                            result = rectangle;
                            return(result);
                        }
                        rectangle.Width  = bounds.Width;
                        rectangle.Height = (int)unchecked ((double)((float)size2.Height * num) + 0.5);
                        if (bounds.Y >= 0)
                        {
                            rectangle.Y = (bounds.Height - rectangle.Height) / 2;
                        }
                        result = rectangle;
                        return(result);
                    }
                    }
                }
                result = rectangle;
                return(result);
            }
        }
Exemple #59
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DescriptorImageInfo"/> structure.
 /// </summary>
 /// <param name="sampler">
 /// A sampler handle, and is used in descriptor updates for types <see
 /// cref="DescriptorType.Sampler"/> and <see cref="DescriptorType.CombinedImageSampler"/> if
 /// the binding being updated does not use immutable samplers.
 /// </param>
 /// <param name="imageView">
 /// An image view handle, and is used in descriptor updates for types <see
 /// cref="DescriptorType.SampledImage"/>, <see cref="DescriptorType.StorageImage"/>, <see
 /// cref="DescriptorType.CombinedImageSampler"/>, and <see cref="DescriptorType.InputAttachment"/>.
 /// </param>
 /// <param name="imageLayout">
 /// The layout that the image will be in at the time this descriptor is accessed. Is used in
 /// descriptor updates for types <see cref="DescriptorType.SampledImage"/>, <see
 /// cref="DescriptorType.StorageImage"/>, <see cref="DescriptorType.CombinedImageSampler"/>,
 /// and <see cref="DescriptorType.InputAttachment"/>.
 /// </param>
 public DescriptorImageInfo(Sampler sampler, ImageView imageView, ImageLayout imageLayout)
 {
     Sampler     = sampler;
     ImageView   = imageView;
     ImageLayout = imageLayout;
 }
Exemple #60
0
        public static void DrawBackgroundImage(Graphics g, Image backgroundImage, Color backColor, ImageLayout backgroundImageLayout, Rectangle bounds, Rectangle clipRect, Point scrollOffset, RightToLeft rightToLeft)
        {
            if (g == null)
            {
                throw new ArgumentNullException(nameof(g));
            }
            if (backgroundImageLayout == ImageLayout.Tile)
            {
                using (TextureBrush textureBrush = new TextureBrush(backgroundImage, WrapMode.Tile)) {
                    if (scrollOffset != Point.Empty)
                    {
                        Matrix transform = textureBrush.Transform;
                        transform.Translate((float)scrollOffset.X, (float)scrollOffset.Y);
                        textureBrush.Transform = transform;
                    }
                    g.FillRectangle(textureBrush, clipRect);
                    return;
                }
            }
            Rectangle rectangle = ControlPaintWrapper.CalculateBackgroundImageRectangle(bounds, backgroundImage, backgroundImageLayout);

            if (rightToLeft == RightToLeft.Yes && backgroundImageLayout == ImageLayout.None)
            {
                rectangle.X += clipRect.Width - rectangle.Width;
            }
            using (SolidBrush solidBrush = new SolidBrush(backColor)) {
                g.FillRectangle(solidBrush, clipRect);
            }
            if (!clipRect.Contains(rectangle))
            {
                if (backgroundImageLayout == ImageLayout.Stretch || backgroundImageLayout == ImageLayout.Zoom)
                {
                    rectangle.Intersect(clipRect);
                    g.DrawImage(backgroundImage, rectangle);
                    return;
                }
                if (backgroundImageLayout == ImageLayout.None)
                {
                    rectangle.Offset(clipRect.Location);
                    Rectangle destRect = rectangle;
                    destRect.Intersect(clipRect);
                    Rectangle rectangle2 = new Rectangle(Point.Empty, destRect.Size);
                    g.DrawImage(backgroundImage, destRect, rectangle2.X, rectangle2.Y, rectangle2.Width, rectangle2.Height, GraphicsUnit.Pixel);
                    return;
                }
                Rectangle destRect2 = rectangle;
                destRect2.Intersect(clipRect);
                Rectangle rectangle3 = new Rectangle(new Point(destRect2.X - rectangle.X, destRect2.Y - rectangle.Y), destRect2.Size);
                g.DrawImage(backgroundImage, destRect2, rectangle3.X, rectangle3.Y, rectangle3.Width, rectangle3.Height, GraphicsUnit.Pixel);
                return;
            }
            else
            {
                ImageAttributes imageAttributes = new ImageAttributes();
                imageAttributes.SetWrapMode(WrapMode.TileFlipXY);
                g.DrawImage(backgroundImage, rectangle, 0, 0, backgroundImage.Width, backgroundImage.Height, GraphicsUnit.Pixel, imageAttributes);
                imageAttributes.Dispose();
            }
        }