用C++ Builder实现图像的特技显示

C++ builder 家用摄像头捕捉图像  我们来开发一个用家用摄像头捕捉图像的小程序。程序的主要代码如下,其中步骤说明将插入到代码当中。步骤一:在C++ builder中新建的Form上插入:2个button,一个panel,一个ComboBox和一个SaveDialg步骤二:编写代码//------------------------------------------------------------------- 阅读详情
 在网页、软件和游戏中,我们经常可以看到图像的各种特技显示,如中心扩散、百叶窗帘、右下推出等,这种动感图像显示,往往给人一种赏心悦目的感觉,给我们的应用程序增加了一些美感。在C++ Builder中,我们可以很容易地实现这些功能。下面以一个具体的例子,介绍实现中心扩散和百叶窗帘两种显示技巧,并说明在C++ Builder中处理图像的基本方法。
  在C++ Builder中新建一个工程,然后在窗体上添加一个Image图像控件,把它的Picture属性设置为一幅bmp图像,调节Image控件尺寸与图像的尺寸大小相同。再在窗体上添加两个Button控件,把Button1的Caption属性设置为“中心扩散”、Button2的Caption属性设置为“百叶窗帘”。
1. 对于“中心扩散”的实现,我们利用一定的算法,通过一定的循环次数,每次显示图像的一部分,从图像的中心位置开始显示,直到显示出图像的整体。



在Button1的OnClick事件中加入以下代码:
void _fastcall TForm1::Button1Click(TObject *Sender)
{
int i,left,top,width,height;
left = Image1->Left;
top = Image1->Top;
width = Image1->Width;
height = Image1->Height;
for (i = 0; i <= width; i++){
//通过图像的坐标选定图像的一部分
Image1->Left = left + (width - i)/2;
Image1->Top = top + height/2 - i*height/width/2;
Image1->Width = i;
Image1->Height = i*height/width;
Image1->Refresh();
}
}

2.对于“百叶窗帘”,我们可利用画布(Canvas)提供的矩形拷贝(CopyRect)方法在不同画布之间进行图像复制来实现,该方法声明如下:
  void _fastcall CopyRect(const Windows::TRect &&Dest, TCanvas*Canvas, const Windows::TRect &&Source);
把参数Canvas指定的源画布矩形区域Source复制到目标画布Dest的矩形区域。利用这种方法,再通过一定的算法,即可实现“百叶窗帘”的特技显示。
在Button2的OnClick事件中加入以下代码:
void _fastcall TForm1::Button2Click(TObject *Sender)
{
int inum,icount,i,j;
Graphics::TBitmap *pBitmap = new Graphics::TBitmap();
pBitmap->Height = Image1->Height;
pBitmap->Width = Image1->Width;
inum =16; //这是百叶窗的叶数
icount = pBitmap->Height /inum;
for (i = 1; i < icount; i++)
for (j = 0; j <= inum; j++){
pBitmap->Canvas->CopyRect(Rect(0,icount*j + i - 1, pBitmap->Width,icount*j + i),Image1->Canvas, Rect(0, icount*j + i - 1,pBitmap->Width, icount*j + i));
Form1->Canvas->Draw(Image1->Left,Image1->Top,pBitmap);
}
delete pBitmap;
}
按F9运行以上程序,即可获得所需要的“百叶窗帘”效果。
  Image图像控件还提供了另外一些很有用的属性和方法,大家可以充分利用C++ Builder的帮助,掌握了这些属性和方法,再利用一些程序算法,就可以随心所欲地写出各种图像特技显示的程序。在我们的应用程序开发中,就可以加入这些图像特技显示,为我们的应用程序增加一些光彩。
获取TBitMap图像缓冲区,提高图像处理速度   使用Dephi进行图像处理可以有多种方法,最常用的应该算是TBitmap,它提供方便的图像存取能力,结合Canvas可进行画线、画圆、图像拷贝等操作。不过在进行大量的图像处理操作时,为了获得更高的速度,我们希望能够直接对图像缓冲区进行读写。查阅Dephi的帮助手册没有发现直接取得整个图像缓冲区的功能,但提供的ScanLine属性可以取得指定行图像数据的指针,比较接近我们的要求,先看看ScanL 阅读详情

相关推荐

C++Builder 截取图片

<br />看网友们提问如何截取图片中的一部分,就查询帮助,写了一下:<br />void __fastcall TForm1::Button2Click(TObject *Sender) { int i_Width = 600 ; int i_Height = 600 ; Graphics::TBitmap *Bitmap = new Graphics::TBitmap; Graphics::TBitmap *Bit = new Graphics::TBitmap;

zhouzhangkui的专栏 3113

C++ builder 方法笔记

1.加载图片 bitmap->LordFromFile(Address)     2.创建缩略图 TBitmap* __fastcall :: bitmap->CreateThumbnail(width,height)

JoeJiao 731

C++ Builder 6实现简单验证码生成指南

本文还有配套的精品资源,点击获取 简介:验证码是网络安全的关键技术,能够有效阻止自动化程序的恶意操作。本教程将指导如何使用C++ Builder 6创建一个基础的验证码生成程序。通过生成随机字符串、绘制图像以及添加干扰元素来创建验证码,最终保存并显示该验证码,以便用户输入验证。教程涵盖了图形处理、随机数生成和字符串操作等技术要点,适合教学或初级项目使用。 1. 验...

weixin_32445049的博客 1099

c++ builder 学习(1)

c++ builder学习 1 界面设计 为对话框添加背景图片 方法 :在对话框中添加Additional中的image控件,然后找到其picture属性添加图片 按钮: 在c++ builder中按钮有三种TButton,TBitBtn,TSpeedbtn,后两者可以改变其背景图片,方法:点击其glyph属性 树形控件: String str[5]={"朋友","同事","家人",

u010442009的专栏 1417

C++ Builder将图片旋转90度示例程序 v1.01

C++ Builder将图片旋转90度示例程序 v1.01

飞牛NAS挂载115网盘避坑指南:为什么你的大文件总是传输失败?

本文深入解析了在飞牛NAS上通过AList挂载115网盘时,大文件传输失败的深层原因,包括风控机制、网络协议及兼容性问题。文章提供了从基础排查到高阶优化的系统性解决方案,并建议采用Kopia分片备份等终极策略,以实现稳定可靠的云端数据流转。

weixin_29306011的博客 1683

C++Builder 中大尺寸图象的显示技巧

---- 在C++Builder 中 利 用TImage 控 件 可 以 轻 松 地 读 入 并 显 示 图 象, 但TImage 控 件 本 身 不 可 以 接 收 输 入 焦 点, 也 没 带 有 滚 动 条, 在 显 示 超 出 显 示 区 域 范 围 的 大 图 象 时, 需 要 对TImage 控 件 进 行 加 强。 本 文 提 出 两 种 最 容 易 实 现 且 有 效 的 方 法,

好色天使的专栏 4792

WorldPop数据集

WorldPop数据集介绍

qq_43874102的博客 1万+

C++ Builder中制作图片边缘模糊效果的几种方法

制作图片边缘模糊效果,同时避免Cannot create a texture for DirecterD2D和OutOfmemory。

JoeJiao 1545

oracle 11.2.0.3.0 client下载,oracle64位客户端 Instant Client

oracle64位 客户端安装程序,Instant Client v11.2.0.3.0(64-bit)可以用,bo客户端需要配这个的,所以装了一个,64位操作系统中、不安装Oracle-32bit客户端,方便使用PLSQL Developer(不支持64bit位Oracle客户端)安装教程安装配置instantclient下载后,解压到D:\Oracle\instantclient_11_2(特...

weixin_42573757的博客 4516

《QGIS快速入门与应用基础》【专栏完整目录】

《QGIS快速入门与应用基础》第一卷专栏完整目录,覆盖 001–328 全部篇目与附录,逐篇可跳转。

LuckyHanMo的博客 1299

C++ Builder 第七章 图形

本章涵盖了VCL的图形编程的基本知识 .vcl封装了Windows图形设备接口,或GDI。 GDI 的方案可能是一个微妙而危险的进程。 塔梅斯这项技术并使其非常容易使用。在下面的页面中,您将了解到:  The TCanvas object 在画布对象 Painting shapes on the screen 在屏幕上画形状 Working with col

jhui163的专栏 4984

YOLOv8-Pose 姿态识别 RK3588 实战:从模型训练到 RKNN 部署,精度与推理速度双提升

本教程从YOLOv8-pose模型的姿态识别训练,到RK3588的边缘量化部署,为你打造了一套“高精度+高实时性+低成本”的人体姿态分析解决方案。无论是健身动作纠正、智能安防行为检测,还是工业人员姿态监控,这套技术都能直接复用——你只需替换数据集与业务逻辑,即可快速落地专属的边缘AI姿态识别系统。如果你在实践中遇到任何卡点,欢迎随时交流。记住,人体姿态识别的价值在于“关键点准、推理快、部署易”,而这三者的平衡,正是你通过本教程能掌握的核心能力。

FJN110的博客 363

c++builder自绘按钮

想找自绘按钮的代码,找了很久,下载到了一个。作者不记得了。不过有点不完美。原代码没有处理,鼠标放在按钮上,按钮高亮显示功能。因此,增加了两个鼠标的CM_MOUSEENTERH和CM_MOUSELEAVE事件。 #ifndef Unit12H #define Unit12H //------------------------------------------------------------

chinayu2007的专栏 2946

宇树G1语音助手完整开发指南(上)——从零构建智能知识库对话系统

本文将详细介绍如何为宇树G1人形机器人开发一个,实现"唤醒 → 对话 → 查询 → 回复"的智能助手功能。

m0_47999117的博客 783

【本地部署实战】LM Studio深度使用指南:从环境搭建到模型调优

LM Studio通过极简的操作流程和强大的生态兼容性,让本地部署大模型成为可能。随着M4芯片的发布和CUDA 12.0的优化,未来本地化AI开发将迎来新的爆发点。建议开发者关注官方Discord社区(https://discord.gg/lmstudio)获取最新模型支持信息。

远程部署调试 运行安装 项目调试 二次开发 项目技术新 持续迭代 部分源码免费分享 8749

GDI+ 在Delphi、C++Builder程序的应用 -- IStream

        GDI+的Image及派生类中涉及到IStream流,在Delphi和C++Builder中广泛使用的TStream不能直接作为参数进行传递,VCL提供了一个TStreamAdapter类,用于把VCL流TStream转换为IStream。TStreamAdapter的构造过程原型如下:  constructor Create(Stream: TStream; Ownershi

闲人阿发伯的业余编程心得 1万+

RK3588 部署 YOLO26-Pose 人体姿态检测:Windows Docker 环境全流程

YOLO26-Pose 在 RK3588 上的部署流程是 PC 端 ONNX 导出 → RKNN 转换(INT8 量化)→ 板端推理。INT8 量化后 YOLO26s-Pose 约 35ms,YOLO26n-Pose 约 15ms,可以覆盖实时姿态检测的需求。后处理是 Python 实现的常见瓶颈——如果帧率不达标,先用 npy 保存模型输出在 PC 上验证解析逻辑的正确性,确认无误后再迁移到 C++ 实现。

m0_64661770的博客 542

C++ builder XE10.2开发安卓软件listview组件设置

1、先设置好,ItemAppearance的属性ItemAppearance、ItemEditAppearance为Custom; 2、 加入载入数据 void __fastcall TForm1::Button1Click(TObject *Sender) { for (int i = 1; i <= 20; i++) { TListViewItem * item = ListView1->Items->Add(); item...

lzksword的专栏 558

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

深度学习工具包 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")

C++位图(Bitmap)

首先普及一下将要用到的逻辑运算符号:【与】运算符号为 & ,运算法则为遇0得0。也就是说只要有0,结果即为0。【或】运算符号为 | ,就是一个竖线,运算法则为遇1得1。也就是说,只要有1,结果就为1。【非】预算符号为 ~,就是一个波浪线,运算法则为按位取反,也就是遇1取0,遇0取1,即 ~1 = 0 , ~0 = 1;【异或】运算符号为 ^,就是一个乘方符号,运算法则为相同取0,不同取1。异或运算,关键在异上面,异为1,否则为0。 位图 (Bitmap) 是一种基于位操作的数据结构,用于表示一

chen_ever的博客 3693

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

ListView选中更改背景颜色

1.在Adapter中创建方法,记录点击位置。 2.在ListView点击事件中,调用方法,把点击的position传给Adapter。 3.在Adapter的getView()方法中,进行判断,控制显示对应的颜色。

incredible 563

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

C++builder 使用cximage对图像文件进行操作

1. 首先,去下载cximage源代码http://www.xdp.it网站上有,需要下载for BC6的,详细地址:http://www.xdp.it/cximage/cximage599c_bc6.zip或者,下载完之后,使用CB6.0编译.直接打开cximage599c_bc6/CxImage/cximage.bpr就可以,编译完后,会生成好几个LIB,每个目录下都有2.将这些lib文件

zhuqinwu的专栏 2210

C++Builder的基本功能

C++Builder的基本功能 我们用高级语言写程序,我们很得意,因为高级语言比较接近人类的语言,使我们用起来得心应手,所以我们当然得意。但我们更得意的一定是让程序代码赶快变成可执行文件。 无论是在写代码的过程,还是最后要编译成可执行文件,都需要有一个工具存在。这一工具一般称为编程集成环境(IDE)。...

huang714的专栏 1万+
上一篇: C++BUILDER中一些实现界面效果的技巧
下一篇: C++Builder处理Windows讯息
iiprogram
博客等级 码龄25年 1068粉丝 1515原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值