From: "Peter Below (TeamB)" <100113.1101@compuXXserve.com> Subject: Re: Bitmaps & Files Date: 27 Apr 1999 00:00:00 GMT Message-ID: Content-Transfer-Encoding: 8bit References: <3724BFE5.5050E751@Hotmail.com> Content-Type: text/plain; charset=iso-8859-1 Organization: TeamB Mime-Version: 1.0 Reply-To: 100113.1101@compuXXserve.com Newsgroups: borland.public.delphi.objectpascal In article <3724BFE5.5050E751@Hotmail.com>, The Patrician wrote: > Is there a way to copy the Bitmap data from a bitmap into a array of > byte(??), so I can save it to a file, which contains other files as > well; How do I reverse this process. > Yes, it is not very complicated. You save the bitmap to a memory stream first, using its SaveToStream method. To store it into a file that contains other data as well you first write the size of the memorystream to the file, then the memory stream itself. This is easiest if you access the file via TFilestream. Procedure SaveBitmapToStream( aBitmap: TBitmap; aStream: TStream ); Var ms: TMemoryStream; size: Integer; Begin Assert( Assigned(aBitmap)); Assert( Assigned(aStream)); ms:= TMemoryStream.Create; try aBitmap.SaveToStream(ms); ms.position := 0; size := ms.Size; aStream.WriteBuffer( size, Sizeof(size)); aStream.CopyFrom(ms, size ); finally ms.free end; End; Procedure LoadBitmapFromStream(aBitmap: TBitmap; aStream: TStream ); Var ms: TMemoryStream; size: Integer; Begin Assert( Assigned(aBitmap)); Assert( Assigned(aStream)); ms:= TMemoryStream.Create; try aStream.ReadBuffer( size, Sizeof(size)); ms.CopyFrom(aStream, size ); ms.position := 0; aBitmap.LoadfromStream(ms); finally ms.free end; End; Peter Below (TeamB) 100113.1101@compuserve.com) No e-mail responses, please, unless explicitly requested!