void main() { int CurrentColor, i; union REGS regset; /* Draw Wu-antialiased lines in all directions */ SetMode(); SetPalette(WuColors); for (i=5; i<ScreenWidthInPixels; i += 10) { DrawWuLine(ScreenWidthInPixels/2-ScreenWidthInPixels/10+i/5, ScreenHeightInPixels/5, i, ScreenHeightInPixels-1, WuColors[WU_BLUE].BaseColor, WuColors[WU_BLUE].NumLevels, WuColors[WU_BLUE].IntensityBits); } for (i=0; i<ScreenHeightInPixels; i += 10) { DrawWuLine(ScreenWidthInPixels/2-ScreenWidthInPixels/10, i/5, 0, i, WuColors[WU_BLUE].BaseColor, WuColors[WU_BLUE].NumLevels, WuColors[WU_BLUE].IntensityBits); } for (i=0; i<ScreenHeightInPixels; i += 10) { DrawWuLine(ScreenWidthInPixels/2+ScreenWidthInPixels/10, i/5, ScreenWidthInPixels-1, i, WuColors[WU_BLUE].BaseColor, WuColors[WU_BLUE].NumLevels, WuColors[WU_BLUE].IntensityBits); } for (i=0; i<ScreenWidthInPixels; i += 10) { DrawWuLine(ScreenWidthInPixels/2-ScreenWidthInPixels/10+i/5, ScreenHeightInPixels, i, 0, WuColors[WU_WHITE].BaseColor, WuColors[WU_WHITE].NumLevels, WuColors[WU_WHITE].IntensityBits); } getch(); /* wait for a key press */ /* Now clear the screen and draw non-antialiased lines */ SetMode(); SetPalette(WuColors); for (i=0; i<ScreenWidthInPixels; i += 10) { DrawLine(ScreenWidthInPixels/2-ScreenWidthInPixels/10+i/5, ScreenHeightInPixels/5, i, ScreenHeightInPixels-1, WuColors[WU_BLUE].BaseColor); } for (i=0; i<ScreenHeightInPixels; i += 10) { DrawLine(ScreenWidthInPixels/2-ScreenWidthInPixels/10, i/5, 0, i, WuColors[WU_BLUE].BaseColor); } for (i=0; i<ScreenHeightInPixels; i += 10) { DrawLine(ScreenWidthInPixels/2+ScreenWidthInPixels/10, i/5, ScreenWidthInPixels-1, i, WuColors[WU_BLUE].BaseColor); } for (i=0; i<ScreenWidthInPixels; i += 10) { DrawLine(ScreenWidthInPixels/2-ScreenWidthInPixels/10+i/5, ScreenHeightInPixels, i, 0, WuColors[WU_WHITE].BaseColor); } getch(); /* wait for a key press */ regset.x.ax = 0x0003; /* AL = 3 selects 80x25 text mode */ int86(0x10, ®set, ®set); /* return to text mode */ }
static INT GraphOpen (GRAPH_WINDOW *gw, const char *title, short h, short v, short dh, short dv) { WindowPtr MacWin; GrafPtr myPort; PaletteHandle myPalette; Str255 pstr; MacWin = MAC_WIN(gw); /* read in resources */ if (GetNewCWindow(GRAPH_RSRC_ID,(Ptr) MacWin,(WindowPtr) -1)==NULL) return (1); myPalette = GetNewPalette(PALETTE_RSRC_ID); SetPalette(MacWin,myPalette,FALSE); /* move and size window */ myPort = (GrafPtr) MacWin; SetPort(myPort); MoveWindow(MacWin,h,v,false); SizeWindow(MacWin,dh,dv,false); CopyCStringToPascal(title,pstr); SetWTitle(MacWin,pstr); ShowWindow(MacWin); SelectWindow(MacWin); DrawGrowIcon(MacWin); return (0); }
/*--------------------------------------------------------------------------*/ Dragon4Screen::Dragon4Screen(PegRect &Rect) : PegScreen(Rect) { mdNumColors = 16; mwHRes = Rect.Width(); mwVRes = Rect.Height(); mpScanPointers = new UCHAR *[Rect.Height()]; UCHAR *CurrentPtr = GetVideoAddress(); for (SIGNED iLoop = 0; iLoop < Rect.Height(); iLoop++) { mpScanPointers[iLoop] = CurrentPtr; CurrentPtr += mwHRes >> 1; } mLastPointerPos.x = Rect.Width() / 2; mLastPointerPos.y = Rect.Height() / 2; mbPointerHidden = FALSE; mwDrawNesting = 0; ConfigureController(); // set up controller registers SetPalette(0, 16, GrayPalette); }
//////////////////////////////////////////////////////////// // Main Function for displaying title screen // return : seednumber (used for random function) //////////////////////////////////////////////////////////// int TitleDisplay() { int x, y; int seed_return; SetPalette(tetrisTitlePalette); // Moving down Title for(y = 1; y < 90; y+=2) { DrawTitleDown(y); } // Blink press start image while(1) { if(seed_return < 130) DrawPressStart(); else if(seed_return < 200) ClearPressStart(); else seed_return = 0; seed_return++; if (! ((*KEYS_TITLE) & KEY_START)) break; } return seed_return; }
/** * Prompts the user for a palette file and opens that file. * * @return Flag that indicates failure (0) or success (1) **/ int LoadPaletteFile() { const char filter[]="All usable files (*.pal)\0*.pal\0All Files (*.*)\0*.*\0\0"; bool success = false; char nameo[2048]; // Display open file dialog OPENFILENAME ofn; memset(&ofn, 0, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hInstance = fceu_hInstance; ofn.lpstrTitle = FCEU_NAME" Open Palette File..."; ofn.lpstrFilter = filter; nameo[0] = 0; ofn.lpstrFile = nameo; ofn.nMaxFile = 256; ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; ofn.lpstrInitialDir = 0; if(GetOpenFileName(&ofn)) { success = SetPalette(nameo); } return success; }
// DrawTimeFrequencyGrid drawing grids. We leave the renderTarget context up to the caller. // Note the top left is origen void DrawTimeFrequencyGrid::Draw( ID2D1RenderTarget *apRenderTarget, D2D1_RECT_F rc, ParameterPack *ptheParameterPack, double time0, double time1 ) { pRenderTarget = apRenderTarget; ptheFrequencyScale = ptheParameterPack->GetFrequencyScale(); // CString palette = ptheParameterPack->GetPalette(); SetPalette(); HRESULT hr = S_OK; hr = pRenderTarget->CreateSolidColorBrush(vGridColor, &pVGridBrush); if ( FAILED(hr)) return; hr = pRenderTarget->CreateSolidColorBrush(labelColor, &pLabelBrush); if ( FAILED(hr)) return; hr = pRenderTarget->CreateSolidColorBrush(textBackgroundColor, &pTextBackgroundBrush); if ( FAILED(hr)) return; // pRenderTarget->BeginDraw(); // Get display times and other information double highFrequencyLimit = ptheParameterPack->GetFilterHigh(); double lowFrequencyLimit = ptheParameterPack->GetFilterLow(); rectangleSize = pRenderTarget->GetSize(); dataBottom = rc.bottom; dataTop = rc.top; DrawVerticalGrid( 10, time0, time1 ); MAPDOUBLE *pLabelMap = ptheParameterPack->GetLabelMap(); if ( ptheParameterPack->GetScaleChoice() != SCALE_NONE ) DrawHorizontalGrid( pLabelMap, 10, lowFrequencyLimit, highFrequencyLimit ); DiscardGraphicsResources(); }
/*--------------------------------------------------------------------------*/ SED1376Screen8::SED1376Screen8(PegRect &Rect) : PegScreen(Rect) { mdNumColors = 256; mwHRes = Rect.Width(); mwVRes = Rect.Height(); mpScanPointers = new UCHAR PEGFAR *[Rect.Height()]; UCHAR PEGFAR *CurrentPtr = GetVideoAddress(); for (SIGNED iLoop = 0; iLoop < Rect.Height(); iLoop++) { mpScanPointers[iLoop] = CurrentPtr; CurrentPtr += mwHRes; } mLastPointerPos.x = Rect.Width() / 2; mLastPointerPos.y = Rect.Height() / 2; mbPointerHidden = FALSE; mwDrawNesting = 0; ConfigureController(); // set up controller registers SetPalette(0, 232, DefPalette256); #ifdef PEGWIN32 mwWinRectXOffset = 0; mwWinRectYOffset = 0; #endif }
void CDib::Copy(const CDib& dib, UINT nBitCount) { if( &dib != this) { Empty(); if( !dib.IsNull() ) { int height = dib.GetHeight(); int width = dib.GetWidth(); Create(width, height, nBitCount); if( nBitCount <= 8) { CPalette palette; dib.CreatePaletteFromImage(palette); SetPalette( palette ); //MakePalette(); } for(int i=0; i<width; i++) { for(int j=0; j<height; j++) { SetPixel(i,j, dib.GetPixel(i, j) ); } } } } }
void Application::InitVideo() { Settings* set = Settings::Instance(); UPoint resolution = set->GetResolution(); int videoFlags = SDL_HWPALETTE | SDL_RESIZABLE; if (set->GetDoubleBuffered()) videoFlags |= SDL_HWSURFACE | SDL_DOUBLEBUF; if (set->GetFullScreen()) videoFlags |= SDL_FULLSCREEN; SDL_Surface *surface = SDL_SetVideoMode(resolution.x, resolution.y, 8, videoFlags); if(!surface) { LOG(LV_ERROR, "Application", "Couldn't set video mode: %s", SDL_GetError()); Die(); } else surface->flags |= SDL_PREALLOC; *m_screen = surface; // reset the palette if we've got one if (m_currentPalette) SetPalette(); SDL_ShowCursor(SDL_DISABLE); m_rootWidget->setSize(resolution); m_rootWidget->setPosition(UPoint(0, 0)); }
void RageDisplay_D3D::SetTexture( int iTextureUnitIndex, RageTexture* pTexture ) { g_iCurrentTextureIndex = iTextureUnitIndex; // g_DeviceCaps.MaxSimultaneousTextures = 1; if( g_iCurrentTextureIndex >= (int) g_DeviceCaps.MaxSimultaneousTextures ) // not supported return; if( pTexture == NULL ) { g_pd3dDevice->SetTexture( g_iCurrentTextureIndex, NULL ); //g_pd3dDevice->SetTextureStageState( g_iCurrentTextureIndex, D3DTSS_COLOROP, D3DTOP_DISABLE ); } else { unsigned uTexHandle = pTexture->GetTexHandle(); IDirect3DTexture9* pTex = (IDirect3DTexture9*)uTexHandle; g_pd3dDevice->SetTexture( g_iCurrentTextureIndex, pTex ); //g_pd3dDevice->SetTextureStageState( g_iCurrentTextureIndex, D3DTSS_COLOROP, D3DTOP_MODULATE ); // Set palette (if any) SetPalette(uTexHandle); } }
SED1353Screen::SED1353Screen(HWND hWnd, PegRect &Rect) : PegScreen(Rect) #else SED1353Screen::SED1353Screen(PegRect &Rect) : PegScreen(Rect) #endif { mdNumColors = 16; mwHRes = Rect.Width(); mwVRes = Rect.Height(); mpScanPointers = new UCHAR PEGFAR *[Rect.Height()]; UCHAR PEGFAR *CurrentPtr = GetVideoAddress(); for (SIGNED iLoop = 0; iLoop < Rect.Height(); iLoop++) { mpScanPointers[iLoop] = CurrentPtr; CurrentPtr += mwHRes >> 1; } mLastPointerPos.x = Rect.Width() / 2; mLastPointerPos.y = Rect.Height() / 2; mbPointerHidden = FALSE; mwDrawNesting = 0; ConfigureController(); // set up controller registers #ifdef PEGWIN32 // Some setup stuff for the BitBlitting function: mHWnd = hWnd; mhPalette = NULL; RECT lSize; ::GetClientRect(mHWnd, &lSize); mwWinRectXOffset = (lSize.right - mwHRes) / 2; mwWinRectYOffset = (lSize.bottom -mwVRes) / 2; #endif SetPalette(0, 16, DefPalette16); } /*--------------------------------------------------------------------------*/ // *** This function must be filled in by the developer *** /*--------------------------------------------------------------------------*/ UCHAR PEGFAR *SED1353Screen::GetVideoAddress(void) { #ifdef PEGWIN32 DWORD dSize = mwHRes / 2 * mwVRes; UCHAR *pMem = new UCHAR[dSize]; return pMem; #else return (UCHAR *) VID_MEM_BASE; #endif }
/*--------------------------------------------------------------------------*/ GenericSvgaScreen::GenericSvgaScreen(PegRect &Rect) : PegScreen(Rect) { mdNumColors = 256; mwHRes = Rect.Width(); mwVRes = Rect.Height(); WORD wPitch = mwHRes; ConfigureController(); // set up controller registers SetPalette(0, 232, DefPalette256); mpScanPointers = new UCHAR *[Rect.Height()]; UCHAR *CurrentPtr = GetVideoAddress(); for (SIGNED iLoop = 0; iLoop < Rect.Height(); iLoop++) { mpScanPointers[iLoop] = CurrentPtr; CurrentPtr += wPitch; } mLastPointerPos.x = Rect.Width() / 2; mLastPointerPos.y = Rect.Height() / 2; mbPointerHidden = FALSE; mwDrawNesting = 0; }
/*--------------------------------------------------------------------------*/ SED1355Screen::SED1355Screen(PegRect &Rect, BOOL bDual) : PegScreen(Rect) { mdNumColors = 256; mbDualMode = bDual; mwHRes = Rect.Width(); mwVRes = Rect.Height(); mpScanPointers = new UCHAR PEGFAR *[Rect.Height()]; UCHAR PEGFAR *CurrentPtr = GetVideoAddress(); for (SIGNED iLoop = 0; iLoop < Rect.Height(); iLoop++) { mpScanPointers[iLoop] = CurrentPtr; CurrentPtr += mwHRes; } mLastPointerPos.x = Rect.Width() / 2; mLastPointerPos.y = Rect.Height() / 2; mbPointerHidden = FALSE; mwDrawNesting = 0; ConfigureController(); // set up controller registers SetPalette(0, 232, DefPalette256); }
void ChangeResolution() { if (bFullScreen) { if (vmVideoMode==vmGraph512) sfScreen = SDL_SetVideoMode(512, 384, 8, SDL_SWSURFACE | SDL_FULLSCREEN | SDL_HWPALETTE); else if (vmVideoMode==vmGraph800) sfScreen = SDL_SetVideoMode(800, 600, 8, SDL_SWSURFACE | SDL_FULLSCREEN | SDL_HWPALETTE); else sfScreen = SDL_SetVideoMode(640, 480, 8, SDL_SWSURFACE | SDL_FULLSCREEN | SDL_HWPALETTE); SDL_ShowCursor(SDL_DISABLE); } else { if (vmVideoMode==vmGraph512) sfScreen = SDL_SetVideoMode(512, 384, 8, SDL_SWSURFACE | SDL_HWPALETTE); else if (vmVideoMode==vmGraph800) sfScreen = SDL_SetVideoMode(800, 600, 8, SDL_SWSURFACE | SDL_HWPALETTE); else sfScreen = SDL_SetVideoMode(640, 480, 8, SDL_SWSURFACE | SDL_HWPALETTE); SDL_ShowCursor(SDL_ENABLE); } //printf("w=%d, h=%d, pitch=%d\n",SDL_GetVideoSurface()->w,SDL_GetVideoSurface()->h,SDL_GetVideoSurface()->pitch); SetPalette(); DrawScreen(); }
void CDibMgr::RemoveDib(CDib* pDib) { // Sanity checks... ASSERT(IsValid()); ASSERT(pDib && pDib->IsValid()); if (!pDib) return; // Remove a palette if necessary... CDibPal* pPal = pDib->GetPalette(); if (pPal && pDib->IsPaletteOwner()) { RemovePal(pPal); SetPalette(NULL, FALSE); } // Remove the dib from our list... POSITION pos = pDib->GetPos(); ASSERT(pos); if (pos) m_collDibs.RemoveAt(pos); // Destroy the dib... delete pDib; }
Surface::Surface(const void* pixels, u32 width, u32 height, u32 bytes_per_pixel /* 1, 2, 3, 4 */, bool amask) : surface(NULL) { SurfaceFormat fm = GetRGBAMask(8 * bytes_per_pixel); if(8 == fm.depth) { #if SDL_VERSION_ATLEAST(2, 0, 0) surface = SDL_CreateRGBSurface(0, width, height, fm.depth, fm.rmask, fm.gmask, fm.bmask, (amask ? fm.amask : 0)); #else surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, fm.depth, fm.rmask, fm.gmask, fm.bmask, (amask ? fm.amask : 0)); #endif } else { surface = SDL_CreateRGBSurfaceFrom(const_cast<void *>(pixels), width, height, fm.depth, width * bytes_per_pixel, fm.rmask, fm.gmask, fm.bmask, amask ? fm.amask : 0); #if SDL_VERSION_ATLEAST(2, 0, 0) SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_NONE); #endif } if(!surface) Error::Except(__FUNCTION__, SDL_GetError()); if(8 == fm.depth) { SetPalette(); Lock(); std::memcpy(surface->pixels, pixels, width * height); Unlock(); } }
Sprite2D *WMPAreaEntry::GetMapIcon(AnimationFactory *bam) { if (!bam) { return NULL; } if (!MapIcon) { int color = -1; int frame = 0; switch (AreaStatus&(WMP_ENTRY_ACCESSIBLE|WMP_ENTRY_VISITED)) { case WMP_ENTRY_ACCESSIBLE: frame = 0; break; case WMP_ENTRY_VISITED: frame = 4; break; case WMP_ENTRY_ACCESSIBLE|WMP_ENTRY_VISITED: frame = 1; break; case 0: frame = 2; break; } if (bam->GetCycleSize(IconSeq)<5) { color = gradients[frame]; frame = 0; } MapIcon = bam->GetFrame((ieWord) frame, (ieByte) IconSeq); if (!MapIcon) { print("WMPAreaEntry::GetMapIcon failed for frame %d, seq %d\n", frame, IconSeq); return NULL; } if (color>=0) { // Note: should a game use the same map icon for two different // map locations, we have to duplicate the MapIcon sprite here. // This doesn't occur in BG1, so no need to do that for the moment. SetPalette(color, MapIcon); } } MapIcon->acquire(); return MapIcon; }
Screen::Screen(short screenwidth, short screenheight, short fontwidth, short fontheight, const COLORREF* palette, const HANDLE* hout) : fontwidth(fontwidth), fontheight(fontheight), pHout(hout) { xchars = screenwidth / fontwidth; ychars = screenheight / fontheight; width = xchars; height = ychars*2; consolescreenbuffer.cbSize = sizeof(CONSOLE_SCREEN_BUFFER_INFOEX); //how many chars there are consolescreenbuffer.dwSize = { xchars, ychars }; consolescreenbuffer.dwCursorPosition = { 0, 0 }; consolescreenbuffer.wAttributes = COL_BACKGROUND; //console coords consolescreenbuffer.srWindow = { 0, 0, xchars, ychars}; consolescreenbuffer.dwMaximumWindowSize = { 10000, 10000 }; consolescreenbuffer.wPopupAttributes = 0; consolescreenbuffer.bFullscreenSupported = FALSE; SetPalette(palette); pScreenBuffer = new CHAR_INFO[width * height]; CHAR_INFO chri = { ' ', 0 }; for (int i = 0; i < width*height; i++) pScreenBuffer[i] = chri; }
bool CxImageSKA::Decode(CxFile *hFile) { if (hFile==NULL) return false; // read the header SKAHEADER ska_header; hFile->Read(&ska_header,sizeof(SKAHEADER),1); ska_header.Width = ntohs(ska_header.Width); ska_header.Height = ntohs(ska_header.Height); ska_header.dwUnknown = ntohl(ska_header.dwUnknown); // check header if (ska_header.dwUnknown != 0x01000000 || ska_header.Width > 0x7FFF || ska_header.Height > 0x7FFF || ska_header.BppExp != 3) return false; if (info.nEscape == -1){ head.biWidth = ska_header.Width ; head.biHeight= ska_header.Height; info.dwType = CXIMAGE_FORMAT_SKA; return true; } int bpp = 1<<ska_header.BppExp; Create(ska_header.Width,ska_header.Height,bpp,CXIMAGE_FORMAT_SKA); if (!IsValid()) return false; // read the palette int nColors = 1<<bpp; rgb_color* ppal = (rgb_color*)malloc(nColors*sizeof(rgb_color)); if (!ppal) return false; hFile->Read(ppal,nColors*sizeof(rgb_color),1); SetPalette(ppal,nColors); free(ppal); //read the image hFile->Read(GetBits(),ska_header.Width*ska_header.Height,1); //reorder rows if (GetEffWidth() != ska_header.Width){ BYTE *src,*dst; src = GetBits() + ska_header.Width*(ska_header.Height-1); dst = GetBits(ska_header.Height-1); for(int y=0;y<ska_header.Height;y++){ memcpy(dst,src,ska_header.Width); src -= ska_header.Width; dst -= GetEffWidth(); } } Flip(); return true; }
Font::~Font(void) { Video *video = core->GetVideoDriver(); video->FreeSprite( sprBuffer ); SetPalette(NULL); free(resRefs); }
void SetRange(int start, int range) { int i; for (i = 0; i < 8; i++) gPalette[start + i] = cColorRanges[range].range[i]; SetPalette(gPalette); }
void MythUIHelper::ThemeWidget(QWidget *widget) { if (d->m_themeloaded) { widget->setPalette(d->m_palette); return; } SetPalette(widget); d->m_palette = widget->palette(); QPixmap *bgpixmap = NULL; if (!d->m_qtThemeSettings->GetSetting("BackgroundPixmap").isEmpty()) { QString pmapname = d->m_themepathname + d->m_qtThemeSettings->GetSetting("BackgroundPixmap"); bgpixmap = LoadScalePixmap(pmapname); if (bgpixmap) { d->m_palette.setBrush(widget->backgroundRole(), QBrush(*bgpixmap)); widget->setPalette(d->m_palette); } } else if (!d->m_qtThemeSettings ->GetSetting("TiledBackgroundPixmap").isEmpty()) { QString pmapname = d->m_themepathname + d->m_qtThemeSettings->GetSetting("TiledBackgroundPixmap"); int width, height; float wmult, hmult; GetScreenSettings(width, wmult, height, hmult); bgpixmap = LoadScalePixmap(pmapname); if (bgpixmap) { QPixmap background(width, height); QPainter tmp(&background); tmp.drawTiledPixmap(0, 0, width, height, *bgpixmap); tmp.end(); d->m_palette.setBrush(widget->backgroundRole(), QBrush(background)); widget->setPalette(d->m_palette); } } d->m_themeloaded = true; delete bgpixmap; }
void Start_STATE_MENU() { SetPalette(BG_PALETTE, 0, 8, bgPALMenu, bank_STATE_MENU); InitScrollTilesColor(0, 102, splashtiles, 2); InitScroll(splashmapWidth, splashmapHeight, splashmap, 0, 0, 2); SHOW_BKG; level = 0; PlayMusic(start_mod_Data, 2, 1); }
void restorePalette(Lcd *x, RGBColor *oldColor, PaletteHandle *oldPalette) { if (hasColorQD) { if (numPaletteColors>2){ SetPalette(&x->lcd_box.b_patcher->p_wind->w_gp,*oldPalette,FALSE); RGBForeColor(oldColor); } } SetPenState(&x->lcd_penState); }
static int CreateApplicationWindow (AWindowRecord *wr, char *fname, short h, short v, short dh, short dv) { Rect r; GrafPtr myPort; PaletteHandle myPalette; char name[80]; /* init AWindowRecord */ wr->theWindow = (WindowPtr) wr; /* read in resources */ if (GetNewCWindow(appWinId,(Ptr)wr,(WindowPtr) -1)==NULL) { return(1); } myPalette = GetNewPalette(defaultPaletteId); SetPalette(wr->theWindow,myPalette,false); /* move and size window */ myPort = (GrafPtr) wr->theWindow; SetPort(myPort); MoveWindow(wr->theWindow,h,v,false); SizeWindow(wr->theWindow,dh+15,dv+15,false); strcpy(name,fname); SetWTitle(wr->theWindow,c2pstr(name)); ShowWindow(wr->theWindow); SelectWindow(wr->theWindow); DrawGrowIcon(wr->theWindow); r = myPort->portRect; TextFont(kFontIDMonaco); /* get the scroll bars */ wr->vScrollBar = GetNewControl(vScrollBarId,wr->theWindow); wr->hScrollBar = GetNewControl(hScrollBarId,wr->theWindow); /* set correct size of the scroll bars */ MoveControl(wr->vScrollBar,r.right-15,-1); SizeControl(wr->vScrollBar,16,r.bottom-13); SetControlMinimum(wr->vScrollBar,0); SetControlMaximum(wr->vScrollBar,0); SetControlValue(wr->vScrollBar,0); ShowControl(wr->vScrollBar); MoveControl(wr->hScrollBar,-1,r.bottom-15); SizeControl(wr->hScrollBar,r.right-13,16); SetControlMinimum(wr->hScrollBar,0); SetControlMaximum(wr->hScrollBar,0); SetControlValue(wr->hScrollBar,0); ShowControl(wr->hScrollBar); DrawControls(wr->theWindow); SetRect(&(wr->usableRect),0,0,dh,dv); return(0); }
static int PaletteWinProc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam) { HDC hdc; int x, y; static GAL_Color colorPal[256], myPal[256]; switch (message) { case MSG_CREATE: GetPalette(HDC_SCREEN, 0, 256, colorPal); #ifdef _DEBUG int i; for (i = 0; i < 256; i++) { printf ("i = %d\n, red = %d\n, green = %d\n, blue = %d\n\n", i, colorPal[i].r, colorPal[i].g, colorPal[i].b); } #endif break; case MSG_PAINT: { if (g_bShowBall) SendMessage (hWnd, MSG_LBUTTONDOWN, 0, 0); } break; case MSG_LBUTTONDOWN: g_bShowBall = TRUE; hdc = GetClientDC(hWnd); InitMyPalette(myPal); SetPalette(hdc, 0, 256, myPal); SetBrushColor(hdc, COLOR_red); FillCircle(hdc, 10, 10, 8); for (y = 0; y < 240; y += 20) { for (x = 0; x < 320; x += 20) { BitBlt(hdc, 0, 0, 20, 20, hdc, x, y, 0); SetColorfulPalette(hdc); } } ReleaseDC(hdc); break; case MSG_RBUTTONDOWN: SetColorfulPalette(HDC_SCREEN); SetBrushColor(HDC_SCREEN, PIXEL_yellow); FillCircle(HDC_SCREEN, 50, 50, 15); break; case MSG_CLOSE: DestroyAllControls (hWnd); DestroyMainWindow (hWnd); PostQuitMessage (hWnd); return 0; } return DefaultMainWinProc(hWnd, message, wParam, lParam); }
void Surface::Set(u32 sw, u32 sh, const SurfaceFormat & fm) { FreeSurface(*this); #if SDL_VERSION_ATLEAST(2, 0, 0) surface = SDL_CreateRGBSurface(0, sw, sh, fm.depth, fm.rmask, fm.gmask, fm.bmask, fm.amask); #else surface = SDL_CreateRGBSurface(SDL_SWSURFACE, sw, sh, fm.depth, fm.rmask, fm.gmask, fm.bmask, fm.amask); #endif if(!surface) Error::Except(__FUNCTION__, SDL_GetError()); if(8 == depth()) { SetPalette(); Fill(fm.ckey); SetColorKey(fm.ckey); } else if(amask()) { #if SDL_VERSION_ATLEAST(2, 0, 0) Fill(RGBA(0, 0, 0, 0)); // no color key only amask #else Fill(RGBA(fm.ckey.r(), fm.ckey.g(), fm.ckey.b(), 0)); SetColorKey(fm.ckey); #endif } else if(fm.ckey.pack()) { Fill(fm.ckey); SetColorKey(fm.ckey); } if(amask()) { #if SDL_VERSION_ATLEAST(2, 0, 0) SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_BLEND); #else SDL_SetAlpha(surface, SDL_SRCALPHA, 255); #endif } else { #if SDL_VERSION_ATLEAST(2, 0, 0) SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_NONE); #else SDL_SetAlpha(surface, 0, 0); #endif } }
void CDib::CreateCompatibleDIB( CDC& dc, int width, int height ) { Empty(); CreateDib( CSize (width,height), dc.GetDeviceCaps( BITSPIXEL ) ); if( IsIndexed() ) { if( dc.GetCurrentPalette() ) SetPalette( *(dc.GetCurrentPalette()) ); else CreateDefaultPalette(); } }
static void PaletteAdjust(void) { int i; double f; f = 1.0 + gOptions.brightness / 33.3; for (i = 0; i < 255; i++) { gPalette[i].red = FitColor(f * origPalette[i].red); gPalette[i].green = FitColor(f * origPalette[i].green); gPalette[i].blue = FitColor(f * origPalette[i].blue); } SetPalette(gPalette); }
/***************************************************************************** Function: osd_gfx_init_scanline_mode Description: Initialize screen for use with the scanline displaying Parameters: none Return: nothing *****************************************************************************/ int osd_gfx_init_scanline_mode(void) { if (!(set_gfx_mode(GFX_SVGALIB,640,480,0,0))) { vwidth=640; vheight=480; blit_x=(320-io.screen_w); blit_y=(240-io.screen_h); screen_blit_x=((WIDTH-io.screen_h) >> 1); screen_blit_y=((HEIGHT-io.screen_w) >> 1); SetPalette(); return 1; }