I am using stb_image stb_image_write and CImg with following code
int width, height, bpp;
img = stbi_load(imgPath, &width, &height, &bpp, 3);
CImg<unsigned char> cimg(img, width, height, 1, bpp);
CImg<unsigned char> wimg(width, 10, 1, 3, 0);
cimg.append(wimg,'y');
cimg.display();
stbi_write_png("save.png", width, height, 3, cimg, width * 3);
It simply creating black line with 10 pixel and appending to bottom of image when I display this it works fine but when I save it showing distorted
I need to add border at bottom am I doing something wrong or any better way to do it ?
Below code works fine read image with stb do some change in cimg and save with stb it overlay small image to big one
int width, height, bpp;
int width2, height2, bpp2;
CImg<unsigned char> gradient(img1, bpp, width, height, 1);
CImg<unsigned char> overlay(img2, bpp2, width2, height2, 1);
CImg<unsigned char> gradient(img1, width, height, bpp, 1);
CImg<unsigned char> overlay(img2, width2, height2, bpp2, 1);
gradient.draw_image(0, 0, overlay);
stbi_write_png("gradient.png", width, height, 3, gradient, width * 3);