16,473
社区成员
发帖
与我相关
我的任务
分享
void CATCDialog::OnBnClickedButton1()
{
// TODO: 在此添加控件通知处理程序代码
UpdateData(TRUE);
// TODO: 在此添加控件通知处理程序代码
CxImage image;
image.Load(_T("baboon.jpg"), CXIMAGE_SUPPORT_JPG);
if (image.IsValid())
{
//image.GrayScale();
CDC *pDC = GetDC();
image.Draw(pDC->GetSafeHdc(), CRect(0, 0, 200, 200));
pDC->DeleteDC();
image.Save(_T("test.jpg"), CXIMAGE_SUPPORT_JPG);
}
UpdateData(FALSE);
}
错误 LNK1120 10 个无法解析的外部命令 ATC C:\Users\tzy\Desktop\ATC\Debug\ATC.exe 1
错误 LNK2001 无法解析的外部符号 __imp__fprintf ATC C:\Users\tzy\Desktop\ATC\ATC\Tiff.lib(tif_ojpeg.obj) 1
错误 LNK2019 无法解析的外部符号 "__declspec(dllimport) public: struct std::_Iterator_base12 * * __thiscall std::_Container_base12::_Getpfirst(void)const " (__imp_?_Getpfirst@_Container_base12@std@@QBEPAPAU_Iterator_base12@2@XZ),该符号在函数 "protected: void __thiscall std::deque<struct tagPOINT,class std::allocator<struct tagPOINT> >::_Orphan_off(unsigned int)const " (?_Orphan_off@?$deque@UtagPOINT@@V?$allocator@UtagPOINT@@@std@@@std@@IBEXI@Z) 中被引用 ATC C:\Users\tzy\Desktop\ATC\ATC\cximage.lib(ximadsp.obj) 1
//使用GDI+
#include <gdiplus.h>
using namespace Gdiplus;
//保存GDI+被初始化后在应用程序中的GDI+标识
static ULONG_PTR m_gdiplusToken;
在构造函数中进行初始化操作
//对GDI+进行初始化
Gdiplus::GdiplusStartupInput gdiInput;
Gdiplus::GdiplusStartup(&m_gdiplusToken, &gdiInput, NULL);
处理部分 (这里是在图片上绘制文字)
//对生成的BItmap进行绘图处理 加上对应的文本信息 begin
Gdiplus::Image image(L"D:\\test\\PDF_417_out.bmp"); //加载图片
//Gdiplus::Graphics imageGraphics(&(*bitmap));
imageGraphics.SetTextRenderingHint(TextRenderingHintClearTypeGridFit);
//wstring strWrite = L"test"; strSource
wstring strSource = L"test";
Gdiplus::FontFamily font(L"楷体");// Gdiplus::FontStyleRegular,
Gdiplus::Font myFont(&font, 10, Gdiplus::FontStyleRegular, Gdiplus::UnitPixel);
SolidBrush blackBrush(Color(255, 0, 0, 0)); //半透明加文字颜色
Gdiplus::PointF school_site((REAL)60, (REAL)60);//文字放置的像素坐标
StringFormat format001;
format001.SetAlignment(StringAlignmentNear);
const WCHAR *temp = strSource.c_str();
imageGraphics.DrawString(temp, strSource.length(), &myFont, school_site, &format001, &blackBrush);
//对生成的Bitmap进行绘图处理 加上对应的文本信息 end