zoukankan      html  css  js  c++  java
  • GetManifestResourceStream得到的Stream是null的解决

    Ans: 参考

    http://blog.csdn.net/blue_sky_blue_heart/archive/2005/12/17/555139.aspx

    System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();
    // Note that the name for the embedded resource is case sensitive and must match the file name.
    Bitmap bmp = new Bitmap(asm.GetManifestResourceStream(asm.GetName().Name + "." + "pic.png"));
    e.Graphics.DrawImage(bmp, 
    58new Rectangle(00, bmp.Width, bmp.Height), GraphicsUnit.Pixel);


    其实最主要的是在将图片资源的属性设置为“嵌入的资源”:“属性-生成操作-嵌入的资源”

    注意GetManifestResourceStream函数的参数:asm.GetName().Name获得的只是当前命名空间的名称,如果在“pic.png”图片在当前工程的Photo目录下,那么该参数就该写成asm.GetName().Name + "." + "Photo" + "." + " pic.png"





    --------------------------------------------------

    李森 – listen
    E-mail:  lisencool@gmail.com

    声明:
    这里集中了在WinCEWindows Mobile开发中的一些基本常识。我很乐意和大家分享,也希望大家提出意见,并给我投稿,我会第一时间替您发表并署上您的大名!

    Announce:
    Here collects general knowledge on WinCE and Windows mobile. I 'm very glad to share them with all friends, and also hope you can share your problems and opinions and contribute articles to me to share with others. I'll publish your articles and sign your name at the first time.

     

  • 相关阅读:
    HTML5:超文本标记语言
    Redis持久化
    ACID VS BASE+CAP
    Redis
    NoSQL(Redis、Menchche、MongoDB)
    transient关键字
    Struts2声明式验证相关问题
    struts2国际化相关问题
    Struts2
    SSH整合的详细步骤
  • 原文地址:https://www.cnblogs.com/Lisen/p/1566799.html
Copyright © 2011-2022 走看看