Solved

several TImages, 1 hPalette -> problem

Posted on 1997-10-20
4
520 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

726 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