PDA

View Full Version : Creating a bitmap from a string?



Jason2gs
05-25-2007, 02:01 AM
I can't seem to find anything to tell me how to convert a bitmap to a string.

Ya see, I need a bitmap for something. I want to be able to paste a picture anywhere on the canvas I want. Could someone tell me how, please?

Oh, and how do I see what the mouse coords are, in Delphi? That'll also help on my project, I think.

Freddy1990
05-25-2007, 12:34 PM
To convert a bitmap to a string, just get the hex values of each pixel and put them in a string, also don't forget to keep the height and width of the bitmap so you can put it back together again later.
For getting the mouse pos, just use
function GetCursorPos(var lpPoint: TPoint): LongBool;
or
Mouse.CursorPos: TPoint;

Jason2gs
05-25-2007, 04:07 PM
Hex values of each pixel? Okay.

As for the mouse coords, I actually meant something like with SCAR. Where the mouse coords are always up. I guess I could just bring SCAR up, and target the form, right?

So I get the hex values for the picture. How would I do that? Just google for a picture-to-hex converter? Or does SCAR use the same thing when it converts bitmaps to strings?

Also, what would I save the string as? TGraphic?

Freddy1990
05-25-2007, 11:38 PM
You use a TBitmap, loop trough every pixel and add their hew values to a string, later you do the same backwards, it's not that hard, you can modify my findcolor source for looping though each pixel.

And I have no clue what you mean with that coordinate thingy

Jason2gs
05-26-2007, 01:51 AM
TBitmap. Got it. What command do I use to set that where I want it? Canvas.Draw?

And you know how SCAR has a status bar with the current mouse coords? I wanted something like that, but in the Delphi window. I guess I'll just use the SCAR window?

Oh, and what (basically) is SCAR? Script Control, correct?


Alright, I got the hex code setup. (Used a program. It was pretty cool :))



010011010110000111
000001110100001001
000010100101000110
001101000101111010
100110100010101100
000110000001010100
010101101011010001
100111111010110000
010111100101000110


I saved it as a string, but it didn't seem to work.


procedure TForm1.FormCreate(Sender: TObject);
begin
Bmp := {Above Code Here};
Bmp.Width := 9;
Bmp.Height := 9;
Canvas.Draw(80, 80, Bmp);
end;


Shouldn't that work?

Freddy1990
05-26-2007, 07:48 AM
That's not hex code, that's binary code, this is hex code:
FFFF33FFFF33000000FFFF00FFFF00FFFF00FFFF00FFFF00FF FF00
FFFF00EFEF0036360038350A1C1C1C00000000000000000000 0000
0000000000000000000000000000000000003D3D055F5F13FF FF33
FFFF33FFFF33FFFF33FFFF33FFFF33FFFF33FFFF33000000FF FF00
FFFF00FFFF00FFFF00FFFF00FFFF00FFFF00FFFF00EFEF0036 3600
38350A1C1C1C00000000000000000000000000000000000000 0000
0000003D3D055F5F13FFFF33FFFF33FFFF33FFFF33FFFF33FF FF33

ugh, I might write it myself -_-

Why do you need it anyway?

Jason2gs
05-26-2007, 07:56 AM
Oooh, alright...

You don't have to write it yourself. I'll figure it out. (I'm just new to Delphi and all.)

I'm working on a project to... Well, I'd rather not tell until it's done. I just have a feeling I'm going to need something like this a lot.

Edit: Ahh, I had the right program, but I had the output set to Binary :p



F4AB53644B0D5CF6E8
FC8EC4F86D4248964E
835D34F6379AC2D679
2E61C5B9790EB5A50D
9D95E649F3079A5F82
E7DC9B21D6C52DCEC6
077AA3B749FEF95F43
03984F3E96266AF154
465A23E82B3A2F33B8


There we go...

Freddy1990
05-26-2007, 09:10 AM
Can you pm me what ur working on? I won't tell anyone :) I'm the master of secret projects :P

Jason2gs
05-26-2007, 04:45 PM
Heh, alright :p