Solved

TImage Bitmap.Vertual...

Posted on 1997-06-08
12
324 Views
Last Modified: 2010-04-06
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?
0
Comment
Question by:PPaul
  • 6
  • 3
  • 3
12 Comments
 
LVL 4

Expert Comment

by:StevenB
Comment Utility
 If you are using exclusively bitmaps then I wouldn't create a whole TImage, rather make do with a TBitmap. Is there some reason why you can't do this? I feel like I need a bit more info before I dive in with an answer.

  Steven.
0
 

Author Comment

by:PPaul
Comment Utility
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.
0
 

Author Comment

by:PPaul
Comment Utility
Adjusted points to 80
0
 

Author Comment

by:PPaul
Comment Utility
Edited text of question
0
 
LVL 3

Accepted Solution

by:
mheacock earned 80 total points
Comment Utility
The TBitmap will contain the original colours...

I would still show the bitmap in a TImage tho.  What you do
is load the bitmap into a TBitmap, then copy this image to
the Timage which is visible.

If you are trying to figure out colours as the mouse passes
over pixels, reference the TBitmap, not the TImage.

This will work fine for you.
0
 
LVL 3

Expert Comment

by:mheacock
Comment Utility
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.
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 4

Expert Comment

by:StevenB
Comment Utility
 Yeah, thats all correct. You certainly have to get up early to maintain a thread of comments arround these parts.

  Steven.
0
 

Author Comment

by:PPaul
Comment Utility
I'll give this a try and report back with the resaults.  Thanks.

0
 

Author Comment

by:PPaul
Comment Utility
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(Sender: TObject);
begin
image1.picture.bitmap.canvas.pixels[Spinedit1.value,0]
:= stringtocolor('$000000'+inttohex(SpinEdit1.Value,2)) ;
Label1.caption:= '$000000'+inttohex(SpinEdit1.Value,2);
Label2.caption:= inttostr(colortoRGB(Image1.Picture.bitmap.canvas.pixels[SpinEdit1.value,0]));

BMPT.canvas.pixels[Spinedit1.value,0]
:= stringtocolor('$000000'+inttohex(SpinEdit1.Value,2)) ;
Label3.caption:= '$000000'+inttohex(SpinEdit1.Value,2);
Label4.caption:= inttostr(colortoRGB(BMPT.canvas.pixels[SpinEdit1.value,0]));

end;

procedure TForm1.FormCreate(Sender: TObject);
begin
Image1.picture.bitmap.width:=260;
Image1.Picture.Bitmap.Height:=1;
BMPT:=Tbitmap.create;
BMPT.Width:=260;
BMPT.Height:=1;

end;
0
 
LVL 3

Expert Comment

by:mheacock
Comment Utility

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?
0
 
LVL 4

Expert Comment

by:StevenB
Comment Utility
 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.
0
 

Author Comment

by:PPaul
Comment Utility
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.
 
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video discusses moving either the default database or any database to a new volume.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now