PPaul
asked on
TImage Bitmap.Vertual...
If I creat a TImage that dosn't show on the form Will the Colour Palette be adjusted to the Windos Colour Palette? If not then could I get the exact colour of a pixel on its Bitmap?
ASKER
The TBitmap Is a good sugestion and is going to be used, thanks. But I'am Trying to creat a program that changes text (ACSII) to a Graphical (Pixel) Format. Each Pixel will use the blue 0-255 for the main characters and red 0-255 for the text type (Bold, Itilic, Underline, and Green and Blue for the Unecode. I use to be able to do this when I had a Amega and would like to reproduce the same in Windows 95. I've found that when showing the Bitmap on the screen and trying to get it's pixel by pexel colours it would round it to the closes colour in the window colour palette. I figure that if I don't display the bitmap it souldn't change the colours on the bitmap.
ASKER
Adjusted points to 80
ASKER
Edited text of question
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If I remember correctly the code would look something like
this:
Bitmap := TBitmap.Create;
Bitmap.LoadFromFile('mybmp .bmp');
Image.Canvas.Assign(Bitmap .Canvas);
....
//get pixel colour
Colour := Bitmap.Canvas.Pixel[X, Y];
The exact syntax may be wrong...but you get a really good idea
of what to do...hopefully...feel free to ask follow-up questions.
this:
Bitmap := TBitmap.Create;
Bitmap.LoadFromFile('mybmp
Image.Canvas.Assign(Bitmap
....
//get pixel colour
Colour := Bitmap.Canvas.Pixel[X, Y];
The exact syntax may be wrong...but you get a really good idea
of what to do...hopefully...feel free to ask follow-up questions.
Yeah, thats all correct. You certainly have to get up early to maintain a thread of comments arround these parts.
Steven.
Steven.
ASKER
I'll give this a try and report back with the resaults. Thanks.
ASKER
UPDATE
Ok. I tried what you said and still I get the colors rounded to the Windows Palette Colors not the true color of the image pixels.
To test the code you gave me I made this demo. It has a SpinEdit, Image and 4 Labels on the form. Am I still doing something worng!?
The Code:
procedure TForm1.SpinEdit1Change(Sen der: TObject);
begin
image1.picture.bitmap.canv as.pixels[ Spinedit1. value,0]
:= stringtocolor('$000000'+in ttohex(Spi nEdit1.Val ue,2)) ;
Label1.caption:= '$000000'+inttohex(SpinEdi t1.Value,2 );
Label2.caption:= inttostr(colortoRGB(Image1 .Picture.b itmap.canv as.pixels[ SpinEdit1. value,0])) ;
BMPT.canvas.pixels[Spinedi t1.value,0 ]
:= stringtocolor('$000000'+in ttohex(Spi nEdit1.Val ue,2)) ;
Label3.caption:= '$000000'+inttohex(SpinEdi t1.Value,2 );
Label4.caption:= inttostr(colortoRGB(BMPT.c anvas.pixe ls[SpinEdi t1.value,0 ]));
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Image1.picture.bitmap.widt h:=260;
Image1.Picture.Bitmap.Heig ht:=1;
BMPT:=Tbitmap.create;
BMPT.Width:=260;
BMPT.Height:=1;
end;
Ok. I tried what you said and still I get the colors rounded to the Windows Palette Colors not the true color of the image pixels.
To test the code you gave me I made this demo. It has a SpinEdit, Image and 4 Labels on the form. Am I still doing something worng!?
The Code:
procedure TForm1.SpinEdit1Change(Sen
begin
image1.picture.bitmap.canv
:= stringtocolor('$000000'+in
Label1.caption:= '$000000'+inttohex(SpinEdi
Label2.caption:= inttostr(colortoRGB(Image1
BMPT.canvas.pixels[Spinedi
:= stringtocolor('$000000'+in
Label3.caption:= '$000000'+inttohex(SpinEdi
Label4.caption:= inttostr(colortoRGB(BMPT.c
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Image1.picture.bitmap.widt
Image1.Picture.Bitmap.Heig
BMPT:=Tbitmap.create;
BMPT.Width:=260;
BMPT.Height:=1;
end;
About your code...could you show some of the output...are you
actually comparing the values on your screen?? Because one
of the values is hex and the other dec...why not show label3
as an int too?
It's best not to accept an answer before the question has been thoroughly resolved, that way other people can continue to add their thoughts on the subject.
The Bitmap will contain the correct colour information, but when displayed on the screen, the canvas colours will be realised to the available pallete. You'll probably have to read the Bitmap directly.
I can't afford 8 points to add any more comments here, good luck.
Steven.
The Bitmap will contain the correct colour information, but when displayed on the screen, the canvas colours will be realised to the available pallete. You'll probably have to read the Bitmap directly.
I can't afford 8 points to add any more comments here, good luck.
Steven.
ASKER
UPDATE
First off Thanks StevenB for trying to help. I will remember that in the furter about accepting the Answers after all posable solutions are given. Sorry :(
The reason I get it to show the Hex and the Dec value is to see if it convers it back to a ACSII Code. Label1 and Label2 is for the Image1, the write and read as ASCII Code. Label3 and Label4 is for the Tbitmap and again the write and read as ASCII Code. I'll try to contact the sysop to see if the question can be reopned! or if there a way I can give you my E-Mail.
First off Thanks StevenB for trying to help. I will remember that in the furter about accepting the Answers after all posable solutions are given. Sorry :(
The reason I get it to show the Hex and the Dec value is to see if it convers it back to a ACSII Code. Label1 and Label2 is for the Image1, the write and read as ASCII Code. Label3 and Label4 is for the Tbitmap and again the write and read as ASCII Code. I'll try to contact the sysop to see if the question can be reopned! or if there a way I can give you my E-Mail.
Steven.