CxImage实现9PNG
CxImage* ScaleImageBy9PNG(CxImage *pRawImage, int nDstWidth,int nDstHeight)
{
if(NULL == pRawImage) return NULL; CDC *pDC = CDC::FromHandle(::GetDC(NULL));
CDC memDC;
memDC.CreateCompatibleDC(pDC); const UINT nBMPWidth = nDstWidth;
const UINT nBMPHeight= nDstHeight;
const UINT nRawWidth = pRawImage->GetWidth();
const UINT nRawHeight = pRawImage->GetHeight(); BITMAPINFO bitmapinfo;
bitmapinfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bitmapinfo.bmiHeader.biBitCount = ;
bitmapinfo.bmiHeader.biHeight = nBMPHeight;
bitmapinfo.bmiHeader.biWidth = nBMPWidth;
bitmapinfo.bmiHeader.biPlanes = ;
bitmapinfo.bmiHeader.biCompression=BI_RGB;
bitmapinfo.bmiHeader.biXPelsPerMeter=;
bitmapinfo.bmiHeader.biYPelsPerMeter=;
bitmapinfo.bmiHeader.biClrUsed=;
bitmapinfo.bmiHeader.biClrImportant=;
bitmapinfo.bmiHeader.biSizeImage = bitmapinfo.bmiHeader.biWidth * bitmapinfo.bmiHeader.biHeight * bitmapinfo.bmiHeader.biBitCount / ;
HBITMAP hBitmap = ::CreateDIBSection (memDC.m_hDC,&bitmapinfo, ,NULL, , ); CxImage *newImage = new CxImage();
newImage->CreateFromHBITMAP(hBitmap);
if (hBitmap != NULL)
{
DeleteObject(hBitmap);
}
::ReleaseDC(NULL, pDC->m_hDC);
if(memDC.m_hDC) ::DeleteDC(memDC.m_hDC); int newImageHeight = newImage->GetHeight();
int newImageWidth = newImage->GetWidth();
if(FALSE == newImage->AlphaIsValid())
{
newImage->AlphaCreate();
}
if(newImageHeight > nRawHeight && newImageWidth > nRawWidth)
{
for(int iH=;iH<newImageHeight;++iH)
for(int iW=;iW<newImageWidth;++iW)
{
int rawH = iH,rawW = iW;
if(rawH >= (newImageHeight-nRawHeight/))
{
rawH = rawH - (newImageHeight - nRawHeight);
}
if(rawW >= (newImageWidth-nRawWidth/))
{
rawW = rawW - (newImageWidth - nRawWidth);
} if((iH < nRawHeight/ || iH>=(newImageHeight-nRawHeight/))&&
(iW < nRawWidth/ || iW>= (newImageWidth-nRawWidth/)))
{
//4块源
RGBQUAD argb = pRawImage->GetPixelColor(rawW,rawH,true);
newImage->SetPixelColor(iW,iH,RGB(argb.rgbRed,argb.rgbGreen,argb.rgbBlue));
newImage->AlphaSet(iW,iH,argb.rgbReserved);
}
else
{
if((iH < nRawHeight/ || iH>=(newImageHeight-nRawHeight/))&&iW->=)
{
RGBQUAD argb = newImage->GetPixelColor(iW-,iH,true);
newImage->SetPixelColor(iW,iH,RGB(argb.rgbRed,argb.rgbGreen,argb.rgbBlue));
newImage->AlphaSet(iW,iH,argb.rgbReserved);
}
else
{
if(iH - >= )
{
RGBQUAD argb = newImage->GetPixelColor(iW,iH-,true);
newImage->SetPixelColor(iW,iH,RGB(argb.rgbRed,argb.rgbGreen,argb.rgbBlue));
newImage->AlphaSet(iW,iH,argb.rgbReserved);
}
}
}
}
}
return newImage;
}
9PNG的意思就是绘制时按9块区域绘制,左上左下右上右下是源,其他是拉伸的部分。CxImage主要使用像素点的方式来进行拉伸,并且每个像素都有copy透明信息。
CxImage实现9PNG的更多相关文章
- CxImage图像库的使用 .
http://blog.csdn.net/wangjie0377/article/details/7830405 CxImage图像库 CxImage下载地址:http://www.codeproje ...
- CxImage在VS2010下的配置
http://blog.csdn.net/youzhuo/article/details/24601621 一.编译Cximage 1.在SourceForge上下载cximage702_full.7 ...
- 9png图片制作
制作步骤不多说了,这儿有链接:http://blog.csdn.net/pugongying1988/article/details/6938972 链接中去边框一个像素可以不用做,直接用androi ...
- CxImage
启动项目的时候显示此时 百度“无法启动程序cximage.lib” 得到http://tieba.baidu.com/p/1935208210把第二项设为启动项即可 为什么设置第二项为启动项呢 因为h ...
- 四大图像库:OpenCV/FreeImage/CImg/CxImage
1.对OpenCV 的印象:功能十分的强大,而且支持目前先进的图像处理技术,体系十分完善,操作手册很详细,手册首先给大家补计算机视觉的知识,几乎涵盖了近10年内的主流算法: 然后将图像格式和矩阵运算, ...
- CxImage整理(叠加字符/图像合并)
//CxImage叠加字符 void CCxImageTestDlg::OnBnClickedButton1() { CxImage imgJPG; // 定义一个CxImage对象 imgJPG.L ...
- [ZT]图像处理库的比较:OpenCV,FreeImage,CImg,CxImage
1.对OpenCV 的印象:功能十分的强大,而且支持目前先进的图像处理技术,体系十分完善,操作手册很详细,手册首先给大家补计算机视觉的知识,几乎涵盖了近10年内的主流算法: 然后将图像格式和矩阵运算, ...
- CxImage的使用
1.首先从此处下载源代码 http://www.codeproject.com/KB/graphics/cximage.aspx 2.然后将里面的工程全部编译一下,我觉得应该是生成对应的库. 3.然后 ...
- 图像处理库的比较:OpenCV,FreeImage,CImg,CxImage
1.对OpenCV 的印象:功能十分的强大,而且支持目前先进的图像处理技术,体系十分完善,操作手册很详细,手册首先给大家补计算机视觉的知识,几乎涵盖了近10年内的主流算法: 然后将图像格式和矩阵运算, ...
随机推荐
- CodeForces - 459C - Pashmak and Buses
先上题目+: C. Pashmak and Buses time limit per test 1 second memory limit per test 256 megabytes input s ...
- CF576D. Flights for Regular Customers
n<=150个点,m<=150条路,每条路Ai,Bi,Di表示Ai到Bi有一条有向边,使用他前至少要走Di条路,问1到n最少走几条路. 又是n^4过150的题.... 不同于传统的最短路, ...
- Ubuntu 16.04安装Kdbg替代Insight实现汇编的调试
Insight已经不能使用APT进行安装,且如果使用源码安装时需要修改.所以只能放弃,转投使用Kdbg. 安装: sudo apt-get install kdbg 使用: nasm -f elf64 ...
- SQL Server 性能优化实战系列(文章索引) : 桦仔
http://www.cnblogs.com/gaizai/archive/2012/01/20/2327814.html
- LeetCode 884. Uncommon Words from Two Sentences (两句话中的不常见单词)
题目标签:HashMap 题目给了我们两个句子,让我们找出不常见单词,只出现过一次的单词就是不常见单词. 把A 和 B 里的word 都存入 map,记录它们出现的次数.之后遍历map,把只出现过一次 ...
- 【C++】双向线性链表容器的实现
// 双向线性链表容器 #include <cstring> #include <iostream> #include <stdexcept> using name ...
- Codeforces Round #329 (Div. 2)B. Anton and Lines 贪心
B. Anton and Lines The teacher gave Anton a large geometry homework, but he didn't do it (as usual ...
- 1695 windows 2013
1695 windows 2013 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题解 查看运行结果 题目描述 Description 话说adam ...
- linux 下载 图片
linux curl 下载图片 l=[] with open('ee.html','r',encoding='utf-8') as fr: for i in fr: ii=i.split('&qu ...
- JPush 初始化失败,直接按照官方文档的格式写的,portal上的包名肯定不会错,mainfest里面直接指定${applicationId}
错误日志: 11-27 09:59:19.670 26124-26124/? D/dalvikvm: Late-enabling CheckJNI 11-27 09:59:20.008 26124-2 ...