第二个问题知道了,uses  jpeg就可以了:](可别笑我菜呀)

解决方案 »

  1.   

    function ZsBmpToIco(mBitmap: TBitmap; mIcon: TIcon;
      mSize32: Boolean = True): Boolean; { 返回将位图转换成图标是否成功 }
    var
      vIconWidth: Integer;
      vIconHeight: Integer;
      vBitmapMask: TBitmap;
      vBitmapColor: TBitmap;
      vIconInfo: TIconInfo;
    begin
      Result := True;
      if mSize32 then begin
        vIconWidth := 32;
        vIconHeight := 32;
      end else begin
        vIconWidth := 16;
        vIconHeight := 16;
      end;  vBitmapMask := TBitmap.Create;
      vBitmapColor := TBitmap.Create;
      try
        vBitmapMask.Width := vIconWidth;
        vBitmapMask.Height := vIconHeight;
        vBitmapMask.Canvas.Brush.Color := clBlack;
        vBitmapMask.Canvas.Rectangle(0, 0, vIconWidth, vIconHeight);    vBitmapColor.Width := vIconWidth;
        vBitmapColor.Height := vIconHeight;
        StretchBlt(vBitmapColor.Canvas.Handle, 0, 0, vIconWidth, vIconHeight,
          mBitmap.Canvas.Handle, 0, 0, mBitmap.Width, mBitmap.Height, SRCCOPY);    vIconInfo.fIcon := True;
        vIconInfo.xHotspot := 0;
        vIconInfo.yHotspot := 0;
        vIconInfo.hbmMask := vBitmapMask.Handle;
        vIconInfo.hbmColor := vBitmapColor.Handle;
        mIcon.Handle := CreateIconIndirect(vIconInfo);
      except
        Result := False;
      end;
      vBitmapMask.Free;
      vBitmapColor.Free;
    end; { ZsBmpToIco }
      

  2.   

    var
      MyJpeg: TJpegImage;
      bmp: Tbitmap;
    begin
      bmp:=tbitmap.Create;
      MyJpeg:= TJpegImage.Create;
      myjpeg.LoadFromFile('c:\windows\desktop\aa.jpg');
      bmp.Assign(myjpeg);
      bmp.SaveToFile('c:\windows\desktop\test.bmp'); // Save the JPEG to Disk
    end;
      

  3.   

    var
      MyJpeg: TJpegImage;
      bmp: Tbitmap;
    begin
      bmp:=tbitmap.Create;
      MyJpeg:= TJpegImage.Create;
      myjpeg.LoadFromFile('c:\windows\desktop\aa.jpg');
      bmp.Assign(myjpeg);
      bmp.SaveToFile('c:\windows\desktop\test.bmp'); // Save the JPEG to Disk
    end;
      

  4.   

    不好,问题又来了,载入的jpg图片虽然可以保存为bmp和ico格式的
    ,也可以用acdsee查看,但再次用image载入它们的时候就出错了!!!
      

  5.   

     可以如下,(其他格式也许也可,试一下)记得加入 use jpeg.
    var
      MyJpeg: TJpegImage;
      Image1: TImage;
    begin
      Image1:= TImage.Create(self);
      MyJpeg:= TJpegImage.Create;
      Image1.Picture.Bitmap.LoadFromFile('c:\windows\desktop\aa.BMP');  // Load the Bitmap from a file
      MyJpeg.Assign(Image1.Picture.Bitmap);  // Assign the BitMap to MyJpeg object
      MyJpeg.CompressionQuality:=StrToInt('75');
      MyJpeg.Compress;
      MyJpeg.SaveToFile('c:\windows\desktop\test.JPG'); // Save the JPEG to Disk
    end;
      

  6.   

    <3>要清空image中的图片,都有哪些方法?
    image1.Picture.Assign(nil);对不对
      

  7.   

    我只用一个image和两个button,加SaveDialog1,OpenDialog1,载入的图片有可能是ico,bmp,jpg三种格式,保存时也有三种可能,
    那么我的载入代码和保存代码都要考虑这些情况呀!!!
    另外载入ico格式的,要保存为bmp格式的怎么写代码转换???
    分数不够还可以加呀
      

  8.   

    function ZsIcoToBmp(mIcon: TIcon; mBitmap: TBitmap): Boolean;
    { 返回将图标转换成位图是否成功 }
    var
      vIconWidth: Integer;
      vIconHeight: Integer;
    begin
      Result := True;
      try
        vIconWidth := mIcon.Width;
        vIconHeight := mIcon.Height;
        mBitmap.Width := vIconWidth;
        mBitmap.Height := vIconHeight;
        mBitmap.Canvas.FillRect(Rect(0, 0, vIconWidth, vIconHeight));
        mBitmap.Canvas.Draw(0, 0, mIcon);
      except
        Result := False;
      end;
    end; { ZsIcoToBmp }
      

  9.   

    //这下你该满足了吧
    //pas
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, ExtDlgs, ExtCtrls, jpeg, Spin;type
      TForm1 = class(TForm)
        Button1: TButton;
        Image1: TImage;
        Image2: TImage;
        Image3: TImage;
        OpenPictureDialog1: TOpenPictureDialog;
        OpenPictureDialog2: TOpenPictureDialog;
        OpenPictureDialog3: TOpenPictureDialog;
        SavePictureDialog1: TSavePictureDialog;
        SavePictureDialog2: TSavePictureDialog;
        SavePictureDialog3: TSavePictureDialog;
        Button2: TButton;
        Button3: TButton;
        Button4: TButton;
        Button5: TButton;
        Button6: TButton;
        Button7: TButton;
        RadioButton1: TRadioButton;
        RadioButton2: TRadioButton;
        RadioButton3: TRadioButton;
        CheckBox1: TCheckBox;
        SpinEdit1: TSpinEdit;
        procedure Button7Click(Sender: TObject);
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
        procedure Button4Click(Sender: TObject);
        procedure Button3Click(Sender: TObject);
        procedure Button6Click(Sender: TObject);
        procedure Button5Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}function BmpToIco(mBitmap: TBitmap; mIcon: TIcon;
      mSize32: Boolean = True): Boolean;
    var
      vIconWidth: Integer;
      vIconHeight: Integer;
      vBitmapMask: TBitmap;
      vBitmapColor: TBitmap;
      vIconInfo: TIconInfo;
    begin
      Result := True;
      if mSize32 then begin
        vIconWidth := 32;
        vIconHeight := 32;
      end else begin
        vIconWidth := 16;
        vIconHeight := 16;
      end;  vBitmapMask := TBitmap.Create;
      vBitmapColor := TBitmap.Create;
      try
        vBitmapMask.Width := vIconWidth;
        vBitmapMask.Height := vIconHeight;
        vBitmapMask.Canvas.Brush.Color := clBlack;
        vBitmapMask.Canvas.Rectangle(0, 0, vIconWidth, vIconHeight);    vBitmapColor.Width := vIconWidth;
        vBitmapColor.Height := vIconHeight;
        StretchBlt(vBitmapColor.Canvas.Handle, 0, 0, vIconWidth, vIconHeight,
          mBitmap.Canvas.Handle, 0, 0, mBitmap.Width, mBitmap.Height, SRCCOPY);    vIconInfo.fIcon := True;
        vIconInfo.xHotspot := 0;
        vIconInfo.yHotspot := 0;
        vIconInfo.hbmMask := vBitmapMask.Handle;
        vIconInfo.hbmColor := vBitmapColor.Handle;
        mIcon.Handle := CreateIconIndirect(vIconInfo);
      except
        Result := False;
      end;
      vBitmapMask.Free;
      vBitmapColor.Free;
    end; { BmpToIco }function IcoToBmp(mIcon: TIcon; mBitmap: TBitmap): Boolean;
    var
      vIconWidth: Integer;
      vIconHeight: Integer;
    begin
      Result := True;
      try
        vIconWidth := mIcon.Width;
        vIconHeight := mIcon.Height;
        mBitmap.Width := vIconWidth;
        mBitmap.Height := vIconHeight;
        mBitmap.Canvas.FillRect(Rect(0, 0, vIconWidth, vIconHeight));
        mBitmap.Canvas.Draw(0, 0, mIcon);
      except
        Result := False;
      end;
    end; { IcoToBmp }function JpegToBmp(mJPEGImage: TJPEGImage; mBitmap: TBitmap): Boolean;
    begin
      Result := True;
      try
        mBitmap.Assign(mJPEGImage);
      except
        Result := False;
      end;
    end; { JpegToBmp }function BmpToJpeg(mBitmap: TBitmap; mJPEGImage: TJPEGImage;
      mCompressionQuality: Integer = 75): Boolean;
    begin
      Result := True;
      try
        mJPEGImage.Assign(mBitmap);
        mJPEGImage.CompressionQuality := mCompressionQuality;
        mJPEGImage.Compress;
      except
        Result := False;
      end;
    end; { BmpToJpeg }procedure TForm1.Button7Click(Sender: TObject);
    var
      vJPEGImage: TJPEGImage;
    begin
      if RadioButton1.Checked then begin
        vJPEGImage := TJPEGImage.Create;
        try
          Image2.Picture.Icon.Assign(nil);
          TJPEGImage(Image3.Picture).Assign(nil);
          BmpToIco(Image1.Picture.Bitmap, Image2.Picture.Icon, CheckBox1.Checked);
          BmpToJpeg(Image1.Picture.Bitmap, vJPEGImage, SpinEdit1.Value);
          TJPEGImage(Image3.Picture).Assign(vJPEGImage);
        finally
          vJPEGImage.Free;
        end;
      end else if RadioButton2.Checked then begin
        vJPEGImage := TJPEGImage.Create;
        try
          Image1.Picture.Bitmap.Assign(nil);
          TJPEGImage(Image3.Picture).Assign(nil);
          IcoToBmp(Image2.Picture.Icon, Image1.Picture.Bitmap);
          BmpToJpeg(Image1.Picture.Bitmap, vJPEGImage, SpinEdit1.Value);
          TJPEGImage(Image3.Picture).Assign(vJPEGImage);
        finally
          vJPEGImage.Free;
        end;
      end else begin
        vJPEGImage := TJPEGImage.Create;
        try
          vJPEGImage.Assign(TJPEGImage(Image3.Picture));
          Image1.Picture.Bitmap.Assign(nil);
          Image2.Picture.Icon.Assign(nil);
          JpegToBmp(vJPEGImage, Image1.Picture.Bitmap);
          BmpToIco(Image1.Picture.Bitmap, Image2.Picture.Icon, CheckBox1.Checked);
        finally
          vJPEGImage.Free;
        end;
      end;
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
      if OpenPictureDialog1.Execute then
        Image1.Picture.Bitmap.LoadFromFile(OpenPictureDialog1.FileName);
    end;procedure TForm1.Button2Click(Sender: TObject);
    begin
      if SavePictureDialog1.Execute then
        Image1.Picture.Bitmap.SaveToFile(SavePictureDialog1.FileName);
    end;procedure TForm1.Button4Click(Sender: TObject);
    begin
      if OpenPictureDialog2.Execute then
        Image2.Picture.Icon.LoadFromFile(OpenPictureDialog2.FileName);
    end;procedure TForm1.Button3Click(Sender: TObject);
    begin
      if SavePictureDialog2.Execute then
        Image2.Picture.Icon.SaveToFile(SavePictureDialog2.FileName);
    end;procedure TForm1.Button6Click(Sender: TObject);
    begin
      if OpenPictureDialog3.Execute then
        Image3.Picture.LoadFromFile(OpenPictureDialog3.FileName);
    end;procedure TForm1.Button5Click(Sender: TObject);
    begin
      if SavePictureDialog3.Execute then
        Image3.Picture.SaveToFile(SavePictureDialog3.FileName);
    end;end.//dfm
    object Form1: TForm1
      Left = 192
      Top = 103
      Width = 544
      Height = 375
      Caption = 'Form1'
      Color = clBtnFace
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      OldCreateOrder = False
      PixelsPerInch = 96
      TextHeight = 13
      object Image1: TImage
        Left = 24
        Top = 0
        Width = 105
        Height = 105
      end
      object Image2: TImage
        Left = 136
        Top = 0
        Width = 105
        Height = 105
      end
      object Image3: TImage
        Left = 248
        Top = 0
        Width = 105
        Height = 105
      end
      object Button1: TButton
        Left = 24
        Top = 112
        Width = 41
        Height = 25
        Caption = 'Load'
        TabOrder = 0
        OnClick = Button1Click
      end
      object Button2: TButton
        Left = 80
        Top = 112
        Width = 41
        Height = 25
        Caption = 'Save'
        TabOrder = 1
        OnClick = Button2Click
      end
      object Button3: TButton
        Left = 192
        Top = 112
        Width = 41
        Height = 25
        Caption = 'Save'
        TabOrder = 2
        OnClick = Button3Click
      end
      object Button4: TButton
        Left = 136
        Top = 112
        Width = 41
        Height = 25
        Caption = 'Load'
        TabOrder = 3
        OnClick = Button4Click
      end
      object Button5: TButton
        Left = 312
        Top = 112
        Width = 41
        Height = 25
        Caption = 'Save'
        TabOrder = 4
        OnClick = Button5Click
      end
      object Button6: TButton
        Left = 256
        Top = 112
        Width = 41
        Height = 25
        Caption = 'Load'
        TabOrder = 5
        OnClick = Button6Click
      end
      object Button7: TButton
        Left = 32
        Top = 232
        Width = 75
        Height = 25
        Caption = 'Change'
        TabOrder = 6
        OnClick = Button7Click
      end
      object RadioButton1: TRadioButton
        Left = 32
        Top = 152
        Width = 97
        Height = 17
        Caption = 'RadioButton1'
        Checked = True
        TabOrder = 7
        TabStop = True
      end
      object RadioButton2: TRadioButton
        Left = 144
        Top = 152
        Width = 89
        Height = 17
        Caption = 'RadioButton2'
        TabOrder = 8
      end
      object RadioButton3: TRadioButton
        Left = 264
        Top = 152
        Width = 89
        Height = 17
        Caption = 'RadioButton3'
        TabOrder = 9
      end
      object CheckBox1: TCheckBox
        Left = 144
        Top = 176
        Width = 49
        Height = 17
        Caption = '32*32'
        TabOrder = 10
      end
      object SpinEdit1: TSpinEdit
        Left = 264
        Top = 176
        Width = 57
        Height = 22
        MaxValue = 100
        MinValue = 1
        TabOrder = 11
        Value = 0
      end
      object OpenPictureDialog1: TOpenPictureDialog
        Filter = 'Bitmaps (*.bmp)|*.bmp'
        Left = 32
        Top = 24
      end
      object OpenPictureDialog2: TOpenPictureDialog
        Filter = 'Icons (*.ico)|*.ico'
        Left = 144
        Top = 24
      end
      object OpenPictureDialog3: TOpenPictureDialog
        Filter = 'JPEG Image File (*.jpg)|*.jpg|JPEG Image File (*.jpeg)|*.jpeg'
        Left = 264
        Top = 24
      end
      object SavePictureDialog1: TSavePictureDialog
        Filter = 'Bitmaps (*.bmp)|*.bmp'
        Left = 64
        Top = 24
      end
      object SavePictureDialog2: TSavePictureDialog
        Filter = 'Icons (*.ico)|*.ico'
        Left = 176
        Top = 24
      end
      object SavePictureDialog3: TSavePictureDialog
        Filter = 'JPEG Image File (*.jpg)|*.jpg|JPEG Image File (*.jpeg)|*.jpeg'
        Left = 296
        Top = 24
      end
    end
      

  10.   

    to zswang(伴水)(伤心中):
    我对你真是肃然起敬了呀!!!
    实在是太麻烦了,谢谢~~~~~~