Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "bmp.h"
- void bmp_gray(bmp_image image)
- {
- unsigned int i, j, a , b;
- /* Получаем линейные размеры изображения */
- unsigned int w = image.header.width;
- unsigned int h = image.header.height;
- bmp_image image2;
- image2.pixel_array = (double*)malloc(3 * (w + 4) * (h + 4) * sizeof(double));
- for (i = 0; i < h; i++) {
- for(j = 0; j < w; j++) {
- image2.pixel_array[0 * h * w + i * w + j] = image.pixel_array[0 * h * w + i * w + j];
- image2.pixel_array[1 * h * w + i * w + j] = image.pixel_array[1 * h * w + i * w + j];
- image2.pixel_array[2 * h * w + i * w + j] = image.pixel_array[2 * h * w + i * w + j];
- }
- }
- for (i = 0; i < w; i++) {
- for(j = 0; j < h; j++) {
- image.pixel_array[0 * h * w + i * w + j] = image2.pixel_array[0 * h * w + i * h + (w * i - j)];
- image.pixel_array[1 * h * w + i * w + j] = image2.pixel_array[1 * h * w + i * h + (w * i - j)];
- image.pixel_array[2 * h * w + i * w + j] = image2.pixel_array[2 * h * w + i * h + (w * i - j)];
- }
- }
- /* for (i = h-w; i < h; i++) {
- for(j = 0; j < h; j++) {
- image.pixel_array[0 * h * w + i * w + j] = image2.pixel_array[0 * h* w + j * w + (w + 1 + i)];
- image.pixel_array[1 * h * w + i * w + j] = image2.pixel_array[1 * h* w + j * w + (w + 1 + i)];
- image.pixel_array[2 * h * w + i * w + j] = image2.pixel_array[2 * h* w + j * w + (w + 1 + i)];
- }
- } */
- free(image2.pixel_array);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement