Ir ao conteúdo

Posts recomendados

Postado

olá pessoal ,   alguém me ajuda nesse exercício ,   preciso criar um bitmap e gravar ele em um arquivo ou apenas guarda-lo no hd ,  tenho esse código pronto que consegue criar o bitmap , que por enquanto apenas copia o que está na tela ,  mas depois pretendo criar esse bitmap com funções ,  e para rodar esse código precisa criar um projeto , e como estou usando o codeblocks , precisa clicar em file / new / project / win32GUI e ali depois de criar o projeto clique do lado esquerdo no projeto e em source e main , e delete esse código que está ali  e coloque esse aqui  :

#if defined(UNICODE) && !defined(_UNICODE)
    #define _UNICODE
#elif defined(_UNICODE) && !defined(UNICODE)
    #define UNICODE
#endif

#include <tchar.h>
#include <windows.h>
#include <math.h>
#include <iostream>                          /* biblioteca para entrada e saida               */
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cstring>
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

/*  Make the class name into a global variable  */
TCHAR szClassName[ ] = _T("Copiando Imagem Da Tela");
static int i,f;
int WINAPI WinMain (HINSTANCE hThisInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR lpszArgument,
                     int nCmdShow)
{
    HWND hwnd;               /* This is the handle for our window */
    MSG messages;            /* Here messages to the application are saved */
    WNDCLASSEX wincl;        /* Data structure for the windowclass */

    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
    wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
    wincl.cbSize = sizeof (WNDCLASSEX);

    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;                 /* No menu */
    wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
    wincl.cbWndExtra = 0;                      /* structure or the window instance */
    /* Use Windows's default colour as the background of the window */
    wincl.hbrBackground = (HBRUSH) 5/*COLOR_BACKGROUND*/;

    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&wincl))
        return 0;

    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           szClassName,         /* Classname */
           _T("Copiando Imagem Da Tela , e um triangulo "), /* Title Text */
           WS_OVERLAPPEDWINDOW, /* default window */
           CW_USEDEFAULT,       /* Windows decides the position */
           CW_USEDEFAULT,       /* where the window ends up on the screen */
           1024,                 /* The programs width */
           600,                 /* and height in pixels */
           HWND_DESKTOP,        /* The window is a child-window to desktop */
           NULL,                /* No menu */
           hThisInstance,       /* Program Instance handler */
           NULL                 /* No Window Creation data */
           );

    /* Make the window visible on the screen */
    ShowWindow (hwnd, nCmdShow);

    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&messages, NULL, 0, 0))
    {
        /* Translate virtual-key messages into character messages */
        TranslateMessage(&messages);
        /* Send message to WindowProcedure */
        DispatchMessage(&messages);
    }

    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return messages.wParam;
}

/*  This function is called by the Windows function DispatchMessage()  */

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    HDC tela ;
    POINT pt;
    COLORREF clrf;
    static TCHAR frase[] = _T("Tecle ESC Para Sair !");
    PAINTSTRUCT ps ;
    int j,w;
    tela = GetDC (hwnd) ;
    switch (message)            /* handle the messages */
    {
        case WM_KEYDOWN:
            if (wParam == VK_ESCAPE) //  se pressionar a tecla ESC
                PostQuitMessage (0) ;
        case WM_PAINT :
            tela = BeginPaint (hwnd, &ps) ;
            TextOut(tela, 650, 50, frase, _tcslen(frase));// escreve mensagem na tela*/
            MoveToEx(tela,  static_cast<int>(sin(i*3.141615/180)*100+700),
                            static_cast<int>(cos(i*3.141615/180)*100+250),NULL) ;//posição de inicio do triangulo
            for(j=1;j<4;j++)
                LineTo(tela,static_cast<int>(sin((i+ j*120+00)*3.141615/180)*100+700) ,
                            static_cast<int>(cos((i+ j*120+00)*3.141615/180)*100+250));//vai para essas posições

            TextOut(tela, 650, 50, frase, _tcslen(frase));// escreve mensagem na tela
            i++;                               /* girar o triangulo */
            if(i>360)i=0;
            InvalidateRect (hwnd, NULL, TRUE) ;//limpa a tela*/
            EndPaint (hwnd, &ps) ;
            tela = GetDC(0);    /* precisa para pegar a cor */
            if(f>1150)f=0;
            else f++;
            for(w=0; w<50; w++)
                for(j=0; j<50; j++){
                    clrf=GetPixel(tela,w+f,j);/* pega a cor dessa posição da tela */
                    SetPixel(tela,w+1100,j+350,clrf);
                }

            /*
                aqui nessa parte
                quero salvar essas
                imagens em um arquivo

            */
            return 0 ;
        case WM_DESTROY:
            PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
            break;
        default:                      /* for messages that we don't deal with */
            return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
}

agradeço quem puder  ajudar    .

Crie uma conta ou entre para comentar

Você precisa ser um usuário para fazer um comentário

Criar uma conta

Crie uma nova conta em nossa comunidade. É fácil!

Crie uma nova conta

Entrar

Já tem uma conta? Faça o login.

Entrar agora

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...

LANÇAMENTO!

eletronica2025-popup.jpg


CLIQUE AQUI E BAIXE AGORA MESMO!