SRL Archive - Help and Support

CreateBitmapString broken?


riwu

2012-11-22 02:56:13

The bitmap turned black (null) after dual conversion (which should theoretically get back the same bitmap)

program new;
{$I SRL/SRL.simba}
{$I SRL/SRL/Misc/debug.Simba}

var
Bmp, w, h: Integer;

begin
GetClientDimensions(w, h);

Bmp:= BitmapFromClient(0, 0, w/10, h/10);
DebugBitmap(Bmp);
wait(2000);

DebugBitmap(BitmapFromString(w/10, h/10, CreateBitmapString(Bmp)));

FreeBitmap(Bmp);
end.

(running this will result in unfreed bmp because i didn't assign a handler, to make things easier to see.)

CynicRus

2012-11-22 07:39:08


program new;
{$I SRL/SRL.simba}
{$I SRL/SRL/Misc/debug.Simba}

var
Bmp, w, h: Integer;
tmp: TMufasaBitmap;

begin
GetClientDimensions(w, h);
tmp:=TMufasaBitmap.Create;
Bmp:= BitmapFromClient(0, 0, w/10, h/10);
DebugBitmap(Bmp);
wait(2000);
tmp:=BitmapFromString(w/10, h/10, CreateBitmapString(Bmp));
DebugBitmap(tmp);

FreeBitmap(Bmp);
end.

try that.

riwu

2012-11-22 07:40:28

Same result, some desktop icons, then turn into black.

Dgby714

2012-11-22 08:52:54

Do you have anything special working on your desktop? Like an active desktop?

From: CynicRus

program new;
{$I SRL/SRL.simba}
{$I SRL/SRL/Misc/debug.Simba}

var
Bmp, w, h: Integer;
tmp: TMufasaBitmap;

begin
GetClientDimensions(w, h);
tmp:=TMufasaBitmap.Create;
Bmp:= BitmapFromClient(0, 0, w/10, h/10);
DebugBitmap(Bmp);
wait(2000);
tmp:=BitmapFromString(w/10, h/10, CreateBitmapString(Bmp));
DebugBitmap(tmp);

FreeBitmap(Bmp);
end.

try that.


That made no sense….

riwu

2012-11-22 09:05:17

I've tried it with different targets (originally with Smart),

first result:


after dual conversion:



I want to automatically make bitmaps of the abilities so i'll have to convert them to string. The only function that i'm using for the first time here is CreateBitmapString so i presume that's the cause.

Have you guys tried running the code? Is this only happening to me?

masterBB

2012-11-22 09:11:11

GetMufasaBitmap(BitmapFromString(w/10, h/10, GetMufasaBitmap(Bmp).ToString)).ToString

The string created by GetMufasaBitmap(Bmp).ToString is the long string representing the first bitmap, but the bitmap created is a black bitmap. Usually a very short string…

Dgby714

2012-11-22 09:14:08

Have no clue why two conversions break it, tho it might just be one of the functions misbehaving.

program new;

var
W, H: LongInt;
Bitmap: TMufasaBitmap;

begin
SetDesktopAsClient();
GetClientDimensions(W, H);

Bitmap := TMufasaBitmap.Create;
try
Bitmap.SetSize(W / 4, H / 4);
Bitmap.CopyClientToBitmap(GetTClient().IOManager, True, 0, 0, 0, 0, W / 4, H / 4);

// Your string is at Bitmap.ToString()

DisplayDebugImgWindow(Bitmap.Width, Bitmap.Height);
DrawBitmapDebugImg(Bitmap.Index);
finally
Bitmap.Free;
end;
end.

masterBB

2012-11-22 09:17:17

Oh we are so stupid! So stupid! The reason the image is black is because we entered wrong heights and widths… therefore the string couldn't be converted.

w/10 + 1
h/10 + 1

or

BitmapFromString(GetMufasaBitmap(Bmp).Width, GetMufasaBitmap(Bmp).Height, GetMufasaBitmap(Bmp).ToString);

riwu

2012-11-22 09:29:46

From: masterBB
Oh we are so stupid! So stupid! The reason the image is black is because we entered wrong heights and widths… therefore the string couldn't be converted.

w/10 + 1
h/10 + 1

or

BitmapFromString(GetMufasaBitmap(Bmp).Width, GetMufasaBitmap(Bmp).Height, GetMufasaBitmap(Bmp).ToString);

Thanks a lot!
Forgot about it starting from 0…