Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct bmp_image* rotate_right(const struct bmp_image* image){
- if(image == NULL || image->header == NULL || image->data == NULL){
- return NULL;
- }
- struct bmp_image* new_image = malloc(sizeof (struct bmp_image*));
- new_image->header = image->header;
- uint32_t old_w = image->header->width;
- uint32_t old_h = image->header->height;
- new_image->header->width = old_h;
- new_image->header->height = old_w;
- new_image->data = malloc(sizeof (struct pixel*)*old_w*old_h);
- uint32_t idx = 0;
- for(uint32_t i = 0; i < old_w; i++){
- for(uint32_t j = 0; j < old_h; j++){
- new_image->data[idx].green = image->data[ ((j+1)*old_w)-i-1 ].green;
- new_image->data[idx].red = image->data[ ((j+1)*old_w)-i-1 ].red;
- new_image->data[idx].blue = image->data[ ((j+1)*old_w)-i-1 ].blue;
- idx++;
- }
- }
- return new_image;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement