void OSDRegion::DrawSomeText(CRect rect, const CString& txt, DWORD color, DWORD backcolor, int font, int iFontSize, DWORD dwFlags, bool bTransparent) { CDC* pDC = GetDC(); CFont* theFont = CreateFont(font, iFontSize); CFont* oldFont = pDC->SelectObject(theFont); if (!bTransparent) { CSize sz = pDC->GetTextExtent(txt); sz.cx = min(sz.cx,rect.Width()); DrawFilledBox(CRect(rect.TopLeft(), sz), backcolor, backcolor); } dwFlags|= DT_END_ELLIPSIS; pDC->SetBkMode(bTransparent ? TRANSPARENT : OPAQUE); pDC->SetBkColor(ConvertRGB(backcolor)); pDC->SetTextColor(ConvertRGB(color)); CString text = txt; text.Replace("&", "&&"); pDC->DrawText(text, rect, dwFlags); pDC->SelectObject(oldFont); delete theFont; ReleaseDC(); }
int OSDRegion::Draw3dBox(DWORD x, DWORD y, DWORD w, DWORD h, DWORD c1, DWORD c2 ) { CDC* pDC = GetDC(); pDC->Draw3dRect(x + GetXOffs(), y + GetYOffs(), w, h, ConvertRGB(c1), ConvertRGB(c2)); ReleaseDC(); return 0; }
int OSDRegion::PutPixel(DWORD x, DWORD y, DWORD pix ) { CDC* pDC = GetDC(); pDC->SetPixelV(x + GetXOffs(), y + GetYOffs(), ConvertRGB(pix)); ReleaseDC(); return 0; }
int OSDRegion::PutBox(DWORD x, DWORD y, DWORD w, DWORD h, const void *data, bool sprite, BYTE dataFormat ) { if (dataFormat!= OSD_1555) { LogUnimplemented("PutBox only implemented for 1555 RGB data"); return 0; } CDC* pDC = GetDC(); int dx = x + GetXOffs(); int dy = y + GetYOffs(); word* pData = (word*) data; for (unsigned int j = 0; j<h; j++) { for (unsigned int i = 0; i<w; i++) { if (!sprite || (*pData != 0)) { pDC->SetPixelV(i + dx, j + dy, ConvertRGB(SWAPWORD(*pData))); } pData++; } } ReleaseDC(); return 0; }
//Load the BMP file GLubyte* TextureLoadBitmap(char *filename, int *w, int *h) /* I - Bitmap file to load */ { BITMAPINFO *info; /* Bitmap information */ void *bits; /* Bitmap pixel bits */ GLubyte *rgb; /* Bitmap RGB pixels */ GLubyte err = '0'; /* * Try loading the bitmap and converting it to RGB... */ bits = LoadDIBitmap(filename, &info); if(bits==NULL) return(NULL); rgb = ConvertRGB(info, bits); if (rgb == NULL) { free(info); free(bits); }; printf("%s: %d %d\n", filename, info->bmiHeader.biWidth, info->bmiHeader.biHeight); printf("read %s successfully\n", filename); *w = info->bmiHeader.biWidth; *h = info->bmiHeader.biHeight; /* * Free the bitmap and RGB images, then return 0 (no errors). */ free(info); free(bits); return (rgb); }
void OSDRegion::DrawFilledBox(CRect rect, DWORD dwFillColor, DWORD dwEdgeColor) { CDC* pDC = GetDC(); COLORREF crBack = ConvertRGB(dwFillColor); pDC->FillSolidRect(rect, crBack); DrawRectangle(rect, dwEdgeColor, 1); ReleaseDC(); }
void OSDRegion::DrawRectangle(CRect rect, DWORD dwColor, int thickness) { CDC* pDC = GetDC(); COLORREF crBorder = ConvertRGB(dwColor); CPen pen(PS_SOLID, thickness, crBorder); CPen* pOldPen = pDC->SelectObject(&pen); pDC->MoveTo(rect.left,rect.top + thickness/2); pDC->LineTo(rect.right-1,rect.top + thickness/2); pDC->LineTo(rect.right-1,rect.bottom-1); pDC->LineTo(rect.left + thickness/2,rect.bottom-1); pDC->LineTo(rect.left + thickness/2,rect.top); pDC->SelectObject(pOldPen); ReleaseDC(); }
void OpenBitmapFile(char *filename ) /* I - Bitmap file to open */ { char title[256], /* Title of file (no path info) */ name[256], /* Full pathname of file */ directory[256]; /* Directory of file */ OPENFILENAME ofn; /* Filename dialog structure */ void *bits; /* Bitmap pixel bits */ GLubyte *BitmapBits = NULL; /* * Pop up a filename dialog if we don't have a filename... */ if (filename == NULL || filename[0] == '\0') { /* * Fill in the OPENFILENAME dialog info... */ strcpy(directory, "."); strcpy(name, ""); strcpy(title, ""); memset(&ofn, 0, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = ViewWindow; ofn.lpstrFilter = "Bitmaps\0*.BMP\0\0"; ofn.nFilterIndex = 1; ofn.lpstrFile = name; ofn.nMaxFile = sizeof(name) - 1; ofn.lpstrFileTitle = title; ofn.nMaxFileTitle = sizeof(title) - 1; ofn.lpstrInitialDir = directory; ofn.lpstrTitle = "Open Bitmap File"; ofn.Flags = OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_NONETWORKBUTTON | OFN_FILEMUSTEXIST; if (!GetOpenFileName(&ofn)) return; filename = name; }; /* * Free the old bitmap if there is one... */ if (BitmapInfo != NULL) { free(BitmapInfo); free(BitmapBits); BitmapInfo = NULL; }; /* * Load the named bitmap from disk. Display an error message if it * doesn't load... */ bits = LoadDIBitmap(filename, &BitmapInfo); bmpheight=(*BitmapInfo).bmiHeader.biHeight; bmpwidth=(*BitmapInfo).bmiHeader.biWidth; printf("bmp dimensions height %d width %d ",bmpheight,bmpwidth); if (bits == NULL) DisplayErrorMessage("Could not open bitmap file \'%s\'!", filename); else { BitmapBits = ConvertRGB(BitmapInfo, bits); bmpaddress=BitmapBits; free(bits); if (BitmapBits == NULL) { DisplayErrorMessage("Could not convert bitmap to RGB!"); free(BitmapInfo); BitmapInfo = NULL; }; }; }