Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

SETCOLORRGB

Robert
Beginner
383 Views

I am working through some examples in the book "Compaq Visual Fortran A Guide to Creating Windows Applications'  in which this code is given:

    ibackcolor=rgb(255,255,255)     ! white
    ifrontcolor=rgb(0,0,0)          ! black
     iret = setcolorrgb(ifrontcolor)
     iret = setbkcolorrgb(ibackcolor)
     iret = settextcolorrgb(ifrontcolor)

This is equivalent to the following given in the Intel documentation:

     iret = setcolorrgb(Z'00000000')
     iret = setbkcolorrgb(Z'00FFFFFF')
     iret = settextcolorrgb(Z'00000000')

My question is where in the Intel documentation do I find a description of the RGB function?   Where can I find documentation for other functions like RGB that are built into Intel Visual Fortran? 

Thank you.

0 Kudos
8 Replies
dboggs
New Contributor I
383 Views

Look up any of these functions in Intel Fortran help. It will tell you that the argument "color" is INTEGER(4), I.e. 24 bits, and it gives you the color mapping. In simple terms, the rightmost 8 bits represent the "amount" of the color Red, where 00000000 indicates no color at all and 11111111 represents full intensity Red. In practice no one uses the bit representation, but rather hex: Z'00  represents no color and Z'FF' represents full intensity. Two-digit groupings represent Red, Green, Blue from right to left. I usually abbreviate these as #00, #FF, etc. Thus, for example,

Intense red = #0000FF
Intense green = #00FF00
Intense blue = #BB0000
Medium intensity cyan = #808000 (equal parts green and blue)

0 Kudos
andrew_4619
Honored Contributor II
383 Views

Some background can be found in the sections of : 

https://software.intel.com/en-us/node/535311

 

 

0 Kudos
Robert
Beginner
383 Views

Thank you dboggs and app4619 for your reply. that expalins RGB function.

Now a follow up question: Fortran does not have a RGB function and I cannot find the RGB function mentioned in any of the Intel documentation, but it compiles so the function is an Intel add on somewhere.  How does one get a list of the undocumented functions in Intel Fortran? I want to know what other undocumented useful functions there are. 

Thank you, Bob

0 Kudos
Steven_L_Intel1
Employee
383 Views

You will find RGB, and some other functions that correspond to C macros in the Microsoft-supplied C header files, in ifwbase.f90 in the compiler Includes folder. These are used the same way they are in C and we don't document them separately as they are effectively part of the Windows API SDK.

0 Kudos
Robert
Beginner
383 Views

Thank you!

0 Kudos
dboggs
New Contributor I
383 Views

Robert, fyi: The "official" IVF functions that replaced the CVF RGB function described in Lawrence's Compaq Visual Fortran book are INTEGERtoRGB and RGBtoINTEGER. You can find these in the regular Intel Fortran documentation. The older RGB function still works, as noted by Steve, but using these is more cochere now and actually documented (although it took me a long time to find them).

For example, result = RGBtoINTEGER (red, green, blue) can be used to provide an integer argument to various other functions like SETCOLORRGB. But once you understand the hex representation of colors it is easier to simply call SETCOLORRGB (#bbggrr).

The reverse procedure, i.e. to inquire the current color in use, is not correspondingly simple.  You first need to use a function like GETCOLORRGB  () to get the INTEGER(4) color number. That can be used to, say, save the current color and stash it away for later restoration; but if you really want the relative red green and blue intensities of the current color you can either (a) write your own routine to convert between integers and hex values, or (b) call the function INTEGERtoRGB. I opt for the latter (this programming is driving me crazy but I'm not there yet).

0 Kudos
JVanB
Valued Contributor II
383 Views

The conversion functions are pretty simple: red = ibits(rgb,0,8), green = ibits(rgb,8,8), blue = ibits(rgb,16,8), rgb = iany(ishft([red,green,blue],[0,8,16])). There is an expanded zip file with all the code for Lawrence's book somewhere on Elsevier's web site, although I can't seem to find it just now. There is also a 64-bit clean version of his OpenGL example; I can find that: http://home.comcast.net/~kmbtib/Fortran_stuff/gridview.zip . Looks like it needs a little work to be 32-bit clean on ifort, though :)

0 Kudos
Robert
Beginner
383 Views

These comments are all very good and helpful. Thank you.

Regards,

Robert_M

0 Kudos
Reply