GDI+缩放图片

uses WinAPI.GDIPAPI, WinAPI.GDIPOBJ;

var
  Bitmap1: TGPBitmap;
  Bitmap2: TBitmap;
  Graphic: TGPGraphics;
begin
  Bitmap1 := TGPBitmap.Create('test.bmp');  // bmp, gif, jpeg, png...
  Bitmap2 := TBitmap.Create;
  with Bitmap2 do
    begin
      Width := Bitmap1.GetWidth * 2 div 3;  // shrink to 2/3 width
      Height := Bitmap1.GetHeight * 2 div 3;  // shrink to 2/3 height
      PixelFormat := pf32bit;
    end;
  Graphic := TGPGraphics.Create(Bitmap2.Canvas.Handle);
  Graphic.SetInterpolationMode(InterpolationModeHighQualityBicubic);  // bicubic resample
  Graphic.DrawImage(Bitmap1, 0, 0, Bitmap2.Width, Bitmap2.Height);
  Bitmap2.SaveToFile('test_resized.bmp');
  Graphic.Free;
  Bitmap2.Free;
  Bitmap1.Free;
end;

转自:https://bbs.youkuaiyun.com/topics/390695373

转载于:https://www.cnblogs.com/railgunman/p/9816236.html

使用GDI进行屏幕快速截图和缩放的Qt实现 使用GDI进行屏幕快速截图和缩放的Qt实现屏幕截图是许多图形应用程序中常见的功能之一。在Qt框架中,我们可以使用GDI(Graphics Device Interface)来实现快速的屏幕截图和缩放功能。本文将介绍如何使用Qt和GDI来实现这一功能,并提供相应的源代码。 阅读详情

相关推荐

GDI技术实现图片缩放

本文还有配套的精品资源,点击获取 简介:在Windows编程中,GDI允许开发者进行图形、文本和图像绘制。本示例展示如何运用GDI技术实现图片的放大和缩小功能,这对于GUI应用程序开发尤其重要。基本步骤包括加载图片,创建设备上下文,选择位图,应用图像缩放算法,并进行重绘。使用最近邻插值和双线性插值是常见的缩放技术。为了优化性能,应当注意合理选择插值算法并避免不必要的内存拷贝...

weixin_36184718的博客 1171

游戏编程笔记-起步(二)在窗口上绘图

游戏编程笔记-起步(二) 2.在窗口上绘图         看了我上面的分析,我想,很多朋友都迫不及待的想学这部分知识,原因是上面的知识实在太简单了,只要稍懂点算法的同胞们都可以看懂。关键是大家苦于英雄无勇武之地啊!学了n年的算法,做了n到算法题,却写不出一个如此简单的小游戏。 那好,让我们开始我们真正的游戏编程之旅吧! 1.概述        在Windows上绘图

游蓝海 的专栏 7950

Delphi7 及Delphi2010下用GDI+实现颜色渐变

Delphi7 及Delphi2010实现GDI+快速颜色渐变,里面附有D7和D2010版本的GDI.

GDI+图像的显示、裁剪、缩放、转置、镜像、旋转、变形

GDI+的配置: http://blog.youkuaiyun.com/lys07962000/article/details/8948996    void CXXDlg::OnPaint() { ....... // 图像的显示  /*CDC* pDC = GetDC();  Graphics graph(pDC->GetSafeHdc());  Image image(L"pic.jp

lys07962000的专栏 1万+

从标准到实战:详解IEC 61000-4-2下的ESD电路防护设计

本文深入解析IEC 61000-4-2标准下的ESD电路防护设计,从静电防护的基础原理到实战应用。详细介绍了接触放电与空气放电的区别、防护器件选型要点(如TVS管和压敏电阻)以及PCB布局的黄金法则,帮助工程师有效提升电子产品的抗静电能力,确保设备在严苛环境下的稳定运行。

weixin_33704234的博客 512

手把手教你搞定CAC会议投稿:从LaTeX模板到PDF eXpress避坑全流程

本文详细解析CAC会议投稿全流程,重点介绍LaTeX模板调整、Turnitin查重技巧及PDF eXpress校验避坑指南。通过实战案例和代码示例,帮助研究者高效完成IEEE格式论文投稿,避免常见技术性失误,提升投稿成功率。

weixin_29969209的博客 397

GDI+缩放图片方法小结(转)

GDI+缩放图片的方法

IT-----无以言退 1万+

.NET适配HarmonyOS进展 1. 前言

目前国产化系统浪潮下,适配鸿蒙是中国软件大势所趋,.NET作为最适合开发客户端语言之一,适配鸿蒙系统(HarmonyOS Next)是目前.NET开发者最关心的事情。我目前业余时间正在移植Avalonia到HarmonyOS,去年在.NET Conf CN上分享过,目前又取得一点进展,所以本文把所有问题进行整合与大家进行分享。

2301_76476890的博客 1461

使用GDI+来缩放图片

前提:获得相应的图片资源在WM_PAINT中获得窗口DC不要忘记使用完后释放CImage image(fileName); PAINTSTRUCT ps; HDC hdc = BeginPaint(hwndDlg, &ps); EndPaint(hwndDlg, &ps); 使用普通GDI来缩放图片的方式:image.StretchBlt(hdc, dstRect.left, dstRect.top, dstRect.Width(), dstRect.Height(), SRCCOPY); 使用GD

信箱神、得引擎 8654

手把手教你用Docker快速部署ZLMediaKit流媒体服务器(含WebRTC配置)

本文详细介绍了如何使用Docker快速部署ZLMediaKit流媒体服务器,并配置WebRTC功能。通过容器化部署,实现环境一致性、资源隔离和快速扩展,同时提供WebRTC专项配置、多协议推拉流实战测试及生产环境优化建议,帮助开发者高效搭建企业级流媒体平台。

agile9scrum的博客 203

STM32 A/B分区OTA升级实战:从原理到避坑指南

本文详细解析STM32 A/B分区OTA升级的核心原理与实战实现,涵盖双分区设计、Bootloader开发、固件传输验证及常见问题解决方案。重点介绍通过A/B分区实现无缝升级与安全回滚的机制,帮助开发者规避典型陷阱,提升嵌入式系统远程更新的可靠性与效率。

qqq44的博客 1109

GDI+ 的图片缩放, 一点纠正.

GDI+ 缩放图像 改正

neocane的专栏 798

Vivado工程芯片型号更换全流程:从IP更新到生成新bit文件(避坑指南)

本文详细介绍了Vivado工程中更换芯片型号的全流程,包括IP更新、约束文件适配和生成新bit文件的关键步骤。特别针对FPGA开发中常见的兼容性问题提供避坑指南,帮助开发者高效完成芯片迁移,确保设计稳定性和性能优化。

weixin_42549451的博客 300

使用GDI+缩放图片文件

总结一下个人所知道的使用GDI+缩放图片的方法. 方法一:最简单的,使用GetThumbnailImage,这个方法的局限性对支持内嵌缩略图的图片文件无效. 因为MSDN中提到:如果图片文件有内嵌的缩略图,那么就提取这个缩略图返回,否则就缩放原图片,不过我想对位图还是安全的:Bitmap * image = new Bitmap(L"MagicLinux.bmp");Image*

stone的备忘录 1921

解决com.kingbase8.util.KSQLException: This _connection has been closed.

一个消息管理系统,系统采用kingbase8数据库,数据库采用单体模式,后台应用也采用springboot单体模式。系统正式上线后,出现几个JDBC响应的异常信息: com.kingbase8.util.KSQLException: An I/O error occurred while sending to the backend. java.net.SocketTimeoutException: Read timed out.

qq_38127559的博客 2758

学Simulink——基于AI融合与智能调度的场实例:联邦学习支持的多卫星协同通信建模

本文介绍了一种基于联邦学习的多卫星协同通信Simulink建模方法。系统采用"星-星协同+星-地协调"架构,每颗卫星本地训练LSTM链路预测模型,地面中心通过FedAvg算法聚合模型参数。建模过程包括卫星通信模型构建、联邦学习机制设计、协同决策系统开发等步骤,支持隐私保护、高效协同和智能决策。仿真结果表明,该方法在预测准确率(89%)、吞吐量(56.7Mbps)等方面优于独立训练模式,接近集中式训练性能。该方案为大规模卫星星座的智能协同提供了仿真验证平台,未来可拓展去中心化联邦学习、异构

xiaoheshang_123的博客 212

GDI+实现图片缩放保存

转:http://cool.worm.blog.163.com/blog/static/64339006201141361913919/ 总结一下个人所知道的使用GDI+缩放图片的方法. 方法一:最简单的,使用GetThumbnailImage,这个方法的局限性对支持内嵌缩略图的图片文件无效.因为MSDN中提到:如果图片文件有内嵌的缩略图,那么就提取这个缩略图返回,否则就缩放原图片,不...

weixin_34029680的博客 154

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

vc++ GDI+实现以鼠标为中心缩放图片(并且可以拖动)

按以下步骤操作,即可实现。 1. 首先创建一个基于对话框的MFC程序,然后把下面两个文件分别保存为.h文件和 .cpp文件 //InitGdiplus.h #pragma once #include <GdiPlus.h> using namespace Gdiplus; class CInitGdiplus { public: CInitGdiplus(void); ~CInitGdiplus(void); private: ULONG_PTR m_Gdipl...

sky_lixf专栏 1750

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

[vb.net]使用GDI+绘图达到图片随鼠标缩放与移动的效果

[vb.net]使用GDI+绘图达到图片随鼠标缩放与移动的效果近日需要在软件中加入对图片的浏览功能,类似地图的拖拽及缩放操作。 网上大部分教程写的不够详细,对于初学者来讲不易理解。总结下要点,有二: (1)捕捉鼠标的点击操作和滚动操作以及鼠标的位移大小; (2)使用GDI+对缩放和移动的图片进行绘制。

u012370590的博客 4500

深度学习工具包 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');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

MFC GDI+实现以鼠标为中心缩放图片(并且可以拖动)

MFC GDI+实现以鼠标为中心缩放图片(并且可以拖动)在开始之前我们先了解一下GDI+中的坐标系统 世界坐标(World Coordinate) 是用来制作特定绘图自然模型的坐标。 页面坐标(Page Coordinate) 则是指绘图接口(例如窗体或控件) 使用的坐标系统。 设备坐标(Device Coordinate) 是在其上进行绘图的实体装置(例如屏幕或纸张) 所使用的坐标。 “世界变换”

greatchina01的专栏 7735

C GDI 图片显示、拖动、缩放自定义控件

C# GDI 图片显示、拖动、缩放自定义控件 去发现同类优质开源项目:https://gitcode.com/ 简介 本资源文件提供了一个用C#编写的自定义控件,该控件使用GDI技术实现了图片的居中显示、拖动和缩放功能。该控件支持显示BMP格式的图片,适用于需要在Windows窗体应用程序中展示图片并进行交互操作的场景。 功能特点 图片居中显示:图片在控件中自动居中显示,确保图片始终处于最佳展示...

gitblog_09783的博客 331
上一篇: T-Sql 递归查询(给定节点查所有父节点、所有子节点的方法)
下一篇: GDI+ 支持的图片文件格式
aowo7144
博客等级 码龄10年 5粉丝 0原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值