Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int TAMANHO_DA_LINHA = 800;
- const int TAMANHO_DA_COLUNA = 600;
- const int CORES = 4;
- extern char* cBegin; // Cbegin é a matriz e tem tamanho 800 * 600 * 4
- void DrawFilledRectangle(int x0, int y0, int x1, int y1, char R, char G, char B, char A) {
- // TODO: Verificar se os valores solicitados estão dentro da matriz
- // Como cada pixel é composto de quatro bytes temos uma matriz assim:
- // | R G B A | R G B A | R G B A | ...
- // | R G B A | R G B A | R G B A | ...
- // | R G B A | R G B A | R G B A | ...
- // lembrar que Cbegin é o ponteiro para o começo da matriz, ou seja, ele aponta pra 0,0
- for (int linha = y0; linha < y1; linha++) {
- for (int coluna = x0; coluna < x1; coluna++) {
- int posicao_inicial = ((TAMANHO_DA_LINHA * linha) + coluna) * CORES;
- cBegin[posicao_inicial] = R;
- cBegin[posicao_inicial + 1] = G;
- cBegin[posicao_inicial + 2] = B;
- cBegin[posicao_inicial + 3] = A;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement