Re: Graphics...
- Posted by Pete Eberlein <xseal at HARBORSIDE.COM> May 11, 1999
- 435 views
> If I want to draw a rectangle with vertices > {0,0},{640,0},{640,480},{0,480}, would I need to translate that into > {0,0},{1280,0},{1280,480},{0,480} while using a 65k mode? 24-bit? > 32-bit? 15-bit? vesa20.e sets the global variable "bytes_per_pixel" to the correct value for each mode. You only have to multiply each x-value by bytes_per_pixel in your program to get the correct position. bits_per_pixel bytes_per_pixel 15 2 16 2 24 3 32 4 > How do I change colors in these bits per pixel modes: All these modes use colors based on the red+green+blue intensities that make up the color. The following code examples assume red, green & blue values are in the range from 0 to 255. > 15? Use the upper 5 bits of red and the upper 5 bits of green and the upper 5 bits of blue... first_byte = floor(blue / 8) + and_bits(green * 4, #E0) second_byte = floor(green / 64) + and_bits(red / 2, #7C) > 16? Use the upper 5 bits of red and the upper 6 bits of green and the upper 5 bits of blue... first_byte = floor(blue / 8) + and_bits(green * 8, #E0) second_byte = floor(green / 32) + and_bits(red, #F8) > 24? first_byte = blue second_byte = green third_byte = red > 32? first_byte = blue second_byte = green third_byte = red fourth_byte = 0 > How many bits are there to a byte? Isn't it 8? So in 16-bit modes it > would be 2 bytes per pixel, 24-bit would be 3, and 32 would be 4, > correct? So to correct the problem from above, I could set a > 'difference' variable to multiply the lengths of lines by...right? The vesa20.e global variable "bytes_per_line" will always have the exact length of the lines. Please use it instead of trying to calculate it yourself. Some graphics cards will use 1024 instead of 640 for the scanline length even though the rightmost 384 bytes are off the edge of the screen. > Thank you all, > Mike Hurley I should probably go put some of this stuff in the docs now... _______ ______ _______ ______ [ _ \[ _ ][ _ _ ][ _ ] [/| [_] |[/| [_\][/ | | \][/| [_\] | ___/ | _] | | | _] [\| [/] [\| [_/] [\| |/] [\| [_/] [_____] [______] [_____] [______] xseal at harborside.com ICQ:13466657 http://www.harborside.com/home/x/xseal/euphoria/