Search code examples
cturbo-cbgi

Image processing in C — processing a 256-color bitmap image


I am using Borland Turbo C and the Borland Graphics Interface.

I have two questions:

  1. I have to process a 256 color bitmap image. It is difficult to process using EGAVGA driver, so I decided to use SVGA driver. It works fine, but when I convert the image into gray scale, instead of showing only the image in gray scale, the whole window goes into gray scale mode. Is there any method to change the color palette for a specific area using outp(0x03c8, data) and outp(0x03c9, data) functions?

  2. The mouse functions works fine with EGAVGA mode but the cursor is not visible in the SVGA mode. Even the mouse is functional. How could I create a custom mouse cursor for SVGA mode in 256 color? I have the codes for creating custom mouse pointer in EGAVGA mode using 0x10 interrupt but it is not working with SVGA mode?


Solution

  • In paletized video modes, palette entries affect the whole screen. If you change any index, all pixels on screen with that index will change, whether if they belong to your image or not.

    If your image is going to share the screen with others, and you want that image the only one that changes into grayscale, you have to set aside some palette entries for exclusive use by your image, so changing them won't affect other graphic elements in your screen.

    On Windows, and X-Window if my memory serves well, the entire screen will have the colours of your palette when your window application has the focus. When not, it will revert to system palette and your windows and its contents will show "weird".