使用字典获取数据(图像) [英] fetching data(images) using dictionary

查看:89
本文介绍了使用字典获取数据(图像)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi
我在字典中从数据库中获得了一些图像,我想使用字典将相同图像移到画布的中间位置.
紧急需要帮助.....

解决方案

要将图像绘制到控件上,您应该覆盖该控件的OnPaint()方法. "c#"> 覆盖 void OnPaint(对象发送者,PaintEventArgs e) { System.Drawing.Image图片= _dictionary [keyToTheImage]; // 用于将图像放置在中心 int imageWidth = image.Width; int imageHeight = image.Height; e.Graphics.DrawImage( 图像, RectangleF( ( .Width-imageWidth)/2F, (.高度-imageHeight)/2F, imageWidth, imageHeight ) ); }


  string  itemPath = ;
 foreach ( var 项目 in  arrAllItems中的项目)
{
    如果(itemC [i] == item.id)
    {
         itemPath = item.imgPathLarge;
    }
} 



通过使用这些代码,我能够将数据库中的图像放入新画布中


hi
i have got some images in dictionary from database ,i want to fetch that same image on to the canvas in the middle position of it using dictionary.
need help urgently.....

解决方案

To draw an image onto a control, you should override that control''s OnPaint() method.

override void OnPaint(object sender, PaintEventArgs e)
{
    System.Drawing.Image image = _dictionary[keyToTheImage];

    // Used to place image onto center
    int imageWidth = image.Width;
    int imageHeight = image.Height;

    e.Graphics.DrawImage(
        image,
        new RectangleF(
            (this.Width - imageWidth) / 2F,
            (this.Height - imageHeight) / 2F,
            imageWidth,
            imageHeight
        )
    );
}


string itemPath = null;
foreach (var item in arrAllItems)
{
    if (itemC[i] == item.id)
    {
         itemPath = item.imgPathLarge;
    }
}



by using these code i am able to get the image from the database into the new canvas


这篇关于使用字典获取数据(图像)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆