惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

量子位
Vercel News
Vercel News
Microsoft Azure Blog
Microsoft Azure Blog
爱范儿
爱范儿
N
Netflix TechBlog - Medium
Google DeepMind News
Google DeepMind News
H
Help Net Security
罗磊的独立博客
The Cloudflare Blog
J
Java Code Geeks
博客园 - 叶小钗
I
InfoQ
B
Blog
Blog — PlanetScale
Blog — PlanetScale
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
腾讯CDC
月光博客
月光博客
博客园_首页
雷峰网
雷峰网
M
MIT News - Artificial intelligence
博客园 - 【当耐特】
美团技术团队
T
The Blog of Author Tim Ferriss
博客园 - 司徒正美

博客园 - amey

不错的blog 系统内置的图片资源---android.R.drawable android 开发不容错过的网站 Android风格与主题(style and theme) Android中的长度单位详解 startActivity 出错 main cannot be resolved or is not a field Android DDMS如何使用? 网上绝无仅有的Log分析教程及例子(转) 如何控制Android不锁屏 Android系统名词解释汇总 - Android讨论区::91手机论坛-91手机娱乐门户 Android开发中的drawable-(hdpi,mdpi,ldpi)和WVGA,HVGA,QVGA的区别以及联系 每一位想有所成就的程序员都必须知道的15件事(转载) MSDN一篇很好的WCF入门教程(转) 使用Refactor找回被覆盖的代码 第一次制作.hlp文件格式的帮助文档 windows应用程序名要与配置文件命名一致 如何控制静态Form类与普通的Form类之间的切换 [windows编程]error C2664: “MessageBoxW”: 不能将参数 2 从“char *”转换为“LPCWSTR” - amey
GetManifestResourceStream的使用
amey · 2011-02-11 · via 博客园 - amey

VB.Net中资源的名称为:项目默认命名空间.资源文件名

C#中则是:项目命名空间.资源文件所在文件夹名.资源文件名

例:
[C# code]
Assembly assm = this.GetType().Assembly.GetExecutingAssembly();
istr = assm.GetManifestResourceStream("项目命名空间.资源文件所在文件夹名.资源文件名");

eg:

 public Bitmap LoadBitmap(string imageName, int width, int height)
        {
            return LoadBitmap(this.GetType().Assembly.GetManifestResourceStream("Sample.Images." + imageName + ScreenFactorSuffix + ".png"), width, height);
        }

        public Bitmap LoadBitmap(Stream s, int width, int height)
        {
            Bitmap dib = new Bitmap(s);
            Bitmap ddb = new Bitmap(width * ScreenFactor, height * ScreenFactor);
            Graphics g = Graphics.FromImage(ddb);
            g.DrawImage(dib, new Rectangle(0, 0, width * ScreenFactor, height * ScreenFactor), new Rectangle(0, 0, dib.Width, dib.Height), GraphicsUnit.Pixel);
            dib.Dispose();
            return ddb;
        }