Vb.net 如何在pictureedit上最小化或调整supertooltip上的图像大小

Vb.net 如何在pictureedit上最小化或调整supertooltip上的图像大小,vb.net,visual-studio-2012,devexpress,Vb.net,Visual Studio 2012,Devexpress,我的问题是,当我将光标指向图片时,他们的图片是一个带有图像的超级工具提示。但是超级工具提示中的图像太大了。如何以编程方式调整其大小 Public com As New MySql.Data.MySqlClient.MySqlCommand Public da As New MySql.Data.MySqlClient.MySqlDataAdapter Public dr As MySql.Data.MySqlClient.MySqlDataReader Public ds As DataSet

我的问题是,当我将光标指向图片时,他们的图片是一个带有图像的
超级工具提示。但是
超级工具提示中的图像太大了。如何以编程方式调整其大小

Public com As New MySql.Data.MySqlClient.MySqlCommand
Public da As New MySql.Data.MySqlClient.MySqlDataAdapter
Public dr As MySql.Data.MySqlClient.MySqlDataReader
Public ds As DataSet

Dim confirm As String

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  con.Close()
  con.Open()
  confirm = "select PPhoto From user_tbl"
  dr = com.ExecuteReader

  While dr.Read
    BarEditItem10.EditValue = Image.FromFile(pathfrm.PathPhoto.Text & dr.GetString("PPhoto"))
    Dim resImage As Image = Image.FromFile(pathfrm.PathPhoto.Text & dr.GetString("PPhoto"))
    Dim sTooltip2 As SuperToolTip = New SuperToolTip
    ' Create an object to initialize the SuperToolTip.
    Dim args As SuperToolTipSetupArgs = New SuperToolTipSetupArgs
    args.Title.Text = "Profile Picture"
    args.Contents.Text = "This is a Profile Picture"
    args.Contents.Image = resImage
    sTooltip2.Setup(args)
    BarEditItem10.SuperTip = sTooltip2
  End While
  con.Close()
End sub

当我将光标指向图片时(第二张图片)


我建议在将图像指定给超级工具提示之前重新调整图像大小。我在我的博客文章中详细介绍了如何做到这一点

本质上,我只是使用静态帮助器类来重新调整图像的大小:

static internal Image ScaleThumbnailImage(Image ImageToScale, int MaxWidth, int MaxHeight)
{
    double ratioX = (double)MaxWidth / ImageToScale.Width;
    double ratioY = (double)MaxHeight / ImageToScale.Height;
    double ratio = Math.Min(ratioX, ratioY);

    int newWidth = (int)(ImageToScale.Width * ratio);
    int newHeight = (int)(ImageToScale.Height * ratio);

    Image newImage = new Bitmap(newWidth, newHeight);
    Graphics.FromImage(newImage).DrawImage(ImageToScale, 0, 0, newWidth, newHeight);

    return newImage; 
} 
这是在ToolTipController的GetActiveObjectInfo事件处理程序中完成的:

private void toolTipController1_GetActiveObjectInfo(object sender, DevExpress.Utils.ToolTipControllerGetActiveObjectInfoEventArgs e)
{

Image MyImage = Image.FromFile("C:\\your_file_here.jpg");

ToolTipControlInfo toolTipInfo = null;
SuperToolTip toolTip = new SuperToolTip();

toolTipInfo = new ToolTipControlInfo(Guid.NewGuid(), "My Image");
ToolTipItem item1 = new ToolTipItem();

item1.Image = ScaleThumbnailImage(MyImage, 640, 480);

toolTip.Items.Add(item1);

toolTipInfo.SuperTip = toolTip;
e.Info = toolTipInfo;
}