使用GDI+转换图片格式

本文介绍了如何利用GDI+库进行图片格式转换,通过调用ImageConvert函数,可以方便地完成图片格式的更改。详细代码和示例可在提供的链接中获取。
摘要由CSDN通过智能技术生成

调用ImageConvert函数即可,测试代码在http://download.csdn.net/detail/qq1134993111/6227899

ImageConverter.h

/*
     转换图片格式  GDI+支持的格式
*/
#pragma once
#include <wtypes.h>
#include <guiddef.h>
#include <string>
using namespace std;
#include <GdiPlus.h>
using namespace Gdiplus;
#pragma comment(lib,"gdiplus")

//获取format对应类型的图片解码器的CLSID
int GetEncoderClsid(const WCHAR* format, CLSID* pClsid);
/* 
wstrImageSrcPath 源图片文件全路径(包括扩展名)  
wstrImageDesPath 转换后文件存放全路径(包括括展名)
wstrFormatType   转换参数,例如:L"image/png" 、L"image/bmp" 等等。要和wstrImageDesPath路径中的图像格式一样
返回值为true表示成功
*/
bool ImageConvert(wstring wstrImageSrcPath,wstring wstrImageDesPath,wstring wstrFormatType);

ImageConverter.cpp

#include "ImageConverter.h"


int GetEncoderClsid(const WCHAR* format, CLSID* pClsid)
{
	UINT  num = 0;          /
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值