function CreateBitmapFromRawImage(const RawImage: TRawImage; var Bitmap, MaskBitmap: HBitmap; AlwaysCreateMask: boolean): boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
function TWidgetSet.CreateBitmapFromRawImage(const RawImage: TRawImage;
var Bitmap, MaskBitmap: HBitmap; AlwaysCreateMask: boolean): boolean;
begin
Bitmap:=0;
MaskBitmap:=0;
Result := false;
end;
In my eyes this looks insane, but I'm a noob :oops:.
Anyway, my point is, instead of "CreateBitmapFromRawImage" doing a lot of complex tasks and then return some values for use. It just always fail the function without doing anything.
I guess I have missed something, or I missuse this function.
Anyway, what I want to do is this:
I have my own kind of Raw Image type I have constructed. It looks like this:
TGeneralRaw = class
Public
Height : integer;
Width : integer;
Data : Ansistring;
function palettetostring: ansistring; //RGB+RGB+RGB+RGB etc.
procedure Sparabitmap(bmp: TBitmap);
Palette : TPalette;
procedure palettetoimage(bmp: TBitmap;imgheight:word =50);
end;
I've made a procedure for the Sparabitmap procedure which is converting the bmp to what the Generalraw contains.
my first slow procedure was basically like this:
for Forer1 := 0 to self.Height-1 do
for Forer2 := 0 to self.Width-1 do
bmp.Canvas.Pixels[forer2,forer1]:=self.palette[byte(self.data[forer1*self.width+(forer2+1)])].Red or self.palette[byte(self.data[forer1*self.width+(forer2+1)])].Green shl 8 or self.palette[byte(self.data[forer1*self.width+(forer2+1)])].Blue shl 16 ;
It worked, but was somewhat slow, so I thought I could make it like this instead, so it will be faster:
var
RawImage:TRawImage;
LazIntfImage:TLazIntfImage;
BMPHandle,BMPMaskHandle:LongWord;
begin
RawImage.Description.Height:=self.Height;
RawImage.Description.Width:=Self.Width;
RawImage.Description.HasPalette:=true;
RawImage.Description.PaletteColorCount:=$100;
RawImage.Palette:=@Self.Palette;
RawImage.Data:=@Self.Data[1];
if not CreateBitmapFromRawImage(RawImage,BMPHandle,BMPMaskHandle,false)
then
raise FPImageException.Create('Failed to create bitmaps');
bmp.CreateFromBitmapHandles(BMPHandle,BMPMaskHandle,rect(0,0,self.Width,self.Height));
By making this, I had manually insert the interface and implementation for the CreateBitmapFromRawImage function. When I did this, I suddenly noticed that the CreateBitmapFromRawImage implementation looks so empty and weird and seem to give same output no matter what input(RawImage) you have.
Thank you,
Arash
PS. Of course, I would definitely appreciate any other solution to show the image faster. (Yea, I edit the bitmap for a TImage to display it)