Integer Overflow with RGB

Integer Overflow with RGB

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
5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

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?

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

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?

I thought using -
'Use dflib' would use the correct library.
How can I check this. Normally it works OK.

David

Leave a Comment

Please sign in to add a comment. Not a member? Join today