Main Page | Alphabetical List | Compound List | File List | Compound Members | File Members

DIBDisplay.h File Reference

#include "basetype.h"
#include "DisplayModeInfo.h"

Go to the source code of this file.

Typedefs

typedef DIBDisplay DIBDisplay

Functions

geBoolean DIBDisplay_GetDisplayInfo (char *DescriptionString, unsigned int DescriptionStringMaxLength, DisplayModeInfo *Info)
void DIBDisplay_GetDisplayFormat (const DIBDisplay *D, int32 *Width, int32 *Height, int32 *BitsPerPixel, uint32 *Flags)
geBoolean DIBDisplay_GetPixelFormat (const DIBDisplay *D, int32 *bytes_per_pixel, int32 *R_shift, uint32 *R_mask, int32 *R_width, int32 *G_shift, uint32 *G_mask, int32 *G_width, int32 *B_shift, uint32 *B_mask, int32 *B_width)
geBoolean DIBDisplay_Blit (DIBDisplay *D)
geBoolean DIBDisplay_Wipe (DIBDisplay *D, uint32 color)
geBoolean DIBDisplay_Lock (DIBDisplay *D, uint8 **ptr, int32 *pitch)
geBoolean DIBDisplay_Unlock (DIBDisplay *D)
void DIBDisplay_Destroy (DIBDisplay **pDIBDisplay)


Typedef Documentation

typedef struct DIBDisplay DIBDisplay
 

Definition at line 35 of file DIBDisplay.h.


Function Documentation

geBoolean DIBDisplay_Blit DIBDisplay D  ) 
 

Definition at line 518 of file DIBDisplay.c.

References DIBDisplay_IsValid(), DIBDisplay::DIBInfo, GE_FALSE, GE_TRUE, geBoolean, DIBDisplay::hWnd, DIBDisplay_DIBInfo::lpDIBBuffer, NULL, DIBDisplay_DIBInfo::pbmi, DIBDisplay::Size_X, and DIBDisplay::Size_Y.

Referenced by Display_Blit().

00519 {
00520         HDC hdc;
00521         assert( DIBDisplay_IsValid(D) != GE_FALSE );
00522 
00523         hdc = GetDC(D->hWnd);
00524         if (hdc == NULL)
00525                 {
00526                         //geErrorLog_AddString("Unable to get HDC for blit");
00527                         return GE_FALSE;
00528                 }
00529 
00530         #if 0
00531                 if (desktop_bpp == 8)
00532                         {
00533                         //
00534                         // Select palette if desktop running in 8-bit mode
00535                         //
00536                         // If palette has changed, realize it
00537                         //
00538 
00539                                 //probably want to set up a halftone palette, and dither down into the 8 bbp desktop.
00540 
00541                                 SelectPalette(  hdc,  hPalette, 0);
00542 
00543                                 if (palette_change_request != GE_FALSE)
00544                                         {
00545                                                 palette_change_request = GE_FALSE;
00546                                                 RealizePalette(hdc);
00547                                         }
00548                         }
00549         #endif
00550 
00551 
00552         //
00553         // Disable Boolean operations during stretching
00554         //
00555 
00556         if (SetStretchBltMode(hdc, COLORONCOLOR)==0)
00557                 {
00558                         //geErrorLog_AddString("unable to set stretch blit mode");
00559                         return GE_FALSE;
00560                 }
00561 
00562         StretchDIBits(hdc,            // Destination DC
00563                                   0,              // Destination X
00564                                   0,              // Destination Y
00565                                   D->Size_X,     // Destination (client area) width
00566                                   D->Size_Y,    // Destination (client area) height 
00567                                   0,              // Source X
00568                                   0,              // Source Y
00569                                   D->Size_X, // Source (back buffer) width
00570                                   D->Size_Y, // Source (back buffer) height
00571                                   D->DIBInfo.lpDIBBuffer,    // Pointer to source (back buffer)
00572                                   D->DIBInfo.pbmi,           // Bitmap info for back buffer
00573                                   DIB_RGB_COLORS, // Bitmap contains index values
00574                                   SRCCOPY);       // Do normal copy with stretching
00575 
00576         ReleaseDC(D->hWnd, hdc);
00577         return GE_TRUE;
00578 }

void DIBDisplay_Destroy DIBDisplay **  pDIBDisplay  ) 
 

Definition at line 680 of file DIBDisplay.c.

References DIBDisplay_DestroyDIB(), DIBDisplay_IsValid(), DIBDisplay::DIBInfo, GE_FALSE, and NULL.

Referenced by DIBDisplay_Create(), and Display_Destroy().

00681 {
00682         DIBDisplay *D;
00683 
00684         assert( *pD != NULL );
00685         assert( pD  != NULL );
00686 
00687         D = *pD;
00688 
00689         assert( DIBDisplay_IsValid(D) != GE_FALSE );
00690         
00691         DIBDisplay_DestroyDIB(&(D->DIBInfo));
00692         free( D );
00693 
00694         *pD = NULL;
00695 }

void DIBDisplay_GetDisplayFormat const DIBDisplay D,
int32 Width,
int32 Height,
int32 BitsPerPixel,
uint32 Flags
 

Definition at line 84 of file DIBDisplay.c.

References DIBDisplay::BitsPerPixel, DIBDisplay::Flags, NULL, DIBDisplay::Size_X, and DIBDisplay::Size_Y.

Referenced by Display_GetDisplayFormat().

00089 {
00090         assert( D            != NULL );
00091         assert( Width        != NULL );
00092         assert( Height       != NULL );
00093         assert( BitsPerPixel != NULL );
00094         assert( Flags        != NULL );
00095 
00096         *Width        = D->Size_X;
00097         *Height       = D->Size_Y;
00098         *BitsPerPixel = D->BitsPerPixel;
00099         *Flags        = D->Flags;
00100 }       

geBoolean DIBDisplay_GetDisplayInfo char *  DescriptionString,
unsigned int  DescriptionStringMaxLength,
DisplayModeInfo Info
 

Definition at line 103 of file DIBDisplay.c.

References DIBDISPLAY_DESCRIPTION_STRING, DisplayModeInfo_AddEntry(), GE_FALSE, GE_TRUE, geBoolean, geErrorLog_AddString, and NULL.

Referenced by Display_GetDisplayInfo().

00106 {
00107         int BitsPerPixel;
00108 
00109         assert( Info != NULL );
00110         assert( DescriptionString != NULL );
00111         assert( DescriptionStringMaxLength > 0 );
00112         if (strlen(DIBDISPLAY_DESCRIPTION_STRING) >= DescriptionStringMaxLength)
00113                 {
00114                         geErrorLog_AddString(GE_ERR_BAD_PARAMETER,"DIBDisplay_GetDescriptionString: description string too short",NULL);
00115                         return GE_FALSE;
00116                 }
00117 
00118         strcpy(DescriptionString,DIBDISPLAY_DESCRIPTION_STRING);
00119 
00120 //      if ( CPUInfo_TestFor3DNow()==GE_TRUE)
00121 //              BitsPerPixel = 32;
00122 //      else
00123                 BitsPerPixel = 16;
00124 
00125         if (DisplayModeInfo_AddEntry(Info,-1,-1,BitsPerPixel,0)==GE_FALSE)
00126                 {
00127                         geErrorLog_AddString(GE_ERR_SUBSYSTEM_FAILURE,"DIBDisplay_GetDescriptionString: unable to add mode entry",NULL);
00128                         return GE_FALSE;
00129                 }
00130         return GE_TRUE;
00131 }

geBoolean DIBDisplay_GetPixelFormat const DIBDisplay D,
int32 bytes_per_pixel,
int32 R_shift,
uint32 R_mask,
int32 R_width,
int32 G_shift,
uint32 G_mask,
int32 G_width,
int32 B_shift,
uint32 B_mask,
int32 B_width
 

Definition at line 727 of file DIBDisplay.c.

References DIBDisplay::BitsPerPixel, DIBDisplay_DIBInfo::DIB_B_bitmask, DIBDisplay_DIBInfo::DIB_G_bitmask, DIBDisplay_DIBInfo::DIB_R_bitmask, DIBDisplay_IsValid(), DIBDisplay::DIBInfo, GE_FALSE, GE_TRUE, geBoolean, int32, NULL, and uint32.

Referenced by Display_GetPixelFormat().

00739 {
00740         int32 red_shift=0;
00741         uint32 red_mask;
00742         int32 red_width=0;
00743         int32 grn_shift=0;
00744         uint32 grn_mask;
00745         int32 grn_width=0;
00746         int32 blu_shift=0;
00747         uint32 blu_mask;
00748         int32 blu_width=0;
00749         int32 i;
00750 
00751         assert( DIBDisplay_IsValid(D) != GE_FALSE );
00752 
00753         //assert( pixel_pitch     != NULL );
00754         assert( bytes_per_pixel != NULL );
00755         assert( R_shift         != NULL );
00756         assert( R_mask          != NULL );
00757         assert( R_width         != NULL );
00758         assert( G_shift         != NULL );
00759         assert( G_mask          != NULL );
00760         assert( G_width         != NULL );
00761         assert( B_shift         != NULL );
00762         assert( B_mask          != NULL );
00763         assert( B_width         != NULL );
00764         
00765 
00766 
00767         //*pixel_pitch     = (D->BitsPerPixel / 8);
00768         *bytes_per_pixel = (D->BitsPerPixel / 8);
00769                 
00770         red_mask = D->DIBInfo.DIB_R_bitmask;
00771         grn_mask = D->DIBInfo.DIB_G_bitmask;
00772         blu_mask = D->DIBInfo.DIB_B_bitmask;
00773         
00774         //
00775         // Derive shift, width values from masks
00776         //
00777 
00778         for (i=31; i >= 0; i--)
00779                 {
00780                         if (red_mask & (1 << i))
00781                                 {
00782                                         red_shift = i;
00783                                 }
00784 
00785                         if (grn_mask & (1 << i))
00786                                 {
00787                                         grn_shift = i;
00788                                 }
00789 
00790                         if (blu_mask & (1 << i))
00791                                 {
00792                                         blu_shift = i;
00793                                 }
00794                 }
00795 
00796         for (i=0; i <= 31; i++)
00797                 {
00798                         if (red_mask & (1 << i))
00799                                 {
00800                                         red_width = i - red_shift + 1;
00801                                 }
00802 
00803                         if (grn_mask & (1 << i))
00804                                 {
00805                                         grn_width = i - grn_shift + 1;
00806                                 }
00807 
00808                         if (blu_mask & (1 << i))
00809                                 {
00810                                         blu_width = i - blu_shift + 1;
00811                                 }
00812                 }
00813         //
00814         // Pass all requested values back to the caller
00815         //
00816 
00817         *R_shift = red_shift;
00818         *G_shift = grn_shift;
00819         *B_shift = blu_shift;
00820 
00821         *R_mask  = red_mask;
00822         *G_mask  = grn_mask;
00823         *B_mask  = blu_mask;
00824 
00825         *R_width = red_width;
00826         *G_width = grn_width;
00827         *B_width = blu_width;
00828                 
00829         return GE_TRUE;
00830 }

geBoolean DIBDisplay_Lock DIBDisplay D,
uint8 **  ptr,
int32 pitch
 

Definition at line 700 of file DIBDisplay.c.

References DIBDisplay_IsValid(), DIBDisplay::DIBInfo, GE_FALSE, GE_TRUE, geBoolean, DIBDisplay::Locked, DIBDisplay_DIBInfo::lpDIBBuffer, NULL, and DIBDisplay::Pitch.

Referenced by Display_Lock().

00703 {
00704         assert( DIBDisplay_IsValid(D) != GE_FALSE );
00705         assert( ptr    != NULL );
00706         assert( pitch  != NULL );
00707         assert( D->Locked == GE_FALSE );
00708 
00709         *ptr    = D->DIBInfo.lpDIBBuffer;
00710         *pitch  = D->Pitch;
00711 
00712         D->Locked = GE_TRUE;
00713         return GE_TRUE;
00714 }

geBoolean DIBDisplay_Unlock DIBDisplay D  ) 
 

Definition at line 717 of file DIBDisplay.c.

References DIBDisplay_IsValid(), GE_FALSE, GE_TRUE, geBoolean, and DIBDisplay::Locked.

Referenced by Display_Unlock().

00718 {
00719         assert( DIBDisplay_IsValid(D) != GE_FALSE );
00720         assert( D->Locked == GE_TRUE );
00721         D->Locked = GE_FALSE;
00722         return GE_TRUE;
00723 }

geBoolean DIBDisplay_Wipe DIBDisplay D,
uint32  color
 

Definition at line 582 of file DIBDisplay.c.

References DIBDisplay_IsValid(), DIBDisplay::DIBInfo, GE_FALSE, GE_TRUE, geBoolean, int16, DIBDisplay::Locked, DIBDisplay_DIBInfo::lpDIBBuffer, DIBDisplay::Pitch, DIBDisplay::Size_X, and DIBDisplay::Size_Y.

Referenced by Display_Wipe().

00584 {
00585         assert( DIBDisplay_IsValid(D) != GE_FALSE );
00586         if (!D->Locked)
00587                 {
00588                         //gegeErrorLog_AddString(Add(,"Display must be locked to clear",NULL);
00589                         return GE_FALSE;
00590                 }
00591 
00592         if (color==0)
00593                 memset(D->DIBInfo.lpDIBBuffer, color, D->Size_Y * D->Pitch);
00594         else
00595                 {
00596                         int i;
00597                         int16 *Ptr = (int16 *)D->DIBInfo.lpDIBBuffer;
00598                         int16 C    = (int16)color;
00599                         for (i=(D->Size_X * D->Size_Y); i>0; i--)
00600                                 {
00601                                         *(Ptr++) = C;
00602                                 }
00603                 }
00604                                                 
00605         return GE_TRUE;
00606 }


Generated on Tue Sep 30 12:37:24 2003 for GTestAndEngine by doxygen 1.3.2