Сделать скрин с экрана
Цитата:
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <curl/curl.h>
#include <curl/types.h>
#include <curl/easy.h>
#include <pcre.h>
#include <locale>
#include <tchar.h>
#include <windows.h>
#include <iostream>
#include <string.h>
#include <tchar.h>
#
#define MAXWRITE (1024*16)
#
#
class Bitmap{
#
private:
#
//This function is slow, and thus not good for animation purposes
#
//but for displaying a transparent bitmap that doesn't get redrawn
#
//constantly this is a good function
#
void DrawTransparentBitmap(HDC hdc,HBITMAP hbm,int ix=0,int iy=0,COLORREF transClr=RGB(255,255,255)){
#
BITMAP bm;
#
int tempx=ix,tempy=iy;
#
GetObject(hbm,sizeof(bm),&bm);
#
HDC hdc2=CreateCompatibleDC(hdc);
#
SelectObject(hdc2,hbm);
#
int xx=0,yy=0;
#
for(int y=tempy;y<tempy+bm.bmHeight;y++){
#
for(int x=tempx;x<tempx+bm.bmWidth;x++){
#
COLORREF clr=GetPixel(hdc2,xx,yy);
#
if(clr!=transClr){
#
SetPixel(hdc,x,y,clr);
#
}
#
xx++;
#
}
#
xx=0;
#
yy++;
#
}
#
DeleteDC(hdc2);
#
}
#
#
#
//I added this function from win32 api.hlp, I plan to write my own some day
#
PBITMAPINFO CreateBitmapInfoStruct(HBITMAP hBmp) {
#
BITMAP bmp;
#
PBITMAPINFO pbmi;
#
WORD cClrBits;
#
if(!GetObject(hBmp, sizeof(BITMAP), (LPSTR)&bmp)){
#
MessageBox(0,"Bitmap failed to save","Error...",MB_OK);
#
}
#
cClrBits = (WORD)(bmp.bmPlanes * bmp.bmBitsPixel);
#
if(cClrBits == 1){
#
cClrBits = 1;
#
}
#
else if(cClrBits <= 4){
#
cClrBits = 4;
#
}
#
else if(cClrBits <= 8){
#
cClrBits = 8;
#
}
#
else if(cClrBits <= 16){
#
cClrBits = 16;
#
}
#
else if(cClrBits <= 24){
#
cClrBits = 24;
#
}
#
else{
#
cClrBits = 32;
#
}
#
if(cClrBits != 24){
#
pbmi=(PBITMAPINFO)LocalAlloc(LPTR,sizeof(BITMAPINFOHEADER)+sizeof(RGBQUAD) * (2^cClrBits));
#
}
#
else{
#
pbmi=(PBITMAPINFO)LocalAlloc(LPTR,sizeof(BITMAPINFOHEADER));
#
}
#
pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
#
pbmi->bmiHeader.biWidth = bmp.bmWidth;
#
pbmi->bmiHeader.biHeight = bmp.bmHeight;
#
pbmi->bmiHeader.biPlanes = bmp.bmPlanes;
#
pbmi->bmiHeader.biBitCount = bmp.bmBitsPixel;
#
if(cClrBits < 24){
#
pbmi->bmiHeader.biClrUsed = 2^cClrBits;
#
}
#
pbmi->bmiHeader.biCompression = BI_RGB;
#
pbmi->bmiHeader.biSizeImage = (pbmi->bmiHeader.biWidth + 7) /8
#
* pbmi->bmiHeader.biHeight
#
* cClrBits;
#
pbmi->bmiHeader.biClrImportant = 0;
#
return pbmi;
#
}
#
#
#
//I added this function from win32 api.hlp, I plan to write my own some day
#
void CreateBMPFile(LPTSTR pszFile, PBITMAPINFO pbi, HBITMAP hBMP,HDC hDC){
#
HANDLE hf;
#
BITMAPFILEHEADER hdr;
#
PBITMAPINFOHEADER pbih;
#
LPBYTE lpBits;
#
DWORD dwTotal;
#
DWORD cb;
#
BYTE *hp;
#
DWORD dwTmp;
#
pbih = (PBITMAPINFOHEADER) pbi;
#
lpBits = (LPBYTE) GlobalAlloc(GMEM_FIXED, pbih->biSizeImage);
#
if(!lpBits){
#
MessageBox(0,"Failed to save bitmap.","Error...",MB_OK);
#
}
#
if(!GetDIBits(hDC, hBMP, 0, (WORD) pbih->biHeight, lpBits, pbi, DIB_RGB_COLORS)){
#
MessageBox(0,"Failed to save bitmap.","Error...",MB_OK);
#
}
#
hf=CreateFile(pszFile,
#
GENERIC_READ | GENERIC_WRITE,
#
(DWORD) 0,
#
(LPSECURITY_ATTRIBUTES) NULL,
#
CREATE_ALWAYS,
#
FILE_ATTRIBUTE_NORMAL,
#
(HANDLE) NULL);
#
if(hf==INVALID_HANDLE_VALUE){
#
MessageBox(0,"Failed to save bitmap1.","Error...",MB_OK);
#
}
#
hdr.bfType=0x4d42;
#
hdr.bfSize=(DWORD)(sizeof(BITMAPFILEHEADER)+pbih->biSize + pbih->biClrUsed*sizeof(RGBQUAD)+pbih->biSizeImage);
#
hdr.bfReserved1=0;
#
hdr.bfReserved2=0;
#
hdr.bfOffBits=(DWORD)sizeof(BITMAPFILEHEADER)+pbih->biSize + pbih->biClrUsed*sizeof (RGBQUAD);
#
if(!WriteFile(hf, (LPVOID) &hdr, sizeof(BITMAPFILEHEADER),(LPDWORD) &dwTmp, (LPOVERLAPPED) NULL)){
#
MessageBox(0,"Failed to save bitmap2.","Error...",MB_OK);
#
}
#
if(!WriteFile(hf,(LPVOID)pbih,sizeof(BITMAPINFOHEADER)+pbih->biClrUsed * sizeof (RGBQUAD),(LPDWORD) &dwTmp, (LPOVERLAPPED) NULL)){
#
MessageBox(0,"Failed to save bitmap3.","Error...",MB_OK);
#
}
#
dwTotal = cb = pbih->biSizeImage;
#
hp = lpBits;
#
while(cb > MAXWRITE){
#
if(!WriteFile(hf,(LPSTR)hp,(int)MAXWRITE,(LPDWORD)&dwTmp,(LPOVERLAPPED)NULL)){
#
MessageBox(0,"Failed to save bitmap4.","Error...",MB_OK);
#
}
#
cb-=MAXWRITE;
#
hp+=MAXWRITE;
#
}
#
if(!WriteFile(hf, (LPSTR) hp, (int) cb,(LPDWORD) &dwTmp, (LPOVERLAPPED) NULL)){
#
MessageBox(0,"Failed to save bitmap5.","Error...",MB_OK);
#
}
#
if(!CloseHandle(hf)){
#
MessageBox(0,"Failed to save bitmap6.","Error...",MB_OK);
#
}
#
GlobalFree((HGLOBAL)lpBits);
#
}
#
#
HBITMAP hbitmap;//The bitmap
#
#
public:
#
#
//Constructor
#
Bitmap(){};
#
#
#
//Constructor specifying either a resource name or a bitmap file path\name.txt
#
Bitmap(char* FOR){
#
this->hbitmap=LoadBitmap(0,FOR);
#
if(!this->hbitmap){
#
this->hbitmap=(HBITMAP)LoadImage(NULL,FOR,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
#
}
#
}
#
#
//If the bitmap contains data or not
#
BOOL Exists(){
#
if(!this->hbitmap){
#
return FALSE;
#
}
#
return TRUE;
#
}
#
#
//Skipping through the obvious ones now...
#
HBITMAP GetHandle(){
#
return this->hbitmap;
#
}
#
#
HBITMAP SetHandle(HBITMAP hbm,HWND hwnd=(HWND)NULL,RECT* r=(RECT*)NULL){
#
HBITMAP temp;
#
temp=this->hbitmap;
#
this->hbitmap=hbm;
#
if(hwnd){
#
RECT rect;
#
if(!r){
#
GetClientRect(hwnd,&rect);
#
}
#
else{
#
rect=*r;
#
}
#
UpdateWindow(hwnd);
#
RedrawWindow(hwnd,&rect,0,RDW_ERASE|RDW_INVALIDATE);
#
}
#
return temp;
#
}
#
#
HBITMAP SetHandle(char*FOR,HWND hwnd=(HWND)NULL,RECT* r=(RECT*)NULL){
#
HBITMAP temp=this->hbitmap;
#
this->hbitmap=LoadBitmap(GetModuleHandle(0),FOR);
#
if(!this->hbitmap){
#
this->hbitmap=(HBITMAP)LoadImage(NULL,FOR,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
#
}
#
if(hwnd){
#
RECT rect;
#
if(!r){
#
GetClientRect(hwnd,&rect);
#
}
#
else{
#
rect=*r;
#
}
#
UpdateWindow(hwnd);
#
RedrawWindow(hwnd,&rect,0,RDW_ERASE|RDW_INVALIDATE);
#
}
#
return temp;
#
}
#
//This one nullifies the bitmap
#
void ClearHandle(HWND hwnd=(HWND)NULL,RECT* r=(RECT*)NULL){
#
this->hbitmap=(HBITMAP)NULL;
#
if(hwnd){
#
RECT rect;
#
if(!r){
#
GetClientRect(hwnd,&rect);
#
}
#
else{
#
rect=*r;
#
}
#
UpdateWindow(hwnd);
#
RedrawWindow(hwnd,&rect,0,RDW_ERASE|RDW_INVALIDATE);
#
}
#
}
#
#
//Draw the bitmap to a DC, arguments are obvious, bitmap is sized
#
//automatically according to it's actual size.
#
void Draw(HDC hdc,DWORD mode=SRCCOPY,int x=0,int y=0){
#
BITMAP bm;
#
GetObject(this->hbitmap,sizeof(BITMAP),&bm);
#
int w=bm.bmWidth;
#
int h=bm.bmHeight;
#
HDC src=CreateCompatibleDC(hdc);
#
SelectObject(src,this->hbitmap);
#
BitBlt(hdc,x,y,w,h,src,0,0,mode);
#
DeleteDC(src);
#
}
#
#
#
void DrawTransparent(HDC hdc,COLORREF transparentColor=RGB(255,255,255),int x=0,int y=0){
#
DrawTransparentBitmap(hdc,this->hbitmap,x,y,transparentColor);
#
}
#
#
//Save to the specified file
#
void SaveToFile(char* file){
#
BITMAPINFO* bmi=CreateBitmapInfoStruct(this->hbitmap);
#
CreateBMPFile(file,bmi,this->hbitmap,GetDC(GetDesktopWindow()));
#
}
#
};
void main()
{
Bitmap bitmap;
bitmap.SaveToFile("123.bmp");
}
#include <conio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <curl/curl.h>
#include <curl/types.h>
#include <curl/easy.h>
#include <pcre.h>
#include <locale>
#include <tchar.h>
#include <windows.h>
#include <iostream>
#include <string.h>
#include <tchar.h>
#
#define MAXWRITE (1024*16)
#
#
class Bitmap{
#
private:
#
//This function is slow, and thus not good for animation purposes
#
//but for displaying a transparent bitmap that doesn't get redrawn
#
//constantly this is a good function
#
void DrawTransparentBitmap(HDC hdc,HBITMAP hbm,int ix=0,int iy=0,COLORREF transClr=RGB(255,255,255)){
#
BITMAP bm;
#
int tempx=ix,tempy=iy;
#
GetObject(hbm,sizeof(bm),&bm);
#
HDC hdc2=CreateCompatibleDC(hdc);
#
SelectObject(hdc2,hbm);
#
int xx=0,yy=0;
#
for(int y=tempy;y<tempy+bm.bmHeight;y++){
#
for(int x=tempx;x<tempx+bm.bmWidth;x++){
#
COLORREF clr=GetPixel(hdc2,xx,yy);
#
if(clr!=transClr){
#
SetPixel(hdc,x,y,clr);
#
}
#
xx++;
#
}
#
xx=0;
#
yy++;
#
}
#
DeleteDC(hdc2);
#
}
#
#
#
//I added this function from win32 api.hlp, I plan to write my own some day
#
PBITMAPINFO CreateBitmapInfoStruct(HBITMAP hBmp) {
#
BITMAP bmp;
#
PBITMAPINFO pbmi;
#
WORD cClrBits;
#
if(!GetObject(hBmp, sizeof(BITMAP), (LPSTR)&bmp)){
#
MessageBox(0,"Bitmap failed to save","Error...",MB_OK);
#
}
#
cClrBits = (WORD)(bmp.bmPlanes * bmp.bmBitsPixel);
#
if(cClrBits == 1){
#
cClrBits = 1;
#
}
#
else if(cClrBits <= 4){
#
cClrBits = 4;
#
}
#
else if(cClrBits <= 8){
#
cClrBits = 8;
#
}
#
else if(cClrBits <= 16){
#
cClrBits = 16;
#
}
#
else if(cClrBits <= 24){
#
cClrBits = 24;
#
}
#
else{
#
cClrBits = 32;
#
}
#
if(cClrBits != 24){
#
pbmi=(PBITMAPINFO)LocalAlloc(LPTR,sizeof(BITMAPINFOHEADER)+sizeof(RGBQUAD) * (2^cClrBits));
#
}
#
else{
#
pbmi=(PBITMAPINFO)LocalAlloc(LPTR,sizeof(BITMAPINFOHEADER));
#
}
#
pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
#
pbmi->bmiHeader.biWidth = bmp.bmWidth;
#
pbmi->bmiHeader.biHeight = bmp.bmHeight;
#
pbmi->bmiHeader.biPlanes = bmp.bmPlanes;
#
pbmi->bmiHeader.biBitCount = bmp.bmBitsPixel;
#
if(cClrBits < 24){
#
pbmi->bmiHeader.biClrUsed = 2^cClrBits;
#
}
#
pbmi->bmiHeader.biCompression = BI_RGB;
#
pbmi->bmiHeader.biSizeImage = (pbmi->bmiHeader.biWidth + 7) /8
#
* pbmi->bmiHeader.biHeight
#
* cClrBits;
#
pbmi->bmiHeader.biClrImportant = 0;
#
return pbmi;
#
}
#
#
#
//I added this function from win32 api.hlp, I plan to write my own some day
#
void CreateBMPFile(LPTSTR pszFile, PBITMAPINFO pbi, HBITMAP hBMP,HDC hDC){
#
HANDLE hf;
#
BITMAPFILEHEADER hdr;
#
PBITMAPINFOHEADER pbih;
#
LPBYTE lpBits;
#
DWORD dwTotal;
#
DWORD cb;
#
BYTE *hp;
#
DWORD dwTmp;
#
pbih = (PBITMAPINFOHEADER) pbi;
#
lpBits = (LPBYTE) GlobalAlloc(GMEM_FIXED, pbih->biSizeImage);
#
if(!lpBits){
#
MessageBox(0,"Failed to save bitmap.","Error...",MB_OK);
#
}
#
if(!GetDIBits(hDC, hBMP, 0, (WORD) pbih->biHeight, lpBits, pbi, DIB_RGB_COLORS)){
#
MessageBox(0,"Failed to save bitmap.","Error...",MB_OK);
#
}
#
hf=CreateFile(pszFile,
#
GENERIC_READ | GENERIC_WRITE,
#
(DWORD) 0,
#
(LPSECURITY_ATTRIBUTES) NULL,
#
CREATE_ALWAYS,
#
FILE_ATTRIBUTE_NORMAL,
#
(HANDLE) NULL);
#
if(hf==INVALID_HANDLE_VALUE){
#
MessageBox(0,"Failed to save bitmap1.","Error...",MB_OK);
#
}
#
hdr.bfType=0x4d42;
#
hdr.bfSize=(DWORD)(sizeof(BITMAPFILEHEADER)+pbih->biSize + pbih->biClrUsed*sizeof(RGBQUAD)+pbih->biSizeImage);
#
hdr.bfReserved1=0;
#
hdr.bfReserved2=0;
#
hdr.bfOffBits=(DWORD)sizeof(BITMAPFILEHEADER)+pbih->biSize + pbih->biClrUsed*sizeof (RGBQUAD);
#
if(!WriteFile(hf, (LPVOID) &hdr, sizeof(BITMAPFILEHEADER),(LPDWORD) &dwTmp, (LPOVERLAPPED) NULL)){
#
MessageBox(0,"Failed to save bitmap2.","Error...",MB_OK);
#
}
#
if(!WriteFile(hf,(LPVOID)pbih,sizeof(BITMAPINFOHEADER)+pbih->biClrUsed * sizeof (RGBQUAD),(LPDWORD) &dwTmp, (LPOVERLAPPED) NULL)){
#
MessageBox(0,"Failed to save bitmap3.","Error...",MB_OK);
#
}
#
dwTotal = cb = pbih->biSizeImage;
#
hp = lpBits;
#
while(cb > MAXWRITE){
#
if(!WriteFile(hf,(LPSTR)hp,(int)MAXWRITE,(LPDWORD)&dwTmp,(LPOVERLAPPED)NULL)){
#
MessageBox(0,"Failed to save bitmap4.","Error...",MB_OK);
#
}
#
cb-=MAXWRITE;
#
hp+=MAXWRITE;
#
}
#
if(!WriteFile(hf, (LPSTR) hp, (int) cb,(LPDWORD) &dwTmp, (LPOVERLAPPED) NULL)){
#
MessageBox(0,"Failed to save bitmap5.","Error...",MB_OK);
#
}
#
if(!CloseHandle(hf)){
#
MessageBox(0,"Failed to save bitmap6.","Error...",MB_OK);
#
}
#
GlobalFree((HGLOBAL)lpBits);
#
}
#
#
HBITMAP hbitmap;//The bitmap
#
#
public:
#
#
//Constructor
#
Bitmap(){};
#
#
#
//Constructor specifying either a resource name or a bitmap file path\name.txt
#
Bitmap(char* FOR){
#
this->hbitmap=LoadBitmap(0,FOR);
#
if(!this->hbitmap){
#
this->hbitmap=(HBITMAP)LoadImage(NULL,FOR,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
#
}
#
}
#
#
//If the bitmap contains data or not
#
BOOL Exists(){
#
if(!this->hbitmap){
#
return FALSE;
#
}
#
return TRUE;
#
}
#
#
//Skipping through the obvious ones now...
#
HBITMAP GetHandle(){
#
return this->hbitmap;
#
}
#
#
HBITMAP SetHandle(HBITMAP hbm,HWND hwnd=(HWND)NULL,RECT* r=(RECT*)NULL){
#
HBITMAP temp;
#
temp=this->hbitmap;
#
this->hbitmap=hbm;
#
if(hwnd){
#
RECT rect;
#
if(!r){
#
GetClientRect(hwnd,&rect);
#
}
#
else{
#
rect=*r;
#
}
#
UpdateWindow(hwnd);
#
RedrawWindow(hwnd,&rect,0,RDW_ERASE|RDW_INVALIDATE);
#
}
#
return temp;
#
}
#
#
HBITMAP SetHandle(char*FOR,HWND hwnd=(HWND)NULL,RECT* r=(RECT*)NULL){
#
HBITMAP temp=this->hbitmap;
#
this->hbitmap=LoadBitmap(GetModuleHandle(0),FOR);
#
if(!this->hbitmap){
#
this->hbitmap=(HBITMAP)LoadImage(NULL,FOR,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
#
}
#
if(hwnd){
#
RECT rect;
#
if(!r){
#
GetClientRect(hwnd,&rect);
#
}
#
else{
#
rect=*r;
#
}
#
UpdateWindow(hwnd);
#
RedrawWindow(hwnd,&rect,0,RDW_ERASE|RDW_INVALIDATE);
#
}
#
return temp;
#
}
#
//This one nullifies the bitmap
#
void ClearHandle(HWND hwnd=(HWND)NULL,RECT* r=(RECT*)NULL){
#
this->hbitmap=(HBITMAP)NULL;
#
if(hwnd){
#
RECT rect;
#
if(!r){
#
GetClientRect(hwnd,&rect);
#
}
#
else{
#
rect=*r;
#
}
#
UpdateWindow(hwnd);
#
RedrawWindow(hwnd,&rect,0,RDW_ERASE|RDW_INVALIDATE);
#
}
#
}
#
#
//Draw the bitmap to a DC, arguments are obvious, bitmap is sized
#
//automatically according to it's actual size.
#
void Draw(HDC hdc,DWORD mode=SRCCOPY,int x=0,int y=0){
#
BITMAP bm;
#
GetObject(this->hbitmap,sizeof(BITMAP),&bm);
#
int w=bm.bmWidth;
#
int h=bm.bmHeight;
#
HDC src=CreateCompatibleDC(hdc);
#
SelectObject(src,this->hbitmap);
#
BitBlt(hdc,x,y,w,h,src,0,0,mode);
#
DeleteDC(src);
#
}
#
#
#
void DrawTransparent(HDC hdc,COLORREF transparentColor=RGB(255,255,255),int x=0,int y=0){
#
DrawTransparentBitmap(hdc,this->hbitmap,x,y,transparentColor);
#
}
#
#
//Save to the specified file
#
void SaveToFile(char* file){
#
BITMAPINFO* bmi=CreateBitmapInfoStruct(this->hbitmap);
#
CreateBMPFile(file,bmi,this->hbitmap,GetDC(GetDesktopWindow()));
#
}
#
};
void main()
{
Bitmap bitmap;
bitmap.SaveToFile("123.bmp");
}
Если есть легче способ, то скажите плыз)
Оформите, пожалуйста, нормально код. Без этих ужасных # через строчку.
спасибо! Помогли! Юзал поиск но ничё не нашёл( Вы мне предьявили отличные ссылки. Спс! +
Вот мой код:
Цитата:
void screen()
{
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
HDC scrdc, memdc;
HBITMAP membit;
scrdc = GetDC(0);
int Height, Width;
Height = GetSystemMetrics(SM_CYSCREEN);
Width = GetSystemMetrics(SM_CXSCREEN);
memdc = CreateCompatibleDC(scrdc);
membit = CreateCompatibleBitmap(scrdc, Width, Height);
SelectObject(memdc, membit);
BitBlt(memdc, 0, 0, Width, Height, scrdc, 0, 0, SRCCOPY);
HBITMAP hBitmap;
hBitmap =(HBITMAP) SelectObject(memdc, membit);
Gdiplus::Bitmap bitmap(hBitmap, NULL);
bitmap.Save(L"111.png", &png);
DeleteObject(hBitmap);
//GdiplusShutdown(gdiplusToken);
// return 0;
}
{
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
HDC scrdc, memdc;
HBITMAP membit;
scrdc = GetDC(0);
int Height, Width;
Height = GetSystemMetrics(SM_CYSCREEN);
Width = GetSystemMetrics(SM_CXSCREEN);
memdc = CreateCompatibleDC(scrdc);
membit = CreateCompatibleBitmap(scrdc, Width, Height);
SelectObject(memdc, membit);
BitBlt(memdc, 0, 0, Width, Height, scrdc, 0, 0, SRCCOPY);
HBITMAP hBitmap;
hBitmap =(HBITMAP) SelectObject(memdc, membit);
Gdiplus::Bitmap bitmap(hBitmap, NULL);
bitmap.Save(L"111.png", &png);
DeleteObject(hBitmap);
//GdiplusShutdown(gdiplusToken);
// return 0;
}
Если делать скрин из игры, то выходит чёрный скрин. А если с рабочего стола то всё супер.
скриншет участка экрана.
HBITMAP WINAPI GetScreenBitmap (LPCRECT pRect)
{
HDC hDC;
HDC hMemDC;
HBITMAP hNewBitmap = NULL;
if ( (hDC = ::GetDC (NULL)) != NULL )
{
if ( (hMemDC = ::CreateCompatibleDC (hDC)) != NULL )
{
if ( (hNewBitmap = ::CreateCompatibleBitmap (hDC, pRect->right - pRect->left, pRect->bottom - pRect->top)) != NULL )
{
HBITMAP hOldBitmap = (HBITMAP)::SelectObject(hMemDC, hNewBitmap);
::BitBlt (hMemDC, 0, 0, pRect->right - pRect->left, pRect->bottom - pRect->top,
hDC, pRect->left, pRect->top, SRCCOPY);
::SelectObject (hMemDC, (HGDIOBJ) hOldBitmap);
}
::DeleteDC (hMemDC);
}
::ReleaseDC (NULL, hDC);
}
return hNewBitmap;
}
software и directx всё норм, с opengl чёрный экран
На засыпку - как сделать уменьшенную копию?)
StretchBlt,наверное!А если очень хочется,то написать функцию уменьшения самому:)
сойдёт)) только помогите всунуть его в мой код:)
Цитата:
StretchBlt(memdc, 0, 0, Width, Height, scrdc, 0, 0, Width/2, Height/2, SRCCOPY );
Если не ошибаюсь)
сделал) работает, в 3 раза уменьшает, НО, цвета насыщенными сильно становятся, буд-то он пиксили вбивает друг-в-друга
ладно, с качеством проехали, что делать с Opengl?
Молодец,что сделал,а,чтобы не ошибаться(быть уверенным наверняка:)),пройди по ссылочке у меня в подписи и там почитай про StretchBlt
Так, для информации, в OpenGL помнится была функция для качественного масштабирования.