本文整理汇总了C++中Pixel类的典型用法代码示例。如果您正苦于以下问题:C++ Pixel类的具体用法?C++ Pixel怎么用?C++ Pixel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Pixel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool Pixel::operator==(Pixel &pixel){
return (this->empty == pixel.empty && (
this->Red() == pixel.Red()
&& this->Green() == pixel.Green()
&& this->Blue() == pixel.Blue()
));
}
示例2:
void img::PixMat::histogram(std::vector<int>& result) const {
result.resize(Pixel::NUM_COLOR);
for (std::size_t i = 0; i < size(); i++) {
const Pixel p = operator[](i);
result[p.luminance()]++;
}
}
示例3: writeSprite
bool SavePartSprite::writeSprite(Surface &sprite) const {
// The sprite's dimensions have to fit
if (((uint32)sprite.getWidth()) != _width)
return false;
if (((uint32)sprite.getHeight()) != _height)
return false;
if (_trueColor) {
if (sprite.getBPP() <= 1)
return false;
Graphics::PixelFormat pixelFormat = g_system->getScreenFormat();
const byte *data = _dataSprite;
Pixel pixel = sprite.get();
for (uint32 i = 0; i < (_width * _height); i++, ++pixel, data += 3)
pixel.set(pixelFormat.RGBToColor(data[0], data[1], data[2]));
} else {
if (sprite.getBPP() != 1)
return false;
memcpy(sprite.getData(), _dataSprite, _spriteSize);
}
return true;
}
示例4: contains
bool PixelIterator::contains(const Pixel& pix) {
return pix.x() >= _box.min_corner().x() &&
pix.x() < _box.max_corner().x() &&
pix.y() >= _box.min_corner().y() &&
pix.y() < _box.max_corner().y();
}
示例5: in_file
int DataProcessor::load_train_result(const string &name)
{
map<int, Pixel> label_color;
ifstream in_file(name.c_str());
if (!in_file)
{
return -1;
}
string line;
while (getline(in_file, line))
{
vector<string> fields;
split_string(line, '\t', fields);
Pixel pixel;
pixel._pixel_size = 3;
char pixel_str[3];
pixel_str[0] = (unsigned char)atoi(fields[3].c_str());
pixel_str[1] = (unsigned char)atoi(fields[4].c_str());
pixel_str[2] = (unsigned char)atoi(fields[5].c_str());
pixel.set_data(pixel_str);
int label = atoi(fields[6].c_str());
if (label_color.find(label) == label_color.end())
{
label_color[label] = pixel;
}
set_pixel(_picture, atoi(fields[0].c_str()), label_color[label]);
}
in_file.close();
return 0;
}
示例6: get_grey
/**
* @return returns the Pixels average gray value
*/
inline Pixel<T> get_grey() const {
Pixel<T> p = Pixel<T>(*this);
p.grey();
return p;
}
示例7: main
int main()
{
cout << Pixel::GetK() << endl;
{
cout << "Урок 6. Наследование классов." << endl;
cout << "-----------------------------" << endl;
Pixel a(10,20, Pixel::red);
cout << "Pixel a: "; a.Print(); cout << endl;
cout << Pixel::GetK() << endl;
Pixel b(Point(30,40), Pixel::blue);
cout << "Pixel b: "; b.Print(); cout << endl;
cout << Pixel::GetK() << endl;
b.SetColor(Pixel::green);
b.Move(10,20);
cout << "Pixel b: "; b.Print(); cout << endl;
cout << "Dist =" << a.Dist(b) <<endl;
cout << "Color of Pixel b = " << b.GetColor() << endl;
Pixel c = a;
cout << "Pixel c = "; c.Print(); cout << endl;
}
cout << Pixel::GetK() << endl;
return 0;
}
示例8: range_error
/**
* Mathematical operation /
* if the size of the left hand side object is 0 the right hand side
* else the size of both pixels has to be the same
*/
Pixel<T> operator/=(const Pixel<T> &rhs) {
if(size_ == rhs.size()) {
for(unsigned char i = 0; i < size_; ++i) {
pixel_[i] /= rhs.get_pixel(i);
validate_value(pixel_[i]);
}
return *this;
} else if(size_ == 0) {
size_ = rhs.size();
delete[] pixel_;
T *temp = new T[size_];
for(unsigned char i = 0; i < size_; ++i) {
temp[i] = rhs.get_pixel(i);
}
pixel_ = temp;;
return *this;
}
std::ostringstream ss;
ss << "A Division between pixels can only happen when they have the same "
<< "size!\t LHS: " << size_ << "\tRHS: "<< rhs.size() << '\n';
throw std::range_error(ss.str());
}
示例9: ofBackground
void GenericClientManager::draw()
{
ofBackground(50);
ofSetColor(255,255,255);
if (enableDraw) {
cam.begin();
if (showAxis) {
//axis
ofSetColor(255,0,0);
ofSetLineWidth(3);
ofLine(0, 0, 0, 100, 0, 0);
ofSetColor(0,255,0);
ofLine(0, 0, 0, 0, 100, 0);
ofSetColor(0,0,255);
ofLine(0, 0, 0, 0, 0, 100);
//axis
}
glPushMatrix();
//ofScale(5,5,5);
float width = (float) ofGetWidth();
float height = (float) ofGetHeight();
vector<Pixel*>::iterator it = this->pixelsFast->begin();
while (it!=this->pixelsFast->end())
{
Pixel* px = *it;
px->draw();
it++;
}
glPopMatrix();
cam.end();
}
}
示例10:
Pixel::Pixel(Pixel &p)
{
this->_r = p.getR();
this->_g = p.getG();
this->_b = p.getB();
this->_a = p.getA();
}
示例11: Pixel
Pixel Pixel::copy() {
Pixel *p = new Pixel();
p->setR(r);
p->setG(g);
p->setB(b);
return *p;
}
示例12:
bool Pixel::operator==(Pixel &pxArg)
{
if(this->GetRed() == pxArg.GetRed() && this->GetRed() == pxArg.GetRed() && this->GetRed() == pxArg.GetRed())
return true;
else
return false;
}
示例13: Pixel
/**
* Copy Constructor
*/
Pixel(const Pixel<T> ©) {
size_ = copy.size();
pixel_ = new T[size_]();
for(int i = 0; i < size_; ++i) {
pixel_[i] = copy.get_pixel(i);
}
}
示例14:
bool operator==(const Pixel<T>& p1, const Pixel<T>& p2) {
if (p1.nbChannels() != p2.nbChannels())
return false;
for (unsigned int i=0; i<p1.nbChannels(); ++i)
if (p1[i] != p2[i])
return false;
return true;
}
示例15: destruct
int PixelBinder::destruct(lua_State* L)
{
void* ptr = *(void**)lua_touserdata(L, 1);
Pixel* bitmap = static_cast<Pixel*>(ptr);
bitmap->unref();
return 0;
}