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

Integer Overflow with RGB

Intel_C_Intel
Employee
422 Views
I am trying to improve my code by adding checking for integer overflow.
I now find I get an integer overflow error with the RGB function.
I must be doing something silly.

David

integer*4	c
integer*2	i1,i2,i3

c=RGB(255,0,0) ! this is OK
i1=255
i2=0
i3=0
c=RGB(int1(i1),int1(i2),int1(i3)) ! this gives and error
0 Kudos
4 Replies
david_jones
Beginner
423 Views
A simple write statement shows that int1(255)=-1.

I don't see explicit documenation of RGB() called ffom Fortran.

Would it be easier to use RGBTOINTEGER which explicity has integer*4 arguments and check bitwise that the higher bits are not set?

0 Kudos
Intel_C_Intel
Employee
423 Views
Thanks, I had forgotten that int1 would be -127 to 128.
When I try RGBtoInteger it won't compile, I don't see why.
I get the message 'Unresolved external symbol _rgbtointeger

David

use dfwin
use dflib

integer*4	i1,i2,i3,c
		
c=RGB(255,0,0) ! this is OK
i1=255
i2=0
i3=0
c=RGBTOINTEGER(i1,i2,i3) ! this wouldn't compile
0 Kudos
david_jones
Beginner
423 Views
The message you quote looks like an error message from the linker. Your code compiled and linked OK for me in a fresh "standard graphics" project. Perhaps you are not accessing the right library?
0 Kudos
Intel_C_Intel
Employee
423 Views
I thought using -
'Use dflib' would use the correct library.
How can I check this. Normally it works OK.

David
0 Kudos
Reply