呵呵 以前还真没有认真研究过图像处理这块儿东西(其实这回也只是了解一些皮毛),研究一下,才发现自己做这样的大头贴程序还算简单

具体的程序没写完,只是稍微写了一些想法...

大头贴说白了就是个图像叠加程序,两步动作,一个是抠像/照相程序,一个是图像处理及其叠加

抠像比较复杂,不去研究,照相都有现成的Dll,用不着研究,图像处理都有标准算法,以后上了大学会研究

现在主要就看看图像叠加

背景模板是Gif文件,有一块设置为Transparent的区域,也就是用来放大头的

一种方式是直接用Canvas的Draw方法或者是CopyRect方法把模板图像花在大头上边,设置好Transparent颜色,就行了 下边是网上拉下来的一段程序(不是我写的,我写的程序比这个漂亮多了 呵呵)

procedure TForm1.Button2Click(Sender: TObject);
var
  b,s:tbitmap;
begin
  b:=tBitmap.create;
  s:=tBitmap.create;
  s.TransparentMode :=tmAuto;  //可以自己设置透明色
  b.LoadFromFile('c:/windows/forest.bmp');  //大的
  s.LoadFromFile('c:/windows/circles.bmp'); //小的
  b.canvas.copymode:=cmSrcCopy;  //选择合适的
  s.PixelFormat:=pf32bit;  //避免调色板问题
  b.PixelFormat:=pf32bit;
  //b.canvas.draw(b.width-s.width,b.height-s.height,s); 另一种做法
  b.Canvas.CopyRect (rect(b.width-s.width,b.height-s.height,b.width,b.height),
    s.canvas,rect(0,0,s.width,s.height));
  Canvas.Draw (0,0,b);
  b.savetofile('d:/temp.bmp');
  b.free;
  s.free;
end;

还找到一个API函数,BitBlt 以前听说过,倒是没有研究过,下面是MSDN里边的摘录

The BitBlt function performs a bit-block transfer of the color data corresponding to a rectangle of pixels from the specified source device context into a destination device context.

BOOL BitBlt(
HDC hdcDest, // handle to destination DC
  int nXDest,  // x-coord of destination upper-left corner
  int nYDest,  // y-coord of destination upper-left corner
  int nWidth,  // width of destination rectangle
  int nHeight, // height of destination rectangle
  HDC hdcSrc,  // handle to source DC
  int nXSrc,   // x-coordinate of source upper-left corner
  int nYSrc,   // y-coordinate of source upper-left corner
  DWORD dwRop  // raster operation code
);

Parameters

hdcDest
[in] Handle to the destination device context.
nXDest
[in] Specifies the x-coordinate, in logical units, of the upper-left corner of the destination rectangle.
nYDest
[in] Specifies the y-coordinate, in logical units, of the upper-left corner of the destination rectangle.
nWidth
[in] Specifies the width, in logical units, of the source and destination rectangles.
nHeight
[in] Specifies the height, in logical units, of the source and the destination rectangles.
hdcSrc
[in] Handle to the source device context.
nXSrc
[in] Specifies the x-coordinate, in logical units, of the upper-left corner of the source rectangle.
nYSrc
[in] Specifies the y-coordinate, in logical units, of the upper-left corner of the source rectangle.
dwRop
[in] Specifies a raster-operation code. These codes define how the color data for the source rectangle is to be combined with the color data for the destination rectangle to achieve the final color.

The following list shows some common raster operation codes.

Value Description
BLACKNESS Fills the destination rectangle using the color associated with index 0 in the physical palette. (This color is black for the default physical palette.)
CAPTUREBLT Windows 98/Me, Windows 2000/XP: Includes any windows that are layered on top of your window in the resulting image. By default, the image only contains your window. Note that this generally cannot be used for printing device contexts.
DSTINVERT Inverts the destination rectangle.
MERGECOPY Merges the colors of the source rectangle with the brush currently selected in hdcDest, by using the Boolean AND operator.
MERGEPAINT Merges the colors of the inverted source rectangle with the colors of the destination rectangle by using the Boolean OR operator.
NOMIRRORBITMAP Windows 98/Me, Windows 2000/XP: Prevents the bitmap from being mirrored.
NOTSRCCOPY Copies the inverted source rectangle to the destination.
NOTSRCERASE Combines the colors of the source and destination rectangles by using the Boolean OR operator and then inverts the resultant color.
PATCOPY Copies the brush currently selected in hdcDest, into the destination bitmap.
PATINVERT Combines the colors of the brush currently selected in hdcDest, with the colors of the destination rectangle by using the Boolean XOR operator.
PATPAINT Combines the colors of the brush currently selected in hdcDest, with the colors of the inverted source rectangle by using the Boolean OR operator. The result of this operation is combined with the colors of the destination rectangle by using the Boolean OR operator.
SRCAND Combines the colors of the source and destination rectangles by using the Boolean AND operator.
SRCCOPY Copies the source rectangle directly to the destination rectangle.
SRCERASE Combines the inverted colors of the destination rectangle with the colors of the source rectangle by using the Boolean AND operator.
SRCINVERT Combines the colors of the source and destination rectangles by using the Boolean XOR operator.
SRCPAINT Combines the colors of the source and destination rectangles by using the Boolean OR operator.
WHITENESS Fills the destination rectangle using the color associated with index 1 in the physical palette. (This color is white for the default physical palette.)

Return Values

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero.

Windows NT/2000/XP: To get extended error information, call GetLastError.

Remarks

BitBlt only does clipping on the destination DC.

If a rotation or shear transformation is in effect in the source device context, BitBlt returns an error. If other transformations exist in the source device context (and a matching transformation is not in effect in the destination device context), the rectangle in the destination device context is stretched, compressed, or rotated, as necessary.

If the color formats of the source and destination device contexts do not match, the BitBlt function converts the source color format to match the destination format.

When an enhanced metafile is being recorded, an error occurs if the source device context identifies an enhanced-metafile device context.

Not all devices support the BitBlt function. For more information, see the RC_BITBLT raster capability entry in the GetDeviceCaps function as well as the following functions: MaskBlt, PlgBlt, and StretchBlt.

BitBlt returns an error if the source and destination device contexts represent different devices. To transfer data between DCs for different devices, convert the memory bitmap to a DIB by calling GetDIBits. To display the DIB to the second device, call SetDIBits or StretchDIBits.

ICM: No color management is performed when blits occur.

还有一段Example

Capturing an Image

You can use a bitmap to capture an image, and you can store the captured image in memory, display it at a different location in your application's window, or display it in another window.

In some cases, you may want your application to capture images and store them only temporarily. For example, when you scale or zoom a picture created in a drawing application, the application must temporarily save the normal view of the image and display the zoomed view. Later, when the user selects the normal view, the application must replace the zoomed image with a copy of the normal view that it temporarily saved.

To store an image temporarily, your application must call CreateCompatibleDC to create a DC that is compatible with the current window DC. After you create a compatible DC, you create a bitmap with the appropriate dimensions by calling the CreateCompatibleBitmap function and then select it into this device context by calling the SelectObject function.

After the compatible device context is created and the appropriate bitmap has been selected into it, you can capture the image. The BitBlt function captures images. This function performs a bit block transfer that is, it copies data from a source bitmap into a destination bitmap. However, the two arguments to this function are not bitmap handles. Instead, BitBlt receives handles that identify two device contexts and copies the bitmap data from a bitmap selected into the source DC into a bitmap selected into the target DC. In this case, the target DC is the compatible DC, so when BitBlt completes the transfer, the image has been stored in memory. To redisplay the image, call BitBlt a second time, specifying the compatible DC as the source DC and a window (or printer) DC as the target DC.

The following example code, from an application that captures an image of the entire desktop, creates a compatible device context and a bitmap with the appropriate dimensions, selects the bitmap into the compatible DC, and then copies the image using the BitBlt function.

// Create a normal DC and a memory DC for the entire screen. The
// normal DC provides a "snapshot" of the screen contents. The
// memory DC keeps a copy of this "snapshot" in the associated
// bitmap.
hdcScreen = CreateDC("DISPLAY", NULL, NULL, NULL);
hdcCompatible = CreateCompatibleDC(hdcScreen);
// Create a compatible bitmap for hdcScreen.
hbmScreen = CreateCompatibleBitmap(hdcScreen,
GetDeviceCaps(hdcScreen, HORZRES),
GetDeviceCaps(hdcScreen, VERTRES));
if (hbmScreen == 0)
errhandler("hbmScreen", hwnd);
// Select the bitmaps into the compatible DC.
if (!SelectObject(hdcCompatible, hbmScreen))
errhandler("Compatible Bitmap Selection", hwnd);
// Hide the application window.
ShowWindow(hwnd, SW_HIDE);
//Copy color data for the entire display into a
//bitmap that is selected into a compatible DC.
if (!BitBlt(hdcCompatible,
0,0,
bmp.bmWidth, bmp.bmHeight,
hdcScreen,
0,0,
SRCCOPY))
errhandler("Screen to Compat Blt Failed", hwnd);
// Redraw the application window.
ShowWindow(hwnd, SW_SHOW); 
没有时间实际试验了,应该直接用API效果会比较好
还有个想法,GIF文件的后面+上若干字节是不会影响Gif图像文件本身的,so,应该在作为大头贴模板的Gif文件末加上一段数据用以指明此模板的空白区域中心点,大小等等,这样就可以实现让大头像自动匹配到模板中去,不用人工操作,这个实现起来应该不会太难
明天开始去学校了,delphi真得88了,手头的<面向对象的实践之路>虽然精彩,但是也只能去看那一大摞高考的东西.....
特别得好好看看英语,该死的MS资料从来就不出中文版 呵呵

自己做个大头贴软件,一些总结相关推荐

  1. gif透明背景动画_做动画片用什么软件?99%的人用它就做出来了 - 动画制作博客...

    做动画片用什么软件?常用的动画.剪辑工具较多,一提到很多人会想到Adobe家的PR.AE吧,不得不承认这些是神器,能做出专业效果,属于专业级别的软件,但是不适合大多数人. 现在做动画的主流软件还有很多 ...

  2. 电脑做笔记用什么软件好

    在电子信息化时代,绝大多数的上班族和相当一部分的大学生都会使用电脑来办公或学习.而想要在电脑上记录各种常用的信息.注意事项.感想感悟等内容,使用一款笔记软件来分类记录是比较方便的,这样不仅可以实现分散 ...

  3. 电脑做照片视频的软件用哪个?3步制作高清照片视频,超多酷炫转场效果

    电脑做照片视频的软件用哪个?在电脑上用什么软件做照片视频?如何快速做一个效果精美的高清照片视频? 今天直接教大家我一直在用的数码大师,做一个高清的精美照片视频吧,这里分享我的制作教程和效果截图: 在电 ...

  4. 四级英语听力软件测试,公务员考试网上做题 普通话测试软件 英语四级听力技巧...

    公务员考试网上做题 普通话测试软件 英语四级听力技巧 (2015-11-07 18:03:10) 标签: 普通话测试软件 英语四级听力技 [相似文献] 中国期刊全文数据库 前10条 1 李文,罗正跃; ...

  5. 做一个成功的软件项目经理

    做一个成功的软件项目经理 概述 要想做一个成功的软件项目经理需要有丰富的管理知识,同时要有全面的技术知识. 同时在知识的结合下在实际中应用管理学的计划,组织,控制,激励,领导等职能,发挥个人管理的长处 ...

  6. 分享几个常做甘特图的软件

    因为现在做的工作是项目运营,所以平时在部署活动的时候需要跟进活动的执行情况,那活动的执行进度就要活动相关的甘特图.如果没有一款合适的软件去做甘特图会特别麻烦,一方面要处理数据另一方面要保证图型的美观, ...

  7. 专门画像素图的软件_有哪几种简便的做像素画的软件?

    有哪些简便的做像素画的软件?https://www.zhihu.com/video/1104046126096855040 如何在几分钟之内,自己做一张简单好看的像素 gif 图 .试试这个免费的像素 ...

  8. 用VB.NET做个论坛发帖软件

    用VB.NET做个论坛发帖软件 riveastking 题记:如果你经常泡各种论坛发表宏论,如果您想把您的软件在极短时间内提交到有关网站,如果您想把您的网站快速登陆各搜索引擎,如果您想做个论坛自动发贴 ...

  9. 生物地理中考测试题刷题软件,初中生地会考怎么复习?做题找答案软件哪个好?...

    初中生地会考怎么复习?做题找答案软件哪个好? 2020-09-0216:18:52 来源: 作者:qiuyu 生地会考难度不会很高,基本上都能合格,但如果追求高分的话,还是需要注意下复习技巧.初中生地 ...

最新文章

  1. 深圳、长沙高校排名飙升,清北坐实亚洲大学Top2,留学深造还去啥新港日| 泰晤士2020亚洲大学榜...
  2. 一个颠覆性答案,登上《科学》封面:是什么弄破了这些泡泡? | 科学GIF
  3. UML图系列——用例图
  4. 【BZOJ3772】精神污染
  5. c# 值类型数据与引用类型数据
  6. 【51单片机快速入门指南】6.1:LCD1602的八线、四线控制及自定义符号,完美兼容Proteus仿真
  7. 微信宣布将推出自有输入法后,搜狗快马加鞭赶来泼冷水......
  8. 怎么查看蓝牙uuid_你的蓝牙耳机真的坏了吗?蓝牙耳机常见的一些假故障?
  9. 支持医学研究的Apple开源移动框架
  10. pycharm 汉化包
  11. cypress自动化--运行测试用例报告输出
  12. 基于ZigBee的远程温度监测系统.
  13. Hibernate中的一级缓存、二级缓存和懒加载
  14. matlab调用ANSYS
  15. 【ESP 保姆级教程】疯狂传感器篇 —— 案例:Mega + ESP8266 + MQ2烟雾 + MQ3酒精 + MQ7一氧化碳+ OLED + 阿里云物联网平台 + 微信小程序
  16. MySQL字符集是什么
  17. 小程序map的自定义图标不显示问题
  18. 8分钟带你彻底弄懂《信号与系统》
  19. On-premises software 释义http://en.wikipedia.org/wiki/On-premises_software
  20. 消防火灾联动报警系统中环网冗余型CAN转光纤的CAN光端机应用

热门文章

  1. win10 无法登录QQ,但能访问网页和使用UWP应用
  2. AOT JIT and Interpretation
  3. XTU 1213 A+B III
  4. 实验二 创建显示系统进程的信息的proc模块
  5. 从苏宁电器到卡巴斯基(第二部)第15篇:我在卡巴的日子 XV
  6. 谈谈e话通中wmp的应用
  7. 简单介绍单片机、电脑处理器原理
  8. 项目经理如何做好项目管理中的风险管理
  9. Error mounting /dev/sda2 at /media/mk90/F: Command-line `mount -t ntfs -o
  10. php攻克技术难点,攻克的七大技术难题