Pixels::x, etc gives unknown return type?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
zacwitte

Pixels::x, etc gives unknown return type?

Post by zacwitte »

this is my function to read each pixel of a greyscale image into a vector:

Starting on line 79:

Code: Select all

int ReadPGM::readImage(char *filename, vector<double> &pixelData) {
	Magick::Image image;
	image.read(filename);
	Magick::Pixels view(image);
	int x = view.x; //testing
	MagickLib::PixelPacket *pixels = view.getConst(view.x, view.y, view.columns, view.rows);
	
	//TODO: if there's an error, return -1
	
	for (unsigned int row=0; row < view.rows; row++) {
		for (unsigned int col=0; col < view.columns; col++ ) {
			Magick::Color color(pixels[row * view.rows + col]);
			pixelData[row * view.rows + col] = Magick::Color::scaleQuantumToDouble(color.blueQuantum());
			cout << pixels[row][col];
		}
		cout << endl;
	}
	
	return 1;
}
These are the errors I'm getting:

Code: Select all

g++ -I/sw/include -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"ReadPGM.d" -MT"ReadPGM.d" -o"ReadPGM.o" "../ReadPGM.cpp"
../ReadPGM.cpp: In member function 'int ReadPGM::readImage(char*, std::vector<double, std::allocator<double> >&)':
../ReadPGM.cpp:83: error: argument of type 'int (Magick::Pixels::)()const' does not match 'int'
../ReadPGM.cpp:84: error: no matching function for call to 'Magick::Pixels::getConst(<unknown type>, <unknown type>, <unknown type>, <unknown type>)'
/sw/include/Magick++/Pixels.h:37: note: candidates are: const MagickLib::PixelPacket* Magick::Pixels::getConst(int, int, unsigned int, unsigned int)
../ReadPGM.cpp:88: error: invalid use of member (did you forget the '&' ?)
../ReadPGM.cpp:89: error: invalid use of member (did you forget the '&' ?)
../ReadPGM.cpp:90: error: invalid use of member (did you forget the '&' ?)
../ReadPGM.cpp:91: error: invalid use of member (did you forget the '&' ?)
../ReadPGM.cpp:92: error: no match for 'operator[]' in '*((+(row * 8u)) + pixels)[col]'
../ReadPGM.cpp:83: warning: unused variable 'x'
This is the method I gleaned from reading the Pixel.h documentation and example, but there's probably a better way of doing it...? Any enlightenment appreciated.
zacwitte

Re: Pixels::x, etc gives unknown return type?

Post by zacwitte »

bump? please?
zacwitte

Re: Pixels::x, etc gives unknown return type?

Post by zacwitte »

ahh I thought Pixels::x was a property, not a function, dumb mistake I guess. I wish these things were documented!!
Post Reply