BOOL GUIAPI SetColorfulPalette (HDC hdc) { PDC pdc; GAL_Color pal[256]; pdc = dc_HDC2PDC (hdc); if (pdc->surface->format->BitsPerPixel == 8) { GAL_DitherColors (pal, 8); GAL_SetColors (pdc->surface, pal, 0, 256); } return FALSE; }
/* * Set the requested video mode, allocating a shadow buffer if necessary. */ GAL_Surface * GAL_SetVideoMode (int width, int height, int bpp, Uint32 flags) { GAL_VideoDevice *video, *this; GAL_Surface *prev_mode, *mode; int video_w; int video_h; int video_bpp; this = video = current_video; /* Default to the current video bpp */ if ( bpp == 0 ) { flags |= GAL_ANYFORMAT; bpp = GAL_VideoSurface->format->BitsPerPixel; } /* Get a good video mode, the closest one possible */ video_w = width; video_h = height; video_bpp = bpp; #if defined(_LITE_VERSION) && !defined(_STAND_ALONE) if ( mgIsServer && !GAL_GetVideoMode(&video_w, &video_h, &video_bpp, flags) ) { #else if ( !GAL_GetVideoMode(&video_w, &video_h, &video_bpp, flags) ) { #endif GAL_SetError ("NEWGAL: GAL_GetVideoMode error, not supported video mode.\n"); return(NULL); } /* Check the requested flags */ /* There's no palette in > 8 bits-per-pixel mode */ if ( video_bpp > 8 ) { flags &= ~GAL_HWPALETTE; } if ( video->physpal ) { free(video->physpal->colors); free(video->physpal); video->physpal = NULL; } /* Try to set the video mode, along with offset and clipping */ prev_mode = GAL_VideoSurface; GAL_VideoSurface = NULL; /* In case it's freed by driver */ mode = video->SetVideoMode(this, prev_mode,video_w,video_h,video_bpp,flags); GAL_VideoSurface = (mode != NULL) ? mode : prev_mode; if ((mode != NULL)) { /* Sanity check */ if ( (mode->w < width) || (mode->h < height) ) { GAL_SetError("NEWGAL: Video mode smaller than requested.\n"); return(NULL); } /* If we have a palettized surface, create a default palette */ if ( mode->format->palette ) { GAL_PixelFormat *vf = mode->format; GAL_DitherColors(vf->palette->colors, vf->BitsPerPixel); vf->DitheredPalette = TRUE; video->SetColors(this, 0, vf->palette->ncolors, vf->palette->colors); } /* Clear the surface to black */ video->offset_x = 0; video->offset_y = 0; mode->offset = 0; #if defined(_LITE_VERSION) && !defined(_STAND_ALONE) if (mgIsServer) { #endif GAL_SetClipRect(mode, NULL); GAL_ClearSurface(mode); #if defined(_LITE_VERSION) && !defined(_STAND_ALONE) } #endif #ifdef DEBUG_VIDEO fprintf(stderr, "NEWGAL: Requested mode: %dx%dx%d, obtained mode %dx%dx%d " "(offset %d)\n", width, height, bpp, mode->w, mode->h, mode->format->BitsPerPixel, mode->offset); #endif mode->w = width; mode->h = height; GAL_SetClipRect(mode, NULL); } /* If we failed setting a video mode, return NULL... (Uh Oh!) */ if ( mode == NULL ) { return(NULL); } video->info.vfmt = GAL_VideoSurface->format; /*FIXME*/ GAL_VideoSurface->video = current_video; return(GAL_PublicSurface); } /* * Convert a surface into the video pixel format. */ GAL_Surface * GAL_DisplayFormat (GAL_Surface *surface) { Uint32 flags; if (!GAL_PublicSurface) { GAL_SetError("NWEGAL: No video mode has been set.\n"); return(NULL); } /* Set the flags appropriate for copying to display surface */ flags = (GAL_PublicSurface->flags&GAL_HWSURFACE); #ifdef AUTORLE_DISPLAYFORMAT flags |= (surface->flags & (GAL_SRCCOLORKEY|GAL_SRCALPHA)); flags |= GAL_RLEACCELOK; #else flags |= surface->flags & (GAL_SRCCOLORKEY|GAL_SRCALPHA|GAL_RLEACCELOK); #endif return(GAL_ConvertSurface(surface, GAL_PublicSurface->format, flags)); }