256 colours in TPW 
Author Message
 256 colours in TPW

O.k., heres where I'm at:
I have a number of 24 bit bmp's, and I want to display them on a 256
colour display simultaneously.  This would imply using one pallette and a
whole lot of colour-depth reduction, so if anybody knows the whereabouts
of some procedures to assist with this I would be very appreciative....
even procedures to display a 256 colour (8bpp) bmp on a 256 colour screen
would be a really helpful start.

 Thanks in advance...
___________
Chil'Out

-----------



Wed, 18 Jun 1902 08:00:00 GMT  
 256 colours in TPW


Quote:
>O.k., heres where I'm at:
>I have a number of 24 bit bmp's, and I want to display them on a 256
>colour display simultaneously.  This would imply using one pallette and a
>whole lot of colour-depth reduction, so if anybody knows the whereabouts
>of some procedures to assist with this I would be very appreciative....
>even procedures to display a 256 colour (8bpp) bmp on a 256 colour screen
>would be a really helpful start.

> Thanks in advance...
>___________

You must carry your own palette as you already guessed and these are the
routines you will need.

{********************[ VIDEO UNIT ]*********************}
{                                                       }
{        Copyright (c) 1995,1996,1997                   }
{        Programming by Leon de Boer                    }
{                                                       }
{***************[ SUPPORTED PLATFORMS ]*****************}
{  16 and 32 Bit compilers                              }
{     DOS      - Turbo Pascal 7.0 +      (16 Bit)       }
{     DPMI     - Turbo Pascal 7.0 +      (16 Bit)       }
{     WINDOWS  - Turbo Pascal 7.0 +      (16 Bit)       }
{     OS2      - Virtual Pascal 0.3 +    (32 Bit)       }
{                C'T patch to BP         (16 Bit)       }
{                                                       }
{***************[ REVISION HISTORY ]********************}
{  Version  Date        Fix                             }
{  -------  ---------   ------------------------------  }
{  1.00     28 Nov 96   First multi platform release    }
{*******************************************************}

UNIT Video;

{<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
                                  INTERFACE
{<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}

{====Compiler conditional defines to sort platforms out =============}
{$IFDEF MSDOS}                                        { MSDOS PLATFORM }
   {$DEFINE DOS_OS}                                   { Define DOS_OS }
{$ENDIF}

{$IFDEF DPMI}                                         { DPMI PLATFORM }
   {$DEFINE DOS_OS}                                   { Define DOS_OS }
{$ENDIF}

{$IFDEF Windows}                                      { WINDOWS platform }
   {$DEFINE ADV_OS}                                   { Set as advanced }
{$ENDIF}

{$IFDEF OS2}                                          { OS2 platform }
   {$DEFINE ADV_OS}                                   { Set as advanced }
   {$DEFINE BPOS2}                                    { Define BPOS2 }
{$ENDIF}

{$IFDEF VirtualPascal}                                { VIRTUAL PASCAL }
   {$DEFINE CODE_32_BIT}                              { 32 BIT CODE }
   {$DEFINE ASM_32_BIT}                               { 32 BIT ASSSEMBLER }
   {$DEFINE API_32_BIT}                               { 32 BIT API CALLS }
   {$UNDEF BPOS2}                                     { Undefine BPOS2 }
{$ENDIF}
{--------------------------------------------------------------------}

{==== Compiler directives ===========================================}
{$N-} {  No 80x87 code generation }
{$O+} { This unit may be overlaid }
{$X+} { Extended syntax is ok }
{$F+} { Force far calls }
{$A+} { Word Align Data }
{$G+} { 286 Code optimization - if you're on an 8088 get a real computer }
{$R-} { Disable range checking }
{$S-} { Disable Stack Checking }
{$I-} { Disable IO Checking }
{$Q-} { Disable Overflow Checking }
{$V-} { Turn off strict VAR strings }
{$B-} { Allow short circuit boolean evaluations }
{---------------------------------------------------------------------}

{***************************************************************************}
{                            RECORD DEFINITIONS                             }
{***************************************************************************}

TYPE
{?????????????????????????????????????????????????????????????????????????|}
{                               RGB RECORD                                |}
{?????????????????????????????????????????????????????????????????????????|}
   RGBValue = RECORD Red, Green, Blue: Byte; END;     { RGB value record }

TYPE
{?????????????????????????????????????????????????????????????????????????|}
{                            RGB QUAD RECORD                              |}
{?????????????????????????????????????????????????????????????????????????|}
   RGBQuad = RECORD
     rgbReserved, Red, Green, Blue: Byte;             { RGB quad record }
   END;

TYPE
{?????????????????????????????????????????????????????????????????????????|}
{                             YCbCr RECORD                                |}
{?????????????????????????????????????????????????????????????????????????|}
   YCbCrValue = RECORD Y, Cb, Cr: Byte; END;          { YCbCr value record }

TYPE
{?????????????????????????????????????????????????????????????????????????|}
{                          TRGBPalette RECORD                             |}
{?????????????????????????????????????????????????????????????????????????|}
   TRGBPalette = RECORD
      PalSize: Integer;                               { RGB entries in pal }
      Data   : Array [0..0] Of RGBQuad;               { RGB palette data }
   END;
   PRGBPalette = ^TRGBPalette;

{***************************************************************************}
{                            INTERFACE ROUTINES                             }
{***************************************************************************}

{?????????????????????????????????????????????????????????????????????????|}
{                       COLOUR CONVERSION ROUTINES                        |}
{?????????????????????????????????????????????????????????????????????????|}

{=RGB_To_GreyScale===================================================
Converts an RGB value to a greyscale value. The RGB values are assumed
to be full scale corrected and the value returned is relative to the
maximum number of greyscale levels entered.
02Jul95 LdB
=====================================================================}
FUNCTION RGB_To_GreyScale (RGB: RGBValue; GreyLevels: Byte): Byte;

{=Convert_YCbCr_To_RGB===============================================
Converts a YCbCr format value such as used in JPEG to a RGB value.
02Jul95 LdB
=====================================================================}
PROCEDURE Convert_YCbCr_To_RGB (YCbCr: YCbCrValue; Var RGB: RGBValue);

{=Convert_RGB_To_YCbCr===============================================
Converts an RGB value to a YCbCr format value such as used in JPEG.
02Jul95 LdB
=====================================================================}
PROCEDURE Convert_RGB_To_YCbCr(RGB: RGBValue; Var YCbCr: YCbCrValue);

{?????????????????????????????????????????????????????????????????????????|}
{               RGB PALETTE AND COLOUR CONTROL ROUTINES                   |}
{?????????????????????????????????????????????????????????????????????????|}

{=CreateRGBPalette===================================================
Given a palette size this function allocates the memory required and
returns an empty palette structure with no entries to the caller. If
this call fails for lack of memory a nil pointer is returned.
04Jul96 LdB
=====================================================================}
FUNCTION CreateRGBPalette (PalSize: Integer): PRGBPalette;

{=MatchedRGBEntry====================================================
Returns the index of the first palette entry that matches the given
RGB values from the given palette, if no match is found it returns -1.
04Jul96 LdB
=====================================================================}
FUNCTION MatchedRGBEntry (RGB: RGBValue; RGBPal: PRGBPalette): Integer;

{=NearestRGBEntry====================================================
Returns the index of the nearest palette entry to the given RGB values
within the given palette. Usually called if MatchedRGBEntry fails.
04Jul96 LdB
=====================================================================}
FUNCTION NearestRGBEntry (RGB: RGBValue; RGBPal: PRGBPalette): Integer;

{=AddEntryToRGBPalette===============================================
If the palette structure is valid and an empty position is available
the given RGB value is inserted into the palette and the position
index returned. If the function fails -1 will be returned.
04Jul96 LdB
=====================================================================}
FUNCTION AddEntryToRGBPalette (RGB: RGBValue;
...

read more »



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. more than 256 colours

2. 320 X 200 with 256 colours

3. 640x480 256 colours?

4. TPW: loading 256 color bitmaps?

5. WANTED: A Simple unit for loading 256 color bitmaps using TPW 1.5

6. TPW: Changing text colours & FOSSIL

7. TPW Windows with different background colours

8. TPW/Delphi cursor replacement, more colours?

9. TPW/Delphi cursor replacement, more colours?

10. Looking for NOT VESA mouse unit to work in 640*480*256 or 800*600*256 mode

11. 640 X 480 X 256?

12. How do I print 256 color graphics?

 

 
Powered by phpBB® Forum Software