Home > Back-end > How to modify the TBitmap this class? I'm dizzy!!!!!
How to modify the TBitmap this class? I'm dizzy!!!!!
Time:09-23
Have a project, need the server to get a series of TBitmap SaveToStream way write a continuous flow, and the client then read one by one from a flow inside with loadfromstream independent TBitmap, but found in actual operation, the TBitmap loadfromstream this method, is a sigh to read to the end, that is to say, want to use this method, I need to create a temporary stream, read a piece of data out of it, and then to TBitmap loadfromstream, for example, is as follows:
Server: BMP: TBitmap; BMP. Savetostream (stream); //... //... Among multiple bitmap into the flow, of course, there will be some segmentation mark
Client: BMP: TBitmap TMP: TMemoryStream;//define a temporary flow TMP. Copyfrom (stream, 10000);//with a temporary flow read a piece of data BMP. Loadfromstream (TMP);//BMP loaded from the temporary flow
Among the above code, had to borrow a temporary flow, seem to be very tedious, because TBitmap loadfromstream this method, all incredibly don't support the size, check the source code, is a private method TBitmap loadfromstream call Readstream: Procedure TBitmap. LoadFromStream (Stream: TStream); The begin ReadStream (Stream, Stream. Size - Stream. The Position ). end; Is too wicked, incredibly ReadStream is to support the size, the results here write the size parameters of the die into a rest all contents of the stream!!
So I'm going to modify TBitmap this class, the idea is simple, add a LoadFromStream2 method, increase a size parameter can be: Procedure TBitmap. LoadFromStream2 (Stream: TStream ; ASize: integer ); The begin ReadStream (Stream, ASize ). end;
But it is not so easy as I think, Tbitmap is a class, so the bottom was the VCL based class, one of the most important social phenomena, all of the system unit involves the bitmap to recompile, other ok, jpeg unit no source code, can't compile, and engineering and need jpeg this unit, I finally had to give up this way,
And he wants from TBitmap inherit a class, realize my LoadFromStream2 method, but after trying to just discover, TBitmap readfrom unexpectedly is a private method, subclasses can't access!!!!!!
So here's the thing: I just want to on the basis of the TBitmap, realize LoadFromStream with size parameters, what should I do? Help you master the ~ ~ ~
CodePudding user response:
This way, say first, what version of what's in the development environment of software, such as Delphi, Win32 or XE5, Win32, Win64 this