Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <intrin.h>
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <vector>
- #include <ctime>
- #include "lodepng.cpp"
- #include "lodepng.h"
- void negateImage(const char* in_filename, const char* out_filename) {
- // Загружаем изображение
- unsigned error;
- unsigned char* image;
- unsigned width, height;
- error = lodepng_decode24_file(&image, &width, &height, in_filename);
- if (error) {
- cerr << "Failed to load image: " << lodepng_error_text(error) << endl;
- return;
- }
- // Фильтр негатива
- for (unsigned y = 0; y < height; y++) {
- for (unsigned x = 0; x < width; x++) {
- unsigned index = (y * width + x) * 3;
- image[index + 0] = 255 - image[index + 0];
- image[index + 1] = 255 - image[index + 1];
- image[index + 2] = 255 - image[index + 2];
- }
- }
- // Сохраняем изображение
- error = lodepng_encode24_file(out_filename, image, width, height);
- if (error) {
- cerr << "Failed to save image: " << lodepng_error_text(error) << endl;
- return;
- }
- // Освобождаем память
- free(image);
- }
- void userConsistentNegate() {
- // Задаем имена входного и выходного файлов
- const char* in_filename = "input.png";
- const char* out_filename = "output.png";
- // Фильтр негатива
- negateImage(in_filename, out_filename);
- }
- int main() {
- userConsistentNegate();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement