提示Access violation at address 0045c00 in module 'project1.exe',read of address 0000000.错误.

解决方案 »

  1.   

    var
      TempStream : TMemoryStream;
    begin
      TempStream := TMemoryStream.Create;
      image1.Picture.Bitmap.SaveToStream(tempstream);
      TempStream.Position := 0;
      image2.Picture.Bitmap.LoadFromStream( TempStream);
      TempStream.Free;
    end;
    这样就对了。
      

  2.   


    提示Access violation at address 0045c00 in module 'project1.exe',read of address 0000000.错误.
      

  3.   

    但是image2里没显示出画面呀?
      

  4.   

    以下下语句我已经试过了,楼主你也去试一下吧。
    var
      TempStream : TMemoryStream;
    begin
      TempStream := TMemoryStream.Create;
      image1.Picture.Bitmap.SaveToStream(tempstream);
      TempStream.Position := 0;
      image2.Picture.Bitmap.LoadFromStream( TempStream);
      TempStream.Free;
    end;
      

  5.   

    TO hjd_cw,试过了,没报错但是不显示画面为何?
      

  6.   

    我刚才试的时候可以显示图像的!
    你的图像文件是什么?能传个过来看看吗?
    [email protected]
      

  7.   

    JPEG是跟BMP不一样的。
    你先看看 TJPegImage 的帮助 和 例子。
      

  8.   

    BMP可以通过,但是jpg、jpeg类的就不行了,我uses jpeg可是还不行。
      

  9.   

    打开...\Delphi5\Source\VCL\Graphics.pas,在里面添加一个类:
      TPictureEx = Class(TPicture)
        public
          procedure SaveToStream(Stream: TStream);
          procedure LoadFromStream(Stream: TStream);
      end;
    procedure TPictureEx.LoadFromStream(Stream: TStream);
    var
      GraphClassName: String;
    0A  ClassNameLen: Integer;
      GraphClass: TGraphicClass;0D
      NewGraphic: TGraphic;
    begin
      Stream.Read(ClassNameLen,Sizeof(ClassNameLen));
      GraphClassName := StringOfChar(#0,ClassNameLen);
      Stream.Read(GraphClassName[1],ClassNameLen);
      GraphClass := FileFormats.FindClassName(GraphClassName);
      if GraphClass = nil then
        raise EInvalidGraphic.CreateFmt(SUnknownClassName, [GraphClassName]);  NewGraphic := GraphClass.Create;
      try
        NewGraphic.OnProgress := Progress;
        NewGraphic.LoadFromStream(Stream);
      except
        NewGraphic.Free;
        raise;
      end;
      Graphic:=NewGraphic;
    end;
    procedure TPictureEx.SaveToStream(Stream: TStream);
    var
      GraphClassName: String;
    0A  ClassNameLen: Integer;
    begin
      if Graphic<> nil then
      begin
        GraphClassName := Graphic.ClassName;
        ClassNameLen := Length(GraphClassName);
        Stream.Write(ClassNameLen,Sizeof(ClassNameLen));
        Stream.Write(GraphClassName[1],ClassNameLen);
      end;
    end;然后把它加入到一个临时工程中,去掉调试选项,编译这个工程,把生成的Graphics.dcu拷贝到...\Delphi5\lib中.选中调试选项编译,拷贝到...\Delphi5\lib\debug中.
    然后在你的程序中使用TPictureEx,用它的SaveToStream保存,用它的LoadFromStream读.
    这个类就是在SaveToStream时保存了Picture.Graphic.ClassName,这样在读的时候就知道图像是什么格式了.
      

  10.   

    delphi5\help\samples\jpeg\jpegproj.dpr
    这个例子去看一下。
      

  11.   

    我试了一下这样的语句
    var
      TempStream : TMemoryStream;
    begin
      TempStream := TMemoryStream.Create;
      TJPEGImage(Image1.Picture.Graphic).SaveToStream(tempstream);
      TempStream.Position := 0;
      TJPEGImage(Image2.Picture.Graphic).LoadFromStream(TempStream);
      TempStream.Free;
    end;
    可以成功,但前提是image2中已有JPEG图像。
      

  12.   


    var
      TempStream : TMemoryStream;
    begin
      TempStream := TMemoryStream.Create;
      image1.Picture.Bitmap.SaveToStream(tempstream);
      TempStream.Position := 0;
      image2.Picture.Bitmap.LoadFromStream( TempStream);
      TempStream.Free;
    end;
    如果是jpg ,user 加上JPEG