Project

General

Profile

Revision 113

added macros to easen work

View differences:

lab5/graphics.h
4 4
#include <lcom/lcf.h>
5 5
#include <stdint.h>
6 6

  
7
#define GET_RED(n) (0xFF & (n >> 16))
8
#define GET_GRE(n) (0xFF & (n >>  8))
9
#define GET_BLU(n) (0xFF & (n      ))
10
#define SET_RED(n) ((n&0xFF) << 16)
11
#define SET_GRE(n) ((n&0xFF) <<  8)
12
#define SET_BLU(n) ((n&0xFF)      )
13
#define SET_COLOR(r,g,b) (SET_RED(r) | SET_GRE(g) | SET_BLU(b))
14

  
7 15
int (get_permission)(unsigned int base_addr, unsigned int size);
8 16

  
9 17
int (get_permissions_first_mbyte)(void);
lab5/lab5.c
193 193
            if(get_bytes_pixel() == 1){
194 194
                color = (first + (row * no_rectangles + col) * step) % (1 << get_bits_pixel());
195 195
            }else{
196
                R = (0xFF&(first>>16) + col*step) % (1 << get_RedMaskSize());
197
                G = (0xFF&(first>> 8) + row*step) % (1 << get_GreenMaskSize());
198
                B = (0xFF&(first    ) + (col+row)*step) % (1 << get_BlueMaskSize());
199
                color = (R<<16) | (G<<8) | (B);
196
                R = (GET_RED(first) + col*step) % (1 << get_RedMaskSize());
197
                G = (GET_GRE(first) + row*step) % (1 << get_GreenMaskSize());
198
                B = (GET_BLU(first) + (col+row)*step) % (1 << get_BlueMaskSize());
199
                color = SET_COLOR(R,G,B);
200 200
            }
201 201
            if (vg_draw_rectangle(col*W,row*H,W,H,color)) {
202 202
                if (vg_exit()) {

Also available in: Unified diff