Get image from clipboard.

Get image from clipboard.

GetClipboardData, SetPixel, BITMAPV5HEADER

See version :

Pas de dépendances

Download :

#include <windows.h>
#include <stdio.h>

void Dessiner(int width,int height,const char* flux)
{
    int i,j,curs;
    HWND Hcon = GetConsoleWindow();
    HDC Hdc = GetDC(Hcon);  
    for(curs=0,j=height-1;j>=0;j--)
    {
        for(i=0;i<width;i++,curs+=4)
        {
            COLORREF COLOR = RGB(flux[curs+2],flux[curs+1],flux[curs]);
            SetPixel(Hdc,i,j,COLOR);
        }
    }
    ReleaseDC(Hcon, Hdc);
}

int main(void)
{
    if(OpenClipboard(NULL))
    {
        HANDLE h;
        h = GetClipboardData(CF_DIBV5);
        if(h)
        {
            BITMAPV5HEADER head;
            char *brut = (char *)GlobalLock(h);
            head = *((BITMAPV5HEADER*)brut);
            Dessiner(head.bV5Width,head.bV5Height,brut+head.bV5Size);
            GlobalUnlock(h);
            CloseClipboard();
        }
        else
            printf("Pas d'image dans le presse papier\n");
        CloseClipboard();
    }
    return 0;
}




Explanations

	No explanations yet.