- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to set a Brush Color without using QUICKWIN
If I use the RGB command I am asked for a type. I have spent several enjoyable hours hunting through the IFWIN.f90 etc files looking for an RGB type, but to no avail. I learnt a lot along the way.
Anyone know the RGB type and where it is decalred.
Thanks
JMN
If I use the RGB command I am asked for a type. I have spent several enjoyable hours hunting through the IFWIN.f90 etc files looking for an RGB type, but to no avail. I learnt a lot along the way.
Anyone know the RGB type and where it is decalred.
Thanks
JMN
Link Copied
12 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
RGB is a Windows function which creates the ColorRef data type in which 8-bit color intensity values for red, green and blue are packed into a single 4-byte integer.
[bash]! wrapper function to convert supplied INTEGER*4 color values ! to BYTE format required by Win32 API function RGB INTEGER FUNCTION Make_RGB (red, grn, blu) IMPLICIT NONE INTEGER, INTENT(IN) :: red, grn, blu Make_RGB = RGB (INT1(red), INT1(grn), INT1(blu)) END FUNCTION Make_RGB ! extract the components from the supplied colorRef red = RSHFT(IAND(RGBcolor, Z'00FF0000'), 16) green = RSHFT(IAND(RGBcolor, Z'0000FF00'), 8) blue = IAND(RGBcolor, Z'000000FF')
! sample color
britepink = Make_RGB (243, 67,194)
[/bash]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Paul:
Thanks heaps. I got started on this quest when I was doing a detailed set of comments inside the code for the CX1 reader. I wanted to change the Brush type and it proved harder than I thought.
JMN
Thanks heaps. I got started on this quest when I was doing a detailed set of comments inside the code for the CX1 reader. I wanted to change the Brush type and it proved harder than I thought.
JMN
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
RGB is a function in IFWBASE (DFWBASE if using CVF).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Anthony and Paul
Thank you for the answers. I got Pauls' code to work and then looked to incorporate the code into my main program to change the background color of the main window.
I started by loading the IFWINTY.F90 from the include directory into a Word Document to look at the structure of the Types created by the Intel programmers. This file ran to 850+ pages in monotext. As a PDF file it is useful for searching.
I then looked inside all the F90 files that are used in the standard programs. It appears that they are all called from IFWIN.F90 as a module call, which means I believe I only ever need to include this use statement.
use ifwin
I went back to Lawrence's sampleand tried to load some his sample programs that use colors. Unfortunately, some of his programs will not load in IVF. [Steve canI suggest that it would be worth Intel's time ask Lawrence if you can fix these programs and then include the source code in your samples. it would make his book more useful for current compilers and allow you to demonstrate some of the changes you have made.]
From the Draw2 program I usedbrush type to create an empty brush, then used iRed, iGreen and iBlue to create three ints for the color components. it ook a while to work out I needed a int4 hbrush. I culd then set the components of the brush to solid and set the color. I then used CreateBrushIndirect and this gave me a HBRUSH integer that showed up nicely in the debug mode.
I could set the background to the HBRUSH and I now get the background I want.
I then went back and slowly deleted all use statements except IFWIN and the program continued to run nicely.
Paul: britePink is very brite and very pink.
Thanks again
JMN
integer(4) iRed, iGreen, iBlue
integer*4 ret, hbrush
Thank you for the answers. I got Pauls' code to work and then looked to incorporate the code into my main program to change the background color of the main window.
I started by loading the IFWINTY.F90 from the include directory into a Word Document to look at the structure of the Types created by the Intel programmers. This file ran to 850+ pages in monotext. As a PDF file it is useful for searching.
I then looked inside all the F90 files that are used in the standard programs. It appears that they are all called from IFWIN.F90 as a module call, which means I believe I only ever need to include this use statement.
use ifwin
I went back to Lawrence's sampleand tried to load some his sample programs that use colors. Unfortunately, some of his programs will not load in IVF. [Steve canI suggest that it would be worth Intel's time ask Lawrence if you can fix these programs and then include the source code in your samples. it would make his book more useful for current compilers and allow you to demonstrate some of the changes you have made.]
From the Draw2 program I usedbrush type to create an empty brush, then used iRed, iGreen and iBlue to create three ints for the color components. it ook a while to work out I needed a int4 hbrush. I culd then set the components of the brush to solid and set the color. I then used CreateBrushIndirect and this gave me a HBRUSH integer that showed up nicely in the debug mode.
I could set the background to the HBRUSH and I now get the background I want.
I then went back and slowly deleted all use statements except IFWIN and the program continued to run nicely.
Paul: britePink is very brite and very pink.
Thanks again
JMN
useIFWIN
type (T_LOGBRUSH ) brushinteger(4) iRed, iGreen, iBlue
integer*4 ret, hbrush
iRed = 255
iGreen = 100
iBlue = 255
brush.lbStyle = BS_SOLID
brush.lbColor = rgb(iRed,iGreen,iBlue)
hBrush = CreateBrushIndirect(brush)
wc%hbrBackground = (hbrush)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The point of my MakeRGB wrapper function is that the WinAPI function RGB() takes single-byte arguments, not I*4.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
With ifort 12.0 I think your MakeRGB wrapper is now redundant - the RGB name in the IFWBASE module is a generic interface to a function that has a specific that takes DWORD kind (i.e. INTEGER(4)) arguments, in addition to a specific that takes BYTE kind arguments. For additional kinds it is probably best to just extend that generic. If Intel were to add the same variants then we
would get a compile time error, but that should be quite transparent and
trivial to repair.
(Note there's no real RGB function in the Window's API anyway - it is just a macro in the C headers for the appopriate bit operations. It is Intel's libraries that provide the tiny helper function that does the equivalent for Fortran code. You could have directly put the same code in your wrapper and maybe saved 0.01 billionths of a picosecond of processor time.)
(Note there's no real RGB function in the Window's API anyway - it is just a macro in the C headers for the appopriate bit operations. It is Intel's libraries that provide the tiny helper function that does the equivalent for Fortran code. You could have directly put the same code in your wrapper and maybe saved 0.01 billionths of a picosecond of processor time.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The type of an integer is determined by how it is declared, not the particular value it is given, hence your statement
is incorrect if these variables are to be used as arguments for the RGB macro.
[bash]integer(4) iRed, iGreen, iBlue[/bash]
is incorrect if these variables are to be used as arguments for the RGB macro.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Paul and Ian:
I will go back and tidy up the integer type now that I understand what Intel has done in the IFWINTY, but it is 850 pages long and takes a while to get through. I would put it up on thr forum as a PDF file which would make it searchable, but not till Steve says Intel would not be upset.
The other interesting issue is the great examples in Lawrence's book are now getting to the stage of being unusable without some changes because of structural differences between CVF and IVF. This is not helped by the current reliance on HTML for help files. I go looking for an answer and end up in the MICROSOFT helo files for windows, which are interesting but not the full answer. I then go back to Lawrence and Petzold and this forum. It would be nice if it was not so hard for newcomers. We want people to like Fortran not find it hard.
In terms of speed, this is an issue with the current code, but I will optimize last.
It is just alot of fun.
JMN
I will go back and tidy up the integer type now that I understand what Intel has done in the IFWINTY, but it is 850 pages long and takes a while to get through. I would put it up on thr forum as a PDF file which would make it searchable, but not till Steve says Intel would not be upset.
The other interesting issue is the great examples in Lawrence's book are now getting to the stage of being unusable without some changes because of structural differences between CVF and IVF. This is not helped by the current reliance on HTML for help files. I go looking for an answer and end up in the MICROSOFT helo files for windows, which are interesting but not the full answer. I then go back to Lawrence and Petzold and this forum. It would be nice if it was not so hard for newcomers. We want people to like Fortran not find it hard.
In terms of speed, this is an issue with the current code, but I will optimize last.
It is just alot of fun.
JMN
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Bear:
I made just one change to bring n line with the IVF coding standard. JMN (AQUAMARINE is awful)
I made just one change to bring n line with the IVF coding standard. JMN (AQUAMARINE is awful)
[bash]MODULE CVFColours ! ! This module declares and sets the 140 HTML colours for CVF in B, G, R order, ! in contrast to the HTML Color Table, where they are R, G, B. The names are ! currently the same as for HTML except for TANN, which has been changed to ! avoid clashing with the trigonometric function Tan. ! Note that AQUA = CYAN = #FFFF00 & FUCHSIA = MAGENTA = #FF00FF. ! Contents are: ! 1. Integer*4 Colour Names and values. ! 2. Character*20(140) ColourName array. ! 3. ColourNameString*2800 Concatenated string of ColourName strings. ! 4. Character*560 String containing short names for colours. ! 5, Integer*4(140) ColourNumber array. ! 6. Integer*4(140) TextBorW array indicating whether Black or White ! displays text better on a background of the ! ColourNumber colour. ! March 2004 A J Cruttenden Ballistics & Fortran Ltd. ! ! 1. Colour Names declared and set to values. ! integer(BYTE), parameter :: ALICEBLUE = #FFF8F0 integer(BYTE), parameter :: ANTIQUEWHITE = #D7EBFA integer(BYTE), parameter :: AQUA = #FFFF00 integer(BYTE), parameter :: AQUAMARINE = #D4FF7F integer(BYTE), parameter :: AZURE = #FFFFF0 integer(BYTE), parameter :: BEIGE = #DCF5F5[/bash]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Should have been DWORD, I misread the interface.
Apologies
JMN
Apologies
JMN

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page