本文整理汇总了C++中SetStretchBltMode函数的典型用法代码示例。如果您正苦于以下问题:C++ SetStretchBltMode函数的具体用法?C++ SetStretchBltMode怎么用?C++ SetStretchBltMode使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SetStretchBltMode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sStretch2D
void sStretch2D(const sU32 *data,sInt width,const sRect &source,const sRect &dest)
{
BITMAPINFO bmi;
sClear(bmi);
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = width;
bmi.bmiHeader.biHeight = -source.y1;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 32;
bmi.bmiHeader.biCompression = BI_RGB;
SetStretchBltMode(sGDIDC,STRETCH_DELETESCANS);
StretchDIBits(
sGDIDC,
dest.x0,dest.y0,dest.SizeX(),dest.SizeY(),
source.x0,source.y0,source.SizeX(),source.SizeY(),
data,&bmi,DIB_RGB_COLORS,SRCCOPY);
}
示例2: SetStretchBltMode
void ImageWndPicWnd::LoadPic(CString T)
{
if(org.LoadImage(T)==S_OK)
{
FileName=T;
SetStretchBltMode(ava.GetDC(),COLORONCOLOR);
org.StretchTo(&ava,ava.Rgn,org.Rgn,SRCCOPY);
HGDIOBJ tfont=ava.SelectObject(font1);
ava.SetBkMode(TRANSPARENT); ava.SetTextColor(clRED);
ava.TextOut(0,0,T);
T.Format("%dx%d",org.w,org.h); ava.TextOut(0,10,T);
ava.SelectObject(tfont);
CaptureButton.ShowWindow(SW_HIDE); DragAcceptFiles(FALSE);
UpdateNow();
Parent->Ctrls.Xmax=org.w; Parent->Ctrls.UpdateData();
}
else FileName="";
}
示例3: SetStretchBltMode
void CPrizeEndDlg::DrawSponsorImg()
{
if (m_SponsorImage.IsNull()) return;
CDC *pDC = this->GetDC();
CDC dcMemory;
dcMemory.CreateCompatibleDC(pDC);
CBitmap bitmap;
bitmap.CreateCompatibleBitmap(pDC, m_SponsorImage.GetWidth(), m_SponsorImage.GetHeight());
CBitmap *pOldBitmap = dcMemory.SelectObject(&bitmap);
SetStretchBltMode(dcMemory.GetSafeHdc(), STRETCH_DELETESCANS/*COLORONCOLOR*/);
m_SponsorImage.StretchBlt(dcMemory, 0, 0, m_SponsorImage.GetWidth(), m_SponsorImage.GetHeight(), SRCCOPY);
pDC->StretchBlt(116, 188, 300, 300,
&dcMemory, 0, 0, m_SponsorImage.GetWidth(), m_SponsorImage.GetHeight(), SRCCOPY);
dcMemory.SelectObject(pOldBitmap);
dcMemory.DeleteDC();
}
示例4: processFrame
HRESULT
Frame::DoRenderSample(IMediaSample *sample)
{
if(FRAME_DECODING) {
if(debug) printf("Frame::DoRenderSample Cancelling DoRenderSample while FRAME_DECODING\n");
return S_FALSE;
}
FRAME_PROCESSING = false;
if(STOP_REQUESTED) return S_FALSE;
FRAME_PROCESSING = true;
data = 0;
sample->GetPointer( &data );
processFrame();
bool newtag = false;
bool newage = (last_tag_age == decoder->tagAge()) ? false : true ;
for(int i=0; i < 15; i++) { if( tag_string[i] != last_tag_string[i] ) newtag = true; }
paintFrame(newtag, newage);
for(int i=0; i < 15; i++) last_tag_string[i] = tag_string[i];
last_tag_age = decoder->tagAge();
//d_videoAlignmentTest();
bmi.bmiHeader = bmih;
HDC hdc = GetDC(hwnd);
HRESULT hr;
SetStretchBltMode(hdc, HALFTONE);
hr = StretchDIBits(hdc,
(c_width-v_display_width)/2,
(c_height - GetSystemMetrics(SM_CYMENU) - config->V_MSG_STRIP_SIZE - v_display_height)/2,
v_display_width, v_display_height,
0, 0,
v_width, v_height,
data, &bmi, DIB_RGB_COLORS, SRCCOPY);
ReleaseDC(hwnd, hdc);
/* OVERLAY TEST
RECT rect;
rect.right = 10;
rect.left = 20;
rect.top = 5;
rect.bottom = 10;
FillRect(hdc, &rect, debug_brush);
OVERLAY TEST */
if(config->V_D_PIXDEBUG) Sleep(600);
FRAME_PROCESSING = false;
return hr;
}
示例5: Bitmap
void __fastcall TForm1::_GetBitmap(TImage* img)
{
// if (Quality != l_jpg->Scale) l_jpg->Scale = Quality;
std::auto_ptr<Graphics::TBitmap> Bitmap(new Graphics::TBitmap);
Bitmap->Assign(jpg);
int myWidth = img->Width;
int myHeight = img->Height;
img->Picture->Bitmap->Width = img->Width;
img->Picture->Bitmap->Height = img->Height;
if (Bitmap->Width > Bitmap->Height) {
double k = (double)Bitmap->Height / (double)Bitmap->Width;
myHeight = img->Width * k;
if (myHeight > img->Height) {
myHeight = img->Height;
myWidth = img->Height / k;
}
}
else {
double k = (double)Bitmap->Width / (double)Bitmap->Height;
myWidth = img->Height * k;
if ( myWidth > img->Width) {
myWidth = img->Width;
myHeight = img->Width / k;
}
}
img->Picture->Bitmap->Canvas->Brush->Color = clBlack;
img->Picture->Bitmap->Canvas->FillRect(TRect(0,0,img->Width,img->Height));
SetStretchBltMode(img->Picture->Bitmap->Canvas->Handle, HALFTONE);
StretchBlt(
img->Picture->Bitmap->Canvas->Handle, // приемник
(img->Width - myWidth)/2, (img->Height - myHeight) / 2, // координаты верхнего угла приемника
myWidth, myHeight,
Bitmap->Canvas->Handle, // исходник
0, 0, // координаты верхнего угла исходника
Bitmap->Width, Bitmap->Height,
SRCCOPY
);
}
示例6: rect
long CHSDib::Draw(HDC pDC, long xoffset, long yoffset,BOOL bTracking /*= FALSE*/)
{
if( (hDib) && (pDC) )
{
CRect rect(xoffset, yoffset, m_bi.biWidth, m_bi.biHeight);
if( bTracking == 2 ) // focus
{
FillRect(pDC, &rect, (HBRUSH) (COLOR_INFOBK + 1));
}
else if( bTracking == 1) // over
{
FillRect(pDC, &rect, (HBRUSH) (COLOR_WINDOW + 1));
}
else
{
FillRect(pDC, &rect, (HBRUSH) (COLOR_BTNFACE + 1));
}
CBrush hBrush;
hBrush.CreateSolidBrush(0);
FrameRect(pDC, &rect, (HBRUSH) hBrush );
hBrush.DeleteObject();
//LPSTR lpDIB = (char*)hDib; //set image to hdc...
//SetStretchBltMode(pDC,MAXSTRETCHBLTMODE);//COLORONCOLOR);
//SetDIBitsToDevice(pDC, xoffset, yoffset,
// m_bi.biWidth, m_bi.biHeight, 0, 0, 0,
// m_bi.biHeight, GetBits(),
// (BITMAPINFO*)lpDIB, DIB_RGB_COLORS);
#if Support_CHSDib
//palette must be correctly filled
LPSTR lpDIB = (char*)hDib; //set image to hdc...
SetStretchBltMode(pDC,MAXSTRETCHBLTMODE);//COLORONCOLOR);
SetDIBitsToDevice(pDC, xoffset, yoffset,
m_bi.biWidth, m_bi.biHeight, 0, 0, 0,
m_bi.biHeight, GetBits(),
(BITMAPINFO*)lpDIB, DIB_RGB_COLORS);
#endif
return 1;
}
return 0;
}
示例7: sttPreviewSkin
static void sttPreviewSkin(MODERNOPTOBJECT *obj, TCHAR *fn, LPDRAWITEMSTRUCT lps)
{
if (!fn) return;
char svc[128];
mir_snprintf(svc, SIZEOF(svc), "%s%s", obj->lpzThemeModuleName, TS_SKIN_PREVIEW);
if (ServiceExists(svc))
CallService(svc, (WPARAM)lps, (LPARAM)fn);
else {
char *afn = mir_t2a(fn);
char *fnpreview = (char *)mir_alloc(lstrlenA(afn) + 10);
lstrcpyA(fnpreview, afn);
lstrcatA(fnpreview, ".png");
HBITMAP hbmPreview = (HBITMAP)CallService(MS_UTILS_LOADBITMAP, 0, (LPARAM)fnpreview);
mir_free(afn);
mir_free(fnpreview);
if (!hbmPreview) return;
BITMAP bmp;
GetObject(hbmPreview, sizeof(bmp), &bmp);
SIZE szDst = { abs(bmp.bmWidth), abs(bmp.bmHeight) };
if ((szDst.cx > lps->rcItem.right-lps->rcItem.left) || (szDst.cy > lps->rcItem.bottom-lps->rcItem.top)) {
float q = min(
float(lps->rcItem.right-lps->rcItem.left) / szDst.cx,
float(lps->rcItem.bottom-lps->rcItem.top) / szDst.cy);
szDst.cx *= q;
szDst.cy *= q;
}
POINT ptDst = {
(lps->rcItem.left+lps->rcItem.right-szDst.cx) / 2,
(lps->rcItem.top+lps->rcItem.bottom-szDst.cy) / 2 };
HDC hdc = CreateCompatibleDC(lps->hDC);
SelectObject(hdc, hbmPreview);
SetStretchBltMode(hdc, HALFTONE);
StretchBlt(lps->hDC, ptDst.x, ptDst.y, szDst.cx, szDst.cy, hdc, 0, 0, abs(bmp.bmWidth), abs(bmp.bmHeight), SRCCOPY);
DeleteDC(hdc);
DeleteObject(hbmPreview);
}
}
示例8: memset
//-----------------------------------------------------------------------------
// Purpose:
// Input : pDC -
// srcRect -
// dstRect -
//-----------------------------------------------------------------------------
void CMaterial::DrawBitmap( CDC *pDC, RECT& srcRect, RECT& dstRect )
{
static struct
{
BITMAPINFOHEADER bmih;
unsigned short colorindex[256];
} bmi;
int srcWidth = srcRect.right - srcRect.left;
int srcHeight = srcRect.bottom - srcRect.top;
BITMAPINFOHEADER &bmih = bmi.bmih;
memset(&bmih, 0, sizeof(bmih));
bmih.biSize = sizeof(bmih);
bmih.biWidth = srcWidth;
bmih.biHeight = -srcHeight;
bmih.biCompression = BI_RGB;
bmih.biBitCount = 24;
bmih.biPlanes = 1;
static BOOL bInit = false;
if (!bInit)
{
bInit = true;
for (int i = 0; i < 256; i++)
{
bmi.colorindex[i] = i;
}
}
int dest_width = dstRect.right - dstRect.left;
int dest_height = dstRect.bottom - dstRect.top;
// ** bits **
SetStretchBltMode(pDC->m_hDC, COLORONCOLOR);
if (StretchDIBits(pDC->m_hDC, dstRect.left, dstRect.top, dest_width, dest_height,
srcRect.left, -srcRect.top, srcWidth, srcHeight, m_pData, (BITMAPINFO*)&bmi, DIB_RGB_COLORS, SRCCOPY) == GDI_ERROR)
{
Msg(mwError, "CMaterial::Draw(): StretchDIBits failed.");
}
}
示例9: GetDC
///////////////////////////////////////////////////////////////////////
// Class : CWinDisplay
// Method : redraw
// Description : Redraw the image
// Return Value : -
// Comments :
void CWinDisplay::redraw() {
RECT windowRect;
RECT imageRect;
HDC cDc;
cDc = GetDC(hWnd);
imageRect.left = 0;
imageRect.top = 0;
imageRect.right = width;
imageRect.bottom= height;
GetClientRect(hWnd,&windowRect);
SetStretchBltMode(cDc, COLORONCOLOR);
StretchDIBits(cDc, 0,0,width,height,
0,0,width,height,
imageData,&info,DIB_RGB_COLORS,SRCCOPY);
willRedraw = FALSE;
}
示例10: P_GET_OBJECT
void
AMiscFunctions::execScreenshotToTCP(FFrame& Stack, RESULT_DECL)
{
P_GET_OBJECT(ATcpLink,tc)
P_FINISH
HDC screen = GetDC(NULL);
HDC destDC = CreateCompatibleDC(screen);
HBITMAP bmp = CreateCompatibleBitmap(screen, 1024, 768);
SelectObject(destDC, bmp);
SetStretchBltMode(destDC, HALFTONE);
if(!StretchBlt(destDC,
0,0,
1024, 768,
screen,
0,0,
GetSystemMetrics(SM_CXSCREEN),
GetSystemMetrics(SM_CYSCREEN),
SRCCOPY)) {
GLog->Logf(TEXT("Unable to StretchBlt."));
}
if (destbuffer == NULL)
destbuffer = (unsigned char*) malloc(1024*1024*1024);
unsigned long destsize;
fnsaveasjpeg(destDC, bmp, &destbuffer, &destsize);
GLog->Logf(TEXT("Sending image through socket %d"), tc->Socket);
char messagetype=0;
send(tc->Socket, &messagetype, 1, 0);
send(tc->Socket, (const char*)&destsize, sizeof(destsize), 0);
send(tc->Socket, (const char*) destbuffer, destsize, 0);
//FILE* f = fopen(fn, "wb+");
//fwrite(destbuffer, 1, destsize, f);
//fclose(f);
}
示例11: switch
LRESULT CALLBACK CRoboMXApp::NewWndProc(HWND hwnd, UINT uMsg, WPARAM wParam,LPARAM lParam)
{
HDC hdc = (HDC)wParam;
CRect rect;
switch (uMsg) {
case WM_SIZE :
SendMessage(hwnd, WM_ERASEBKGND, (WPARAM)GetDC(hwnd), 0);
return CallWindowProc(theApp.m_pOldWndProc, hwnd, uMsg, wParam, lParam);
case WM_ERASEBKGND :
SetStretchBltMode(hdc, HALFTONE);
GetClientRect(hwnd, &rect);
if(rect.Width() && rect.Height())
theApp.m_iBgImage.Draw(hdc, rect);
return 1;
default :
return CallWindowProc(theApp.m_pOldWndProc, hwnd, uMsg, wParam, lParam);
}
}
示例12: GetClientRect
BOOL CUserDesktopDlg::OnEraseBkgnd(CDC* pDC)
{
CRect rect;
GetClientRect(rect);
if(m_desktopwnd && m_desktopwnd->nSessionID)
{
SetStretchBltMode(pDC->m_hDC, COLORONCOLOR);
TT_PaintDesktopWindow(ttInst, m_nUserID, pDC->m_hDC, rect.left,
rect.top, rect.Width(), rect.Height());
//const int W = 100, H = 100;
//BOOL b;
//b = TT_PaintDesktopWindowEx(ttInst, m_nUserID, pDC->m_hDC, rect.left,
// rect.top, rect.Width(), rect.Height(),
// m_desktopwnd.nWidth-W, m_desktopwnd.nHeight-H, W, H);
//ASSERT(b);
return FALSE;
}
else
return CDialog::OnEraseBkgnd(pDC);
}
示例13: DoPaint
VOID DoPaint(HWND hWnd, DWORD dwMode)
{
HBITMAP ghBitmap = (HBITMAP)LoadImage(NULL,"startpic.bmp",IMAGE_BITMAP,0,0, LR_LOADFROMFILE|LR_CREATEDIBSECTION);
PAINTSTRUCT ps;
RECT rect;
HDC hdcMem;
BITMAP bm;
HDC hDC = BeginPaint(hWnd, &ps);
GetClientRect(hWnd, &rect);
SetStretchBltMode(hDC, HALFTONE);
hdcMem = CreateCompatibleDC(hDC);
SelectObject(hdcMem, ghBitmap);
if (ghBitmap)
{
if (GetObject(ghBitmap, sizeof(BITMAP), &bm))
{
if(dwMode == 1)
{
StretchBlt(hDC, 0, 0, rect.right, rect.bottom,
hdcMem, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
}
else
{
INT ixStart = (rect.right - rect.left - bm.bmWidth)/2;
INT iyStart = (rect.bottom - rect.top - bm.bmHeight)/2;
ixStart = ixStart < 0 ? 0 : ixStart;
iyStart = iyStart < 0 ? 0 : iyStart;
BitBlt(hDC, 0, 0, rect.right, rect.bottom,
hdcMem,-ixStart,-iyStart, SRCCOPY);
}
DeleteDC(hdcMem);
}
}
else
{
PatBlt(hDC, 0, 0, rect.right, rect.bottom, BLACKNESS);
}
//EndPaint(hWnd, &ps);
}
示例14: BM_CreateStretched
HBITMAP BM_CreateStretched(HWND hWnd, SIZE sizNew, HBITMAP hbm, SIZE siz)
{
DWORD dwError;
HDC hDC, hdcMem1, hdcMem2;
HBITMAP hbmNew, hbmOld1, hbmOld2;
hbmNew = BM_Create(sizNew);
if (hbmNew != NULL)
{
dwError = 0;
hDC = GetDC(hWnd);
hdcMem1 = CreateCompatibleDC(hDC);
if (hdcMem1 != NULL)
{
hbmOld1 = SelectObject(hdcMem1, hbmNew);
hdcMem2 = CreateCompatibleDC(hDC);
if (hdcMem2 != NULL)
{
hbmOld2 = SelectObject(hdcMem2, hbm);
SetStretchBltMode(hdcMem1, COLORONCOLOR);
StretchBlt(hdcMem1, 0, 0, sizNew.cx, sizNew.cy,
hdcMem2, 0, 0, siz.cx, siz.cy, SRCCOPY);
SelectObject(hdcMem2, hbmOld2);
DeleteDC(hdcMem2);
}
else
dwError = GetLastError();
SelectObject(hdcMem1, hbmOld1);
DeleteDC(hdcMem1);
}
else
dwError = GetLastError();
ReleaseDC(hWnd, hDC);
SetLastError(dwError);
}
return hbmNew;
}
示例15: SelectObject
void CDialogThumbs::DrawOwnerDrawCtl( LPDRAWITEMSTRUCT lpDrawItem, HBITMAP hbp )
{
if (NULL == hbp)
{
return;
}
SelectObject(dc_memory_, hbp);
BITMAP bitmap;
GetObject(hbp, sizeof(bitmap), &bitmap);
float rate_x = (float)(lpDrawItem->rcItem.right - lpDrawItem->rcItem.left) / bitmap.bmWidth;
float rate_y = (float)(lpDrawItem->rcItem.bottom - lpDrawItem->rcItem.top) / abs(bitmap.bmHeight);
RECT rc;
if (rate_x > rate_y)
{
rc.top = lpDrawItem->rcItem.top;
rc.bottom = lpDrawItem->rcItem.bottom;
int width = rate_y * bitmap.bmWidth;
rc.left = 0;
rc.right = width;
}
else
{
rc.left = lpDrawItem->rcItem.left;
rc.right = lpDrawItem->rcItem.right;
int height = rate_x * abs(bitmap.bmHeight);
rc.top = 0;
rc.bottom = height;
}
SetStretchBltMode(lpDrawItem->hDC, STRETCH_HALFTONE);
StretchBlt(lpDrawItem->hDC, rc.left, rc.top, rc.right, rc.bottom, dc_memory_, 0, 0, bitmap.bmWidth, bitmap.bmHeight, SRCCOPY);
}