Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Best way to handle multiple color depth bitmaps

Posted on 2006-03-31
4
Medium Priority
?
252 Views
Last Modified: 2013-12-03
Hi,

I want my application to work well when the display is set for different color depths. Specifically, I want to be able to display 16 color bitmaps in my speed buttons when the display is set to 256 colors, and 256 color bitmaps when the display is set to a higher color depth setting.

My question is, how should I store the different color depth bitmaps, and how do I automatically switch them when the display settings change?

Regards,

Bill
0
Comment
Question by:wipnav
  • 3
4 Comments
 
LVL 11

Accepted Solution

by:
ZhaawZ earned 500 total points
ID: 16345285
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs;

type
  TForm1 = class(TForm)
    procedure onDisplayChange (var msg : TMessage); message wm_displaychange;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.onDisplayChange(var msg : TMessage);
begin
// this procedure is the place where you should switch pics
ShowMessage(Format('%d x %d @ %d bits', [msg.lParam and $ffff, msg.lParam shr 16 and $ffff, msg.wParam]));
end;

end.
0
 
LVL 11

Expert Comment

by:ZhaawZ
ID: 16345386
About switching images... I'm not sure, but it could be done like this:


procedure TForm1.onDisplayChange(var msg : TMessage);
var
  ImageList : TImageList;
begin
if msg.wParam <= 4 then begin // 16 colors or less
  ImageList := ImageList2;
end else begin // more than 16 colors
  ImageList1 := ImageList1;
end;
ImageList.GetBitmap(0, SpeedButton1.Glyph);
ImageList.GetBitmap(1, SpeedButton2.Glyph);
end;
0
 
LVL 1

Author Comment

by:wipnav
ID: 16345460
Thank you that helps.

Also, is there a way to check the color depth when my application starts up so that I can assign the correct initial imagelist?
0
 
LVL 11

Expert Comment

by:ZhaawZ
ID: 16345585
Sure, there is. Put this in onCreate event:

var
  dev : DevMode;
begin
ZeroMemory(@dev, sizeof(dev));
dev.dmSize := sizeof(dev);
// we need only color depth, so set dmFields to dm_bitsperpel
dev.dmFields := dm_bitsperpel;
// get current screen settings (in our case - only color depth)
EnumDisplaySettings(nil, {enum_current_settings} $ffffffff, dev);
// dev.dmBitsPerPel will be current screen resolution, so send it as wParam
// resolution is not needed in our case, so we can leave 0 as lParam
SendMessage(handle, wm_displaycnage, dev.dmBitsPerPel, 0);
end;
0

Featured Post

Technology Partners: 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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

810 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