下午在网上找了很久关于把资源文件中的位图导入到gdi+的Bitmap对象中的方法,但是网上的方法不是要写大段的代码,就是根本无法实现预期目标。最后通过我自己的尝试发现了一个简单易用的方法。就是先把位图导入到一个gdi对象CBitmap中然后通过其句柄加载到gdi+的Bitmap对象中。代码如下:
CBitmap bmp;
bmp.LoadBitmap(IDB_BITMAP1);
Bitmap bitmap((HBITMAP)bmp);
仅三行代码就够了!
墨衍会员
·
AI 创作全网分发
墨衍智能分发
本文由作者通过墨衍一键同步至各平台
1分发平台
2.7k累计阅读
2.7k平均单平台
已同步平台
优快云
微信公众号
微博
知乎
掘金
百家号
博客园
抖音
小红书
你的文章也可以这样分发
墨衍会员 ¥399起/年,写一次发全网
我也要 →
码龄20年
下午在网上找了很久关于把资源文件中的位图导入到gdi+的Bitmap对象中的方法,但是网上的方法不是要写大段的代码,就是根本无法实现预期目标。最后通过我自己的尝试发现了一个简单易用的方法。就是先把位图导入到一个gdi对象CBitmap中然后通过其句柄加载到gdi+的Bitmap对象中。代码如下:
CBitmap bmp;
bmp.LoadBitmap(IDB_BITMAP1);
Bitmap bitmap((HBITMAP)bmp);
仅三行代码就够了!
VN5620硬件接口介绍
VECTOR, VN5620, 诊断
CBitmap转换成GDI+的Bitmap (Image)
GDI与GDI+ 图像对象的转化 (2011-09-23 09:18:58) 转载▼ GDI对象与设备描述表(DC)息息相关,设备描述表是Windows使用的一个数据结构,用于存储具体设备能力和与如何在设备上重绘一些项目的有关属性信息。而且视频设备的设备描述表还与特定的窗口有关。首先你必须获得一个设备描述表句柄,然后在
电子产品设计中EFT防护的关键技术与实践
本文深入探讨了电子产品设计中EFT(快速瞬变脉冲群)防护的关键技术与实践。文章从EFT干扰的原理入手,系统阐述了通过优化PCB布局与地平面设计、构建电源与信号端口滤波防护电路、精选核心器件以及实施软件容错策略,来构建多层次、系统性的抗干扰防线,助力产品稳定通过严苛的电磁兼容测试。
MFC绘图CBitmap/HBITMAP/CImage/CStatic/CDC/HDC-绘制到Static的五种方法
采用提出要求和给出实现方法布置下面的实现,要求: 在Dialog中添加了一个图片组件框(绑定CStatic变量),要把某个图片显示到这个里面
给汽车芯片做‘体检’:手把手教你用IEC62380和SN29500估算功能安全失效率
本文详细介绍了如何使用IEC62380和SN29500标准估算汽车芯片的功能安全失效率,涵盖基础认知、方法论对比及实战计算。通过具体案例演示两种标准的应用流程,帮助工程师准确评估半导体器件的可靠性,确保符合ISO 26262标准要求。
傻白入门芯片设计,wafer/die/chip/cell(一)
芯片设计的一些基本概念
HBITMAP转化为Bitmap(使用GDI+保存带Alpha通道的图像)
Bitmap * ImageUtil :: CreateBitmapFromHBITMAP ( IN HBITMAP hBitmap ) { BITMAP bmp = { 0 }; if ( 0 == GetObject ( hBitmap , sizeof ( BITMAP ), ( LPVOID )& bmp ) ) { return FALSE ; } // Although we can ...
SmartFusion从FPGA到ARM系列教程
前言 本系列教程,将会以Microsemi SmartFusion一代芯片A2F200M3F为例,简单介绍片上ARM Cortex-M3 硬核 MCU 基本外设的使用,及其与FPGA逻辑模块进行交互的示例。 在学习片上硬核ARM Cortex-M3 MCU的开发之前,要先熟悉Microsemi Libero SoC开发环境的使用,可以参考:Microsemi Libero SoC系列教程 关于Microsemi SmartFusion混合型FPGA的介绍,可以参考:Microsemi SmartFusio.
gdiplus Bitmap 转 gdi BITMAP
1,通过GetHBITMAP()实现 在笔者的机子上,不管PixelFormat是8bit,24bit,还是32bit,通过GetHBITMAP得到的HBITMAP,永远是32bit. 通过以下方法查看BITMAP位深度: HBitmap to BITMAP: BITMAP bmp; ::GetObject(hbmp,sizeof(BITMAP),&bmp); 分析原因,可能是HBI
YOLOv12改进策略【独家融合改进】| MobileNetV4+BiFPN,轻松实现降参涨点,适用专栏内所有的骨干替换
可扩展的高效物体检测BiFPN(加权双向特征金字塔网络)
AI人工智能代理工作流 AI Agent WorkFlow:在股票市场预测中的应用
AI人工智能代理工作流 AI Agent WorkFlow:在股票市场预测中的应用 作者:禅与计算机程序设计艺术 / Zen and the Art of Computer Programming 关键词: AI Agent, W
GDI+中的图片处理类Image或Bitmap
与GDI相比,GDI+要强大非常多。对于Windows应用程序来说,用GDI是比較多的,也是比較熟练的,GDI+相对用的较少一点,可是如今GDI+的使用已经非常普遍了。GDI+支持各种类型图片的处理,比方常见的bmp、jpg、gif、png等类型,特别是GDI+处理png图片时有非常大的优势。有时我们须要将图片文件载入到内存中,然后进行UI的绘制,因为要支持多种类型的图片的载入,所以首先想到的是使用GDI+中的图片处理类Image或Bitmap。有时我们也须要将内存中的位图数据,保存成各种类型的图片文件,我
迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)
迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)
gdi+ Bitmap 与CBitmap HBITMAP
下午在网上找了很久关于把资源文件中的位图导入到gdi+的Bitmap对象中的方法,但是网上的方法不是要写大段的代码,就是根本无法实现预期目标。最后通过我自己的尝试发现了一个简单易用的方法。就是先把位图导入到一个gdi对象CBitmap中然后通过其句柄加载到gdi+的Bitmap对象中。代码如下: CBitmap bmp; bmp.LoadBitmap(IDB_BITMAP1); Bitmap
蓝牙模块HM-10手册
蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。
精雕软件(JDpaint) 5.5 绿色版
精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版
VC中使用GDI绘制位图BMP
VC中使用GDI绘制位图BMP 1.绘图基础 2.如何避免绘图过程的闪烁问题 3.关键色
深度学习工具包 DeepLearningToolbox
深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[](https://bitdeli.com/free "Bitdeli Badge")
14.4 GDI 位图对象 (I)
摘录于《Windows程序(第5版,珍藏版).CHarles.Petzold 著》P522 在本章前面曾提到 Windows 从 1.0 版就开始支持 GDI 位图对象。由于 Windows 3.0 引入了设备无关位图,因此 GDI 位图对象现在有时也叫做设备相关位图(device-dependent bitmap)或 DDB。我将尽量不用设备相关位图的全称,因为乍一看,这个词和
Direct2D开发:MFC下从资源文件中加载位图
转载请注明出处:http://www.cnblogs.com/ye-ming 0X01 概述: 相对于GDI处理界面,Direct2D有得天独厚的优势,下图就是Direct2D与GDI的效果对比,win32Direct2D开发有很多,但是到了mfc下,基本上就很少了,下的今天来讲一下在资源文件下加载图片的方法。 0X02 从资源加载位图: 1. 在资源文...
重温WIN32 API ------ 窗口上绘制位图文件
1 基本思路做界面仿真时,经常需要在窗口上贴图,随着图片数量的增多,通过资源文件中添加位图的方式会变得越来越不可控。所以本着“资源与程序分离“的原则,还是使用外部位图文件更加清晰明了。那么如何管理位图的贴图位置呢?如果写死到程序代码中,则又会导致耦合行过高的问题。容易想到解决方法有两个,一是使用一个单独的xml文件来记录图片文件名称和贴图位置的关系,二是直接把贴图位置信息包含进位图文件的文件名中。
WIndow下的图形GDI和GDI+编程总结-不断完善
GDI是一个抽象的接口,是一个关于图形显示的函数库。通过这个接口可以实现对图形的颜色、线条的粗细等属性的控制。它是我们的程序与计算机硬件之间的一个桥梁。 设备环境DC(Device Context 又称为设备上下文,也称为设备描述表)。它是一个关于如何绘制图形的方法的集合,它既可以绘制各种图形,也可以确定在应用窗口中绘制图形的方式,就是绘图模式和映射模式。在Win32编程中,设备环境是用HDC ...
WIN32汇编语言中位图的使用
说到位图。我们事实上非常早就接触过。从最早接触计算机,我们应该就知道有图片这个东西,然后再进一步说,图片在电脑上有好几种格式比方jpg. gif .png.pcx.bmp等等,当中bmp格式的图片文件事实上就是位图(windows的说法是DIB),位图文件也分为几种(由于存储的位置不同)。由于在学的是罗云斌老师的书籍,这次依然还拿他老人家的程序学习,拓展创新,学为己用。毕竟还不是...
WTL中GDI+支持资源文件加载
今天遇到一个小问题困扰了。就是GDI+加载资源位图的问题。由于把一些内容编译到exe程序中去,上网查找了一下,经验总结如下: 1. GDI+ 一定要使用UNICODE,所以 stdafx.h 中要先设置 #define UNICODE 2. 位图Bitmap可以直接加载 Bitmap * tmpBitmap = Bitmap::FromResource(_Module.GetResour
GDI导入位图并在位图上添加文本、描点、绘线
刚开始把位图导入资源文件中并修改ID为IDB_BACK 1、首先定义全局变量 HBITMAPhbmpBack=NULL; 2、在函数BOOLInitInstance(HINSTANCEhInstance,intnCmdShow)加载位图 在HWNDhWnd;后添加 hbmpBa...
GDI学习(2)
位图绘制 四部曲: *加载位图,从文件中加载位图 *建立兼容DC,建立一个与窗口设备环境DC兼容的内存设备环境DC *选用位图对象,内存DC使用步骤一中所建立的位图图像 *进行贴图,将内存DC内的内容贴到窗口DC中 1。加载位图 LoadImage()函数,不仅可以加载位图,还可以加载图标,光标等图像资源。 HANDLE WINAPI LoadImage( _In
DX笔记之五------游戏画面绘图之绘制位图
本系列文章由zhmxy555编写,转载请注明出处。 http://blog.youkuaiyun.com/zhmxy555/article/details/7335103 共四步 步骤一:加载位图 步骤二:建立与窗口DC兼容的内存DC 步骤三:选用位图对象 步骤四:贴图 详细步骤 步骤一:加载位图 要从文件加载位图,常常使用LoadImage()函数。 HANDLE LoadImage( ...
7494
8296
3927

被折叠的 条评论
为什么被折叠?



