Solved

several TImages, 1 hPalette -> problem

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 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

9 Experts available now in Live!

Get 1:1 Help Now