当前位置: 首页>>代码示例>>C++>>正文


C++ ofPixels_::mirror方法代码示例

本文整理汇总了C++中ofPixels_::mirror方法的典型用法代码示例。如果您正苦于以下问题:C++ ofPixels_::mirror方法的具体用法?C++ ofPixels_::mirror怎么用?C++ ofPixels_::mirror使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ofPixels_的用法示例。


在下文中一共展示了ofPixels_::mirror方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getNumChannels

void ofPixels_<PixelType>::mirrorTo(ofPixels_<PixelType> & dst, bool vertically, bool horizontal) const{
	if(&dst == this){
		dst.mirror(vertically,horizontal);
		return;
	}

	if (!vertically && !horizontal){
		dst = *this;
		return;
	}

	int bytesPerPixel = getNumChannels();
	dst.allocate(width, height, getPixelFormat());

	if(vertically && !horizontal){
		auto dstLines = dst.getLines();
		auto lineSrc = getConstLines().begin();
		auto line = --dstLines.end();
		auto stride = line.getStride();

		for(; line>=dstLines.begin(); --line, ++lineSrc){
			memcpy(line.begin(), lineSrc.begin(), stride);
		}
	}else if (!vertically && horizontal){
		int wToDo = width/2;
		int hToDo = height;
		for (int i = 0; i < wToDo; i++){
			for (int j = 0; j < hToDo; j++){
				int pixelb = i;
				int pixela = j*width + i;
				for (int k = 0; k < bytesPerPixel; k++){
					dst[pixela*bytesPerPixel + k] = pixels[pixelb*bytesPerPixel + k];
					dst[pixelb*bytesPerPixel + k] = pixels[pixela*bytesPerPixel + k];

				}
			}
		}
	} else {
		// I couldn't think of a good way to do this in place.  I'm sure there is.
		mirrorTo(dst,true, false);
		dst.mirror(false, true);
	}

}
开发者ID:cpietsch,项目名称:cordova-plugin-opcvExample,代码行数:44,代码来源:ofPixels.cpp

示例2: getNumChannels

void ofPixels_<PixelType>::mirrorTo(ofPixels_<PixelType> & dst, bool vertically, bool horizontal) const{
	if(&dst == this){
		dst.mirror(vertically,horizontal);
		return;
	}

	if (!vertically && !horizontal){
		dst = *this;
		return;
	}

	int bytesPerPixel = getNumChannels();

	if (! (vertically && horizontal)){
		int wToDo = horizontal ? width/2 : width;
		int hToDo = vertically ? height/2 : height;

		for (int i = 0; i < wToDo; i++){
			for (int j = 0; j < hToDo; j++){

				int pixelb = (vertically ? (height - j - 1) : j) * width + (horizontal ? (width - i - 1) : i);
				int pixela = j*width + i;
				for (int k = 0; k < bytesPerPixel; k++){
					dst[pixela*bytesPerPixel + k] = pixels[pixelb*bytesPerPixel + k];
					dst[pixelb*bytesPerPixel + k] = pixels[pixela*bytesPerPixel + k];

				}
			}
		}
	} else {
		// I couldn't think of a good way to do this in place.  I'm sure there is.
		mirrorTo(dst,true, false);
		dst.mirror(false, true);
	}

}
开发者ID:,项目名称:,代码行数:36,代码来源:


注:本文中的ofPixels_::mirror方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。