zoukankan      html  css  js  c++  java
  • 从资源文件中提取Icon对象到Image对象的小技巧。

    直接从资源文件中提取的Icon对象,常常要转换成image对象才能使用,如过用直接用Icon.ToBitmap()方法,就会发生丢色现象。
    通过下面的方法就不会了。
    private Image geticonimage(string name)
            
    {
                Icon icon 
    = null;
                Image image 
    = null;
                Stream stream 
    = new MemoryStream();

                
    try
                
    {
                    
    object iconobj = GetImageResource(name);
                
                    
    if (iconobj is Icon) 
                    
    {
                        icon 
    = (Icon)iconobj;
                    
                        icon.Save(stream);
                        image 
    = Image.FromStream(stream);
                    }

                    
    else
                    
    {
                        image 
    = (Image)iconobj;
                    }

                }

                
    catch
                
    {
                    stream.Close();
                    
    //throw e;
                    image = null;
                }

                
    return image;
                
            }
  • 相关阅读:
    Makefile.am文件配置
    PHP之mb_check_encoding使用
    PHP之mb_internal_encoding使用
    MarkDown编辑使用指南
    test
    [MySQL]修改mysql的root密码
    开启IT之旅_真理不死,信念永恒
    Python pickle 模块
    python注意点
    GAT2.0使用文档(组合接口测试)
  • 原文地址:https://www.cnblogs.com/rock_chen/p/286371.html
Copyright © 2011-2022 走看看