Solved

several TImages, 1 hPalette -> problem

Posted on 1997-10-20
4
521 Views
Last Modified: 2012-08-13
I use several TImages to display data. They all need the same colours, so I made 1 logical palette and 1 hPalette, which I assigned to the Picture.Bitmap.Palette property of all TImages. I use CopyRect to copy part of a memory bitmap to the TImages. This goes OK, unless I mirror the data in the CopyRect. (by passing for the source rect: Bounds(width-1, 0, -width, height-1)). Then the TImage stays black. If I give every TImage its own hPalette, the mirroring goes fine.

My questions:
1- is what I try at all posiible, or do all TImages always need  a unique hPalette?
2- if it is possible, what should I change to make it work?

thanks,

Wim
0
Comment
Question by:cadenza
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Author Comment

by:cadenza
ID: 1348435
Edited text of question
0
 

Accepted Solution

by:
jorgen.hojdmo earned 150 total points
ID: 1348436
Hi!

I have had the same problem, but could not make it work properly by assigning the palette property. A workaround is to use the WinAPI. Before you draw on the bitmap call:

SelectPalette(Bitmap.Canvas.Handle,YourHPalette,false);
RealizePalette(Bitmap.Canvas.Handle);

This will work fine if you do not assign the Palette.

Call the select and realize everytime your app gets focus.


0
 
LVL 3

Expert Comment

by:mirek071497
ID: 1348437
This is fine however better way is to remember the hPalette in your program and use SelectPalette( savedpalette .....
at the end of pgm you must delete this object.

BTW SelectPalette  returns previous palette so you must save this and then restore. You can loose resources if this will not be done !.

prevpal := SelectPalette( ...
...
any code
...
SlelectPalette( prevpal

this is good idea to save resources without loose.

sorry for my english.
0
 

Author Comment

by:cadenza
ID: 1348438
Thanks for the answer and valuable comment. This not only will save me time, but, as I understand from Mirek's comment, resources as well !!!

Wim
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

690 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