Change the background of dxdraw.

Source: Internet
Author: User

Delphix, a beginner, wants to change the background of dxdraw and finds this article.

Topic 247821 is titled:Ask delphix's brother (100 points)
Category:Graphical Image

Nutty (17:34:00)

Next, use dxdraw. Surface. Fill (devcolor: longint) to initialize the background color,
However, I do not know how to assign a value to the devcolor of this longint.

Symptom:
View its definition, which can be expressed in RGB color, but when I want the background to be green,
Run dxdraw. Surface. Fill (RGB (0,128, 0) to obtain the purple background!

Wjiachun (17:55:00)

Dxdraw. Surface. Fill (RGB (0,255, 0 ));

Nutty (17:56:00)

That is to say
The value range is-7ffffffe----7fffffff tcolor and
How do I convert Dev colors with a value of 0----ffffff?

Nutty (17:58:00)

Wjiachun brother:
Not like this...
Dxdraw. Surface. Fill (clgreen) returns a purple background... faint

Wjiachun (18:07:00)

I faint too!

Croco (18:08:00)

The value range is-7ffffffe----7fffffff tcolor and
How do I convert Dev colors with a value of 0----ffffff?
>
Delphix has never been used, and conversion is available:
Function colortorgb (color: tcolor): longint;

> The call in the example is not helpful:
VaR Col: trgbquad;
C: = dxdraw. Surface. colormatch (RGB (Col. rgbred, col. rgbgreen, col. rgbblue ));
Dxdraw. Surface. Fill (C );

Nutty (22:52:00)

Still not. Isn't the last six bytes of the color used in the color representing RGB? Or is the color palette useless?

Zephyr (23:26:00)

The Col parameter is actually the data of pixels in the memory. Its value depends on the tdxdraw control's
The value of surface. bitcount. When bitcount is 8, each pixel is expressed as 1 byte (8 bits ),
In this case, the col parameter is actually the index value of a palette. Only the last 8 bits (0 to 255) are used ).
When bitcount is 24, each pixel is represented by 3 bytes, And the last six bytes of Col represent
RGB. It is estimated that you are using a 16-bit display mode such as 640x480x16 (check the dxdraw's
Display attribute). In this case, the last 15 digits of the col parameter represent the RGB component.
The color is 5 bits, so you cannot use $00ff00 to display green. You can use bitwise operations as needed
Generates the col value in 16-bit display mode.

Fudei (2000-05-20)

Why not? I used it.

Nutty (22:39:00)

It is indeed set to 24 bits true color to display the correct color, Zephyr brother really got it...

But what should I do if I set the window color to 16 or 8 bits? If you use RGB (R, G, and B) to fill in the color, it will be displayed in disorder again. I remember there was a discussion in the Forum, but it was gone. Do you have a good idea?

Zephyr (1:03:00)

Calculate the color value based on the actual situation (that is, first determine the current display mode, and then according to the current display mode
Formula ). Or let your program run in full screen mode.
Set the display attribute of tdxdraw to the display mode of 24bits.
It runs in the display mode specified by the display attribute. For details, refer to the delphix example.

Maybe (should) there is a better way.

Nutty (1:24:00)

Thank you.

Sunwork (20:44:00)

How to Use DirectDraw to display true-color images? I can only display 256-color images, and set them with setdisplaymode (800,600, 8)
An error occurs when you set it to true color mode (800,600, 24. Is there a solution?

Zephyr's answer was finally accepted.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.