cimg

Compiling CImg with c++0x and MingW

会有一股神秘感。 提交于 2019-12-11 23:33:48
问题 I am trying to compile the following CImg sample code with std=c++0x and MingW: #include "CImg.h" using namespace cimg_library; int main() { CImg<unsigned char> img(640,400,1,3); img.fill(0); unsigned char purple[] = { 255,0,255 }; img.draw_text(100,100,"Hello World",purple); img.display("My first CImg code"); return 0; } When I compile using: g++ -std=c++0x HelloWorld.cpp -lgdi32 I get the following error: error: '_fileno' was not declared in this scope But when I compile without std=c++0x,

Overlaying images with CImg

半腔热情 提交于 2019-12-11 18:19:04
问题 It seems like this would be very easy, but I am having a lot of problems using the draw_image() function in CImg. Here is a snippet of code: CImg<unsigned char> landingScreen("desertSunset.bmp"), newGameBTN("newgame.pgm"); CImgDisplay main_disp(landingScreen,"Main Window"); landingScreen.draw_image(400,400,newGameBTN); I have tried about 8 of the overloaded functions for draw_image(), all to no avail. When I run the program, Main Window pops up with my desertSunset image, but that's it. I am

How to display few images (each in separate window) with CImg ?

≡放荡痞女 提交于 2019-12-10 22:55:56
问题 How can one display several images - each in one window - with the use of CImg ? When I try something like this cimg_library::CImg<unsigned char> image(s.c_str()); cimg_library::CImgDisplay main_disp(image, s.c_str() ); while (!main_disp.is_closed() ) main_disp.wait(); I have to close each window to get to the nect one and with this : cimg_library::CImg<unsigned char> image(s.c_str()); cimg_library::CImgDisplay main_disp(image, s.c_str() ) They disappear one after another. 回答1: The windows

Stack overflow error when reading jpeg image using Cimg library

谁说胖子不能爱 提交于 2019-12-10 11:45:16
问题 I'm getting stack overflow error when I'm trying to read jpg file using Cimg library while other format bmp is working file . How can i resolve it? #include"CImg.h" #include<stdio.h> using namespace cimg_library; int main() { CImg<unsigned char> src("d:\\sidimg.jpg"); int width = src.width(); int height = src.height(); unsigned char* ptr = src.data(0,0); int count=0; while(count!= width*height) { printf("%d",*ptr); ptr++; count++; } } 回答1: Sorry for the late answer, but you have to have

C++ fast way to save image from array of values

橙三吉。 提交于 2019-12-10 11:29:51
问题 Right now, I am using CImg. I am unable to use OpenCV due to this issue. My CImg code looks like this: cimg_library::CImg<float> img(512,512); cimg_forXYC(img,x,y,c) { img(x,y,c) = (array[x][y]); } //array contains all float values between 0/1 img.save(save.c_str()); //taking a lot of time By using clocks I was able to determine that the first step, the for loop takes 0-0.01 seconds. However, the second step, the saving of the image, takes 0.06 seconds, which is way too long due to the amount

C++ 16 bit grayscale gradient image from 2D array

落花浮王杯 提交于 2019-12-10 10:39:49
问题 I'm currently trying to build a 16 bit grayscale "gradient" image but my output looks weird so I'm clearly not understanding this correctly. I was hoping somebody could shine some knowledge on my issue. I think that the "bitmap" I write is wrong? But I'm not sure. #include "CImg.h" using namespace std; unsigned short buffer[1250][1250]; void fill_buffer() { unsigned short temp_data = 0; for (int i =0;i < 1250; i++) { for (int j =0 ;j < 1250;j++) { buffer[i][j] = temp_data; } temp_data += 20;

Using CImg: LNK1181: cannot open file “m.lib” on windows 7 x64

孤街浪徒 提交于 2019-12-08 05:46:04
问题 In the CImg Makefile I notice a flag "-lm" I think this points to the m.lib file. But for some reason it cannot find it during the Linking phase. I am compiling the code using the following command: nvcc -o FilledTriangles FilledTriangles.cu -I.. -O2 -lm -lgdi32 "nvcc" is just the nvidia CUDA compiler. It should function similar to g++ 回答1: -lm refers to "libm.so" In general, -lXYZ is a way of telling the linker that it should resolve the symbols in your compiled code against libXYZ.so (after

CImg X11 Linking Error using CLion and CMake

試著忘記壹切 提交于 2019-12-07 19:34:49
问题 I have a C++ project in CLion (Ubuntu) that uses the CImg library. Currently, I cannot get the project to build properly. I have included the CImg.h file in my main.cpp file. I get an output like seen here. I made sure I had X11 tools installed by running the following command in the terminal: sudo apt-get install libx11-dev In the question linked to above, there is an answer that states to add the following compiler options: -L/usr/X11R6/lib -lm -lpthread -lX11 However, I run into 2 problems

How to open PNG with CImg library without losing alpha channel?

萝らか妹 提交于 2019-12-05 06:09:05
问题 When I open png file: CImg<unsigned char> image("image.png"); ...I expect to get 4 channel (RGBA) image. But I always get 3 channel (RGB) image instead (even if the image is semitransparent): image.spectrum() returns 3 instead of 4. In my application, I always need to get 4 channels when I open PNG file. CImg looks like popular library with many useful features (some of which may be useful in the future in my image processing application), so I find it hard to believe that it is impossible to

How to open PNG with CImg library without losing alpha channel?

那年仲夏 提交于 2019-12-03 21:50:31
When I open png file: CImg<unsigned char> image("image.png"); ...I expect to get 4 channel (RGBA) image. But I always get 3 channel (RGB) image instead (even if the image is semitransparent): image.spectrum() returns 3 instead of 4. In my application, I always need to get 4 channels when I open PNG file. CImg looks like popular library with many useful features (some of which may be useful in the future in my image processing application), so I find it hard to believe that it is impossible to open PNG file with alpha channel without losing it. Any suggestions? If CImg is not very good tool for