Solved

several TImages, 1 hPalette -> problem

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to draw animated progressbar in Tvirtualstringtree 5 117
build html 5 client that connect to indy Tidtcpserver 3 356
code issue 8 100
Dynamically Created Query 3 50
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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

867 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

19 Experts available now in Live!

Get 1:1 Help Now