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

推荐订阅源

美团技术团队
罗磊的独立博客
SecWiki News
SecWiki News
The Register - Security
The Register - Security
The GitHub Blog
The GitHub Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
S
Schneier on Security
IT之家
IT之家
博客园 - 聂微东
T
The Exploit Database - CXSecurity.com
Recorded Future
Recorded Future
大猫的无限游戏
大猫的无限游戏
Know Your Adversary
Know Your Adversary
Latest news
Latest news
Vercel News
Vercel News
G
GRAHAM CLULEY
D
DataBreaches.Net
D
Darknet – Hacking Tools, Hacker News & Cyber Security
S
SegmentFault 最新的问题
博客园_首页
雷峰网
雷峰网
T
Tenable Blog
Spread Privacy
Spread Privacy
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
酷 壳 – CoolShell
酷 壳 – CoolShell
Cisco Talos Blog
Cisco Talos Blog
V
Visual Studio Blog
J
Java Code Geeks
博客园 - Franky
The Cloudflare Blog
Apple Machine Learning Research
Apple Machine Learning Research
C
CERT Recently Published Vulnerability Notes
T
Threatpost
Google DeepMind News
Google DeepMind News
F
Fortinet All Blogs
P
Privacy International News Feed
T
Threat Research - Cisco Blogs
T
The Blog of Author Tim Ferriss
V
Vulnerabilities – Threatpost
Recent Announcements
Recent Announcements
Blog — PlanetScale
Blog — PlanetScale
Security Latest
Security Latest
U
Unit 42
M
MIT News - Artificial intelligence
Y
Y Combinator Blog
K
Kaspersky official blog
有赞技术团队
有赞技术团队
B
Blog
腾讯CDC

博客园 - oo复oo

Asp.net Ajax 中的脚本错误: 'Sys'未定义 的解决方法 学习xml 之"实体"篇 - oo复oo - 博客园 该死的dudu加速器广告终于被清除了 第一次安装DNN 网站 网站总算安装成功了 开始行动了 .net 2.0 访问Oracle --与Sql Server的差异,注意事项,常见异常 Ado.net 与NHibernate的关系? 一个基于.net Framework 2.0 的图形处理工具 贴一篇关于asp.net性能计数器的文章,供以后参考 你的.net 2.0 真的能与1.1 安全正确地运行在同一台电脑上吗? 小心Server Application Unavailable 错误 贴一篇关于asp.net性能计数器的文章,供以后参考 使用@Page指令的Src 属性 简化对老版本的 asp.net程序的维护 新年到,祝大家新年快乐 WebRequest 使用不当可能会造成线程阻塞 学习xml 之"刘姥姥进大观园" -----xml概述 学习xml 之" 给个理由先" 此gmail非彼gmail 通过串口编程控制打印机
在.net 中调用win32API :GetBitmapBits ,获取位图的颜色数组,发送给打印机。
oo复oo · 2005-07-13 · via 博客园 - oo复oo

      这段时间处理打印问题,需要得到一个黑白的位图文件的颜色信息。 目前只发现使用Win32的API: GetBitmapBits函数可以实现。但经过N次的试验后,总是失败。

    Win32 API  GetBitmapBits函数的定义:

   下面是我的代码:

    在.net 中定义的拖管方法:

[DllImport("gdi32", CharSet=CharSet.Auto)]
        
static extern bool GetBitmapBits(IntPtr imgFile,int cbBuf,out byte[] ImgByte);

  其中的第一个参数 IntPtr  我是调用Image.GetHbitmap()取得,但取到的值都是很大的整型,感觉不正常。

System.Drawing.Bitmap bitmap=new System.Drawing.Bitmap("d:\\test.bmp");
            IntPtr inp
=bitmap.GetHbitmap();


 

调用托管方法

  

    以上代码总是出错,找不到原因,现在有以下几个问题请教
    1、以上代码在哪个地方错了?
    2、GetBitmapBits中的最后一个参数是LPVOID,在.net 中用一个byte数组是否可行?
    3、第二个参数是指要复制的字节长度,在我没有得到颜色数组的情况下,我应该给这个参数一个什么值?

       希望有了解的朋友能帮助我。研究了1天了。没找到答案。谢谢!