怎么转换图片格式 bmp->jpg bmp->gif??

sor 2002-09-13 03:19:54
怎么转换图片格式
bmp,gif,jpg的互相转换
...全文
21567 11 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
xDraw 2002-09-13
  • 打赏
  • 举报
回复
http://askpro.east.net.cn/download/bmp2gifprj.zip
xDraw 2002-09-13
  • 打赏
  • 举报
回复
http://www.csdn.net/Expert/TopicView1.asp?id=1011450
sucker 2002-09-13
  • 打赏
  • 举报
回复
用ACD See也可以
步履人生 2002-09-13
  • 打赏
  • 举报
回复
UP
sqzth 2002-09-13
  • 打赏
  • 举报
回复
草 :
有那么麻烦吗?
用PHOTOSHOP打开以后
想改成什么格式就另存为什么格式就可以了
oldworm 2002-09-13
  • 打赏
  • 举报
回复
bmp->jpg
//now, use intel jpeg library.
BOOL CImageJpeg::LoadFile(const char *filename)
{
//Use the IJL to load up the jpeg
JPEG_CORE_PROPERTIES image;
memset(&image, 0, sizeof(image));

//Init the IJL
if (ijlInit(&image) != IJL_OK)
{
TRACE(_T("Cannot initialize Intel JPEG library!\n"));
return FALSE;
}

//Read in the Jpeg file parameters
image.JPGFile = filename;
if (ijlRead(&image, IJL_JFILE_READPARAMS) != IJL_OK)
{
TRACE(_T("Cannot read JPEG file header from %s file!\n"), image.JPGFile);
ijlFree(&image);
return FALSE;
}

// Set the JPG color space ... this will always be
// somewhat of an educated guess at best because JPEG
// is "color blind" (i.e., nothing in the bit stream
// tells you what color space the data was encoded from).
// However, in this example we assume that we are
// reading JFIF files which means that 3 channel images
// are in the YCbCr color space and 1 channel images are
// in the Y color space.
switch(image.JPGChannels)
{
case 1:
image.JPGColor = IJL_G;
image.DIBColor = IJL_BGR;
image.DIBChannels = 3;
break;
case 3:
image.JPGColor = IJL_YCBCR;
image.DIBColor = IJL_BGR;
image.DIBChannels = 3;
break;
case 4:
image.JPGColor = IJL_YCBCRA_FPX;
image.DIBColor = IJL_RGBA_FPX;
image.DIBChannels = 3;
default:
// This catches everything else, but no
// color twist will be performed by the IJL.
image.JPGColor = IJL_OTHER;
image.DIBColor = IJL_OTHER;
image.DIBChannels = 3; //image.JPGChannels;
break;
}

//Allocate memory for the image
DWORD dwImageSize = image.JPGWidth * image.JPGHeight * image.DIBChannels;
BYTE* pImageData = new BYTE[dwImageSize];
if(pImageData == NULL){
ijlFree(&image);
return FALSE;
}

//Call the IJL to load the Jpeg from file
image.DIBWidth = image.JPGWidth;
image.DIBHeight = image.JPGHeight;
image.DIBPadBytes = 0;
image.DIBBytes = pImageData;

ijlRead(&image, IJL_JFILE_READWHOLEIMAGE);
/* if (ijlRead(&image, IJL_JFILE_READWHOLEIMAGE) != IJL_OK)
{
TRACE(_T("Cannot read image pImageData from %s file!\n"), image.JPGFile);
delete [] pImageData;
ijlFree(&image);
return FALSE;
}*/
//Finished with IJL
if (ijlFree(&image) != IJL_OK) {
TRACE(_T("Cannot free Intel JPEG library!\n"));
}
m_pBMI = (BITMAPINFO *)new BYTE[sizeof(BITMAPINFOHEADER)];
memset(m_pBMI, 0, sizeof(BITMAPINFOHEADER));
m_pBMI->bmiHeader.biSize = sizeof(m_pBMI->bmiHeader);
m_pBMI->bmiHeader.biWidth = image.JPGWidth;
m_pBMI->bmiHeader.biHeight = image.JPGHeight;
m_pBMI->bmiHeader.biBitCount = 24;
m_pBMI->bmiHeader.biPlanes = 1;
m_pBMI->bmiHeader.biCompression = BI_RGB;

// allocate bitmap
//int bps = (width * channels + 3) /4 * 4;
int bps = WIDTHBYTES(image.JPGWidth * 24);
m_pBits = (BYTE *)new BYTE[bps * image.JPGHeight];
if(m_pBits == NULL){
delete [] pImageData;
return FALSE;
}
int LineBytes = image.JPGWidth * 3;
char *psrc = (char *)pImageData;
char *pline = (char *)(m_pBits + image.JPGHeight * bps);
for(int i = image.JPGHeight-1; i>=0; i--)
{
pline -= bps;
memcpy(pline, psrc, LineBytes);
psrc += LineBytes;
}
delete [] pImageData;

return TRUE;
}

jpg->bmp:
BOOL SaveDIBToJpg(const char *imagefile, const BITMAPINFO *pBMI, const BYTE *pBits,
int quality)
{
if((pBMI) && (pBits))
{
if(pBMI->bmiHeader.biBitCount != 24){
TRACE("Only 24 bit images can be saved as JPEG!\r\n");
return FALSE;
}
//Init the IJL
JPEG_CORE_PROPERTIES image;
memset(&image, 0, sizeof(image));
if (ijlInit(&image) != IJL_OK)
{
TRACE(_T("Can't initialize Intel JPEG library!\n"));
return FALSE;
}
//Setup the "image" settings
image.JPGFile = imagefile;
image.jquality = quality;
image.DIBWidth = pBMI->bmiHeader.biWidth;
image.DIBHeight = pBMI->bmiHeader.biHeight;
image.JPGWidth = pBMI->bmiHeader.biWidth;
image.JPGHeight = pBMI->bmiHeader.biHeight;

int bps = WIDTHBYTES(pBMI->bmiHeader.biWidth*24);
int LineBytes = pBMI->bmiHeader.biWidth*3;

//Allocate some memory to save the Dib bits into
BYTE* pBmp = new BYTE[LineBytes * pBMI->bmiHeader.biHeight];
image.DIBBytes = pBmp;

char *psrc = (char *)(pBits + pBMI->bmiHeader.biHeight * bps);
char *pline = (char *)pBmp;
for(int i = pBMI->bmiHeader.biHeight-1; i>=0; i--)
{
psrc -= bps;
memcpy(pline, psrc, LineBytes);
pline += LineBytes;
}
//Call the IJL to write the Jpeg to file
if (ijlWrite(&image, IJL_JFILE_WRITEWHOLEIMAGE) != IJL_OK)
{
TRACE(_T("Can't write jpeg image\n") );
delete [] pBmp;
return FALSE;
}
//Finished with IJL
if (ijlFree(&image) != IJL_OK) {
TRACE(_T("Can't free Intel JPEG library!\n"));
}

delete [] pBmp;
return TRUE;
}
return FALSE;
}

long_in_sea2002 2002-09-13
  • 打赏
  • 举报
回复
可以用软件,如果你愿意
storein 2002-09-13
  • 打赏
  • 举报
回复
我有用IJL写的BMP--》JPEG ,JPEG--》BMP的程序
如果需要的话

digitalwatermark@163.com
oldworm 2002-09-13
  • 打赏
  • 举报
回复
bmp是最简单的图像格式之一,jpg有现成的库可用,用www.ijg.org或者www.intel.com的ijl都可以,gif也有现成的unlibgif,不过这个东西有问题,不够稳定,我后来自己写了一个gif类。
mornlight 2002-09-13
  • 打赏
  • 举报
回复
到网上找一个库函数呀!
supermen 2002-09-13
  • 打赏
  • 举报
回复
JPEG是一种图像压缩标准,很多精美的图片都是采用这种格式标准,其特点是文件体积较小,而且支持24位色深。但是,Windows9x只支持位图文件(即以bmp为扩展名的文件)的墙纸。下面这个程序就是将以jpg或jpeg为扩展名的图片文件转化为位图文件,并通过修改注册表的键值来通知Windows更换墙纸。本程序使用了一个Tform;一个OpenPictureDialog用来让用户选择图片;三个SpeedButton;分别用来打开OpenPictureDialog对话框,确定更换墙纸,退出程序。程序全部代码如下:
  unit Unit1;
  interface
  uses
   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, jpeg, registry, ExtDlgs, StdCtrls, Buttons;
  type
   TForm1 = class(TForm)
   SpeedButton1: TSpeedButton;
   SpeedButton2: TSpeedButton;
   SpeedButton3: TSpeedButton;
   OpenPictureDialog1: TOpenPictureDialog;
  procedure SpeedButton1Click(Sender: TObject);
  procedure SpeedButton2Click(Sender: TObject);
  procedure SpeedButton3Click(Sender: TObject);
   private
   { Private declarations }
   public
   { Public declarations }
   end;
  var
   Form1: TForm1;
  implementation
  {$R *.DFM}
  procedure TForm1.SpeedButton1Click(Sender: TObject);
  begin
   openpicturedialog1.execute;{打开OpenPictureDialog对话框}
  end;
  procedure TForm1.SpeedButton2Click(Sender: TObject);
  var
   reg: tregistry;{Tregistry对象在Registry单元中声明,需要在Uese 中引用Registry单元}
   jpeg: tjpegimage;{Tjpegimage对象在Jpeg单元中声明,需要在Uese 中引用Jpeg单元}
   bmp: tbitmap;
  begin
   if (openpicturedialog1.filename=``)
   then {判断OpenPictureDialog1中有无文件被选中}
messagedlg(`请选择一张图片`,mtinformation,[mbOK],0)
   else
   begin
   jpeg:=tjpegimage.Create;
   jpeg.LoadFromFile(openpicturedialog1.filename);{加载被用户选中的文件}
   bmp:=tbitmap.Create;
   bmp.assign(jpeg);
   bmp.savetofile(`c:\windows\wall.bmp`);{将转换成功的文件保存的路径及文件名}
   reg:=tregistry.Create;
  reg.rootkey:=hkey_current_user;{设置根键名称}
  reg.openkey(`control panel\desktop`,false);{打开Control Panel\Desktop路径对应的主
键}
   reg.writestring(`tilewallpaper`,`0`);
   reg.writestring(`wallpaper`,`c:\windows\wall.bmp`);
{覆盖并写入新值TileWall- paper和Wallpaper串}
  systemparametersinfo(spi_setdeskwallpaper,0,nil,spif_sendchange);{通知win-dows更
换墙纸}
  reg.closekey;{写入更改内容并关闭注册表}
   reg.Free;{释放对象}
   close;
   end;
  end;
  procedure TForm1.SpeedButton3Click(Sender: TObject);
  begin
   close;
  end;
  end.
  此程序只能将以jpg或jpeg为扩展名的图片文件转化为Windows的墙纸,因此应在OpenPictureDialog控件的Filter属性中筛选显示文件的类型,最好设置为JPEG Image File(*.jpg)和JPEG Image File(*.jpeg)文件。程序在中文Windows98,Delphi 4.0下编译通过

16,548

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • AIGC Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧