现有一JPG格式图片,右击,选择“编辑”,打开画图工具,然后“另存为”,同样是JPG格式,大小改变了?
我试的是从3M多,转换为 1M左右,这里称之为“不变格式压缩” 如果我要实现批量JPG文件的“不变格式压缩”,怎么实现,压缩后的格式可以不限制,只要失真不严重就行?? 哪位高手可以解决这问题??
我试的是从3M多,转换为 1M左右,这里称之为“不变格式压缩” 如果我要实现批量JPG文件的“不变格式压缩”,怎么实现,压缩后的格式可以不限制,只要失真不严重就行?? 哪位高手可以解决这问题??
解决方案 »
- 绘制曲线的问题
- vc2005,MSVCRTD.lib(crtexe.obj) : error LNK2019: 无法解析的外部符号 _main
- 有个奇怪的问题,将CString转换为char
- 多个定时器之间的协调问题,请高手指教!
- 如何用VC调用一DLL,这个DLL没有头文件,但是我知道它里面的函数名和变量??
- vc每次编译程序是都自动保存,我想把他去掉,
- 急!!!哪位大虾知道c++中new的place 语法?
- *ime文件怎么使用?
- 我做了一个屏保程序,运行不了 求大神指教
- COM组件问题,请多多指教
- vc++6.0写的MFC DLL问题??
- C++编译总是出错,莫名其妙的错误哪位能帮忙看看?
软件名:Imagicon
#include <gdiplus.h>
#include <stdio.h>
using namespace Gdiplus;INT GetEncoderClsid(const WCHAR* format, CLSID* pClsid); // helper functionINT main()
{
// Initialize GDI+.
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); CLSID encoderClsid;
EncoderParameters encoderParameters;
ULONG quality;
Status stat; // Get an image from the disk.
Image* image = new Image(L"Shapes.bmp"); // Get the CLSID of the JPEG encoder.
GetEncoderClsid(L"image/jpeg", &encoderClsid); // Before we call Image::Save, we must initialize an
// EncoderParameters object. The EncoderParameters object
// has an array of EncoderParameter objects. In this
// case, there is only one EncoderParameter object in the array.
// The one EncoderParameter object has an array of values.
// In this case, there is only one value (of type ULONG)
// in the array. We will let this value vary from 0 to 100. encoderParameters.Count = 1;
encoderParameters.Parameter[0].Guid = EncoderQuality;
encoderParameters.Parameter[0].Type = EncoderParameterValueTypeLong;
encoderParameters.Parameter[0].NumberOfValues = 1; // Save the image as a JPEG with quality level 0.
quality = 0;
encoderParameters.Parameter[0].Value = &quality;
stat = image->Save(L"Shapes001.jpg", &encoderClsid, &encoderParameters); if(stat == Ok)
wprintf(L"%s saved successfully.\n", L"Shapes001.jpg");
else
wprintf(L"%d Attempt to save %s failed.\n", stat, L"Shapes001.jpg"); // Save the image as a JPEG with quality level 50.
quality = 50;
encoderParameters.Parameter[0].Value = &quality;
stat = image->Save(L"Shapes050.jpg", &encoderClsid, &encoderParameters); if(stat == Ok)
wprintf(L"%s saved successfully.\n", L"Shapes050.jpg");
else
wprintf(L"%d Attempt to save %s failed.\n", stat, L"Shapes050.jpg"); // Save the image as a JPEG with quality level 100.
quality = 100;
encoderParameters.Parameter[0].Value = &quality;
stat = image->Save(L"Shapes100.jpg", &encoderClsid, &encoderParameters); if(stat == Ok)
wprintf(L"%s saved successfully.\n", L"Shapes100.jpg");
else
wprintf(L"%d Attempt to save %s failed.\n", stat, L"Shapes100.jpg"); delete image;
GdiplusShutdown(gdiplusToken);
return 0;
}
用vs2003或者vs2005里面的gdi+库,应该很容易的吧。如果你懒得装那么大的,有个轻量级的编译器:
http://download255.mediafire.com/loljmombrmjg/zlnecmbmzvm/Visual+C%2B%2B+6.0%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87%E5%8A%A0%E5%BC%BA%E7%89%88.rar