reference

This documentation is automatically generated from the openFrameworks source code using doxygen and refers to the most recent release, version 0.12.0.

ofPixels.h
Go to the documentation of this file.
1#pragma once
2
3#include "ofUtils.h"
4#include "ofLog.h"
5#include "ofMath.h"
6#include "ofConstants.h"
7
8template<typename T>
9class ofColor_;
13
14#include <limits>
15
16
56
57
63
64
156
157#define OF_PIXELS_MONO OF_PIXELS_GRAY
158#define OF_PIXELS_R OF_PIXELS_GRAY
159#define OF_PIXELS_RG OF_PIXELS_GRAY_ALPHA
160
161template<typename T>
162std::string ofToString(const T & v);
163template<>
164std::string ofToString(const ofPixelFormat & pixelType);
165
166enum ofImageType: short;
167
169template <typename PixelType>
171public:
172
175 ofPixels_();
176 ~ofPixels_();
177 ofPixels_(const ofPixels_<PixelType> & mom);
179
180 template<typename SrcType>
182
183
188 void allocate(size_t w, size_t h, size_t channels);
189
202 void allocate(size_t w, size_t h, ofPixelFormat pixelFormat);
203
215 void allocate(size_t w, size_t h, ofImageType imageType);
216
221 bool isAllocated() const;
222
226 void clear();
227
230
231 template<typename SrcType>
233
237
238 void set(PixelType val);
239 void set(size_t channel,PixelType val);
240 void setFromPixels(const PixelType * newPixels,size_t w, size_t h, size_t channels);
241 void setFromPixels(const PixelType * newPixels,size_t w, size_t h, ofPixelFormat pixelFormat);
242 void setFromPixels(const PixelType * newPixels,size_t w, size_t h, ofImageType type);
243 void setFromExternalPixels(PixelType * newPixels,size_t w, size_t h, size_t channels);
244 void setFromExternalPixels(PixelType * newPixels,size_t w, size_t h, ofPixelFormat pixelFormat);
245 void setFromAlignedPixels(const PixelType * newPixels, size_t width, size_t height, size_t channels, size_t stride);
246 void setFromAlignedPixels(const PixelType * newPixels, size_t width, size_t height, ofPixelFormat pixelFormat, size_t stride);
248 void setFromAlignedPixels(const PixelType * newPixels, size_t width, size_t height, ofPixelFormat pixelFormat, std::vector<size_t> strides);
249
250 void swap(ofPixels_<PixelType> & pix);
251
255
260 void crop(size_t x, size_t y, size_t width, size_t height);
261
267 void cropTo(ofPixels_<PixelType> &toPix, size_t x, size_t y, size_t width, size_t height) const;
268
269 // crop to a new width and height, this reallocates memory.
270 void rotate90(int nClockwiseRotations);
271 void rotate90To(ofPixels_<PixelType> & dst, int nClockwiseRotations) const;
272 void mirrorTo(ofPixels_<PixelType> & dst, bool vertically, bool horizontal) const;
273
277 void mirror(bool vertically, bool horizontal);
278
286 bool resize(size_t dstWidth, size_t dstHeight, ofInterpolationMethod interpMethod=OF_INTERPOLATE_NEAREST_NEIGHBOR);
287
296
301 bool pasteInto(ofPixels_<PixelType> &dst, size_t x, size_t y) const;
302
303 bool blendInto(ofPixels_<PixelType> &dst, size_t x, size_t y) const;
304
307 void swapRgb();
308
312
316 PixelType * getData();
317 const PixelType * getData() const;
318 OF_DEPRECATED_MSG("Use getData instead",PixelType * getPixels());
319 OF_DEPRECATED_MSG("Use getData instead",const PixelType * getPixels() const);
320
328 size_t getPixelIndex(size_t x, size_t y) const;
329
331 ofColor_<PixelType> getColor(size_t x, size_t y) const;
332
334 ofColor_<PixelType> getColor(size_t index) const;
335
337 void setColor(size_t x, size_t y, const ofColor_<PixelType>& color);
338
340 void setColor(size_t index, const ofColor_<PixelType>& color);
341
343 void setColor(const ofColor_<PixelType>& color);
344
348 const PixelType& operator[](size_t pos) const;
349 PixelType& operator[](size_t pos);
350
354
356 size_t getWidth() const;
357
359 size_t getHeight() const;
360
362 size_t getBytesPerPixel() const;
363
368 size_t getBitsPerPixel() const;
369
377 size_t getBytesPerChannel() const;
378
386 size_t getBitsPerChannel() const;
387 size_t getBytesStride() const;
388
391 size_t getNumChannels() const;
392
393 size_t getTotalBytes() const;
394
395 size_t getNumPlanes() const;
396
397 ofPixels_<PixelType> getPlane(size_t plane);
398
413 ofPixels_<PixelType> getChannel(size_t channel) const;
414
416
420 size_t size() const;
421
426
430
434 void setChannel(size_t channel, const ofPixels_<PixelType> channelPixels);
435
439 void setImageType(ofImageType imageType);
440
441 void setNumChannels(size_t numChannels);
442
443 static size_t pixelBitsFromPixelFormat(ofPixelFormat format);
444 static size_t bytesFromPixelFormat(size_t w, size_t h, ofPixelFormat format);
445
449
450 typedef PixelType * iterator;
451 typedef const PixelType * const_iterator;
452 typedef PixelType * reverse_iterator;
453 typedef const PixelType * const_reverse_iterator;
462
464
466
467 struct ConstPixel{
468 ConstPixel(const PixelType * pixel, size_t bytesPerPixel, ofPixelFormat pixelFormat);
469 const ConstPixel& operator*() const;
470 const ConstPixel* operator->() const;
471 ConstPixel& operator++();
472 ConstPixel operator++(int);
473 ConstPixel operator+(size_t) const;
474 ConstPixel operator-(size_t) const;
475 ConstPixel operator+=(size_t);
476 bool operator!=(ConstPixel const& rhs) const;
477 bool operator<(ConstPixel const& rhs) const;
478 const PixelType & operator[](size_t idx) const;
479 size_t getComponentsPerPixel() const;
480 ofPixelFormat getPixelFormat() const;
481 ofColor_<PixelType> getColor() const;
482
483 using value_type = ConstPixel;
484 using iterator_category = std::forward_iterator_tag;
485 using difference_type = std::ptrdiff_t;
486 using pointer = const value_type*;
487 using reference = const value_type&;
488
489
490 private:
491 const PixelType * pixel;
492 size_t componentsPerPixel;
493 ofPixelFormat pixelFormat;
494 };
495
496 struct Pixel {
497 Pixel(PixelType * pixel, size_t bytesPerPixel, ofPixelFormat pixelFormat);
498 const Pixel& operator*() const;
499 const Pixel* operator->() const;
500 Pixel& operator++();
501 Pixel operator++(int);
502 Pixel& operator--();
503 Pixel operator--(int);
504 Pixel operator+(size_t) const;
505 Pixel operator-(size_t) const;
506 Pixel operator+=(size_t);
507 bool operator!=(Pixel const& rhs) const;
508 bool operator<(Pixel const& rhs) const;
509 Pixel & operator=(Pixel const& rhs);
510 Pixel & operator=(ConstPixel const& rhs);
511 PixelType & operator[](size_t idx);
512 const PixelType & operator[](size_t idx) const;
513 size_t getComponentsPerPixel() const;
514 ofPixelFormat getPixelFormat() const;
515 ofColor_<PixelType> getColor() const;
516
517 using value_type = Pixel;
518 using iterator_category = std::forward_iterator_tag;
519 using difference_type = std::ptrdiff_t;
520 using pointer = const value_type*;
521 using reference = const value_type&;
522
523 private:
524 PixelType * pixel;
525 size_t componentsPerPixel;
526 ofPixelFormat pixelFormat;
527 };
528
529 struct Pixels{
530 Pixels(PixelType * begin, PixelType * end, size_t componentsPerPixel, ofPixelFormat pixelFormat);
531 Pixels(Pixel begin, Pixel end);
532 Pixel begin();
533 Pixel end();
534 private:
535 PixelType * _begin;
536 PixelType * _end;
537 size_t componentsPerPixel;
538 ofPixelFormat pixelFormat;
539 };
540
541 struct Line {
542 Line(PixelType * _begin, size_t stride, size_t componentsPerPixel, size_t lineNum, ofPixelFormat pixelFormat);
543 const Line& operator*() const;
544 const Line* operator->() const;
545 Line& operator++();
546 Line operator++(int);
547 Line& operator--();
548 Line operator--(int);
549 Line operator+(size_t) const;
550 Line operator+=(size_t);
551 bool operator!=(Line const& rhs) const;
552 bool operator<(Line const& rhs) const;
553 bool operator>(Line const& rhs) const;
554 bool operator>=(Line const& rhs) const;
555 PixelType * begin();
556 PixelType * end();
557 const PixelType * begin() const;
558 const PixelType * end() const;
559 size_t getLineNum() const;
560 ofPixels_<PixelType> asPixels();
561 const ofPixels_<PixelType> asPixels() const;
562 size_t getStride() const;
563 Pixel getPixel(size_t pixel);
564 Pixels getPixels();
565 Pixels getPixels(size_t first, size_t numPixels);
566
567 using value_type = Line;
568 using iterator_category = std::forward_iterator_tag;
569 using difference_type = std::ptrdiff_t;
570 using pointer = const value_type*;
571 using reference = const value_type&;
572
573 private:
574 PixelType * _begin;
575 PixelType * _end;
576 size_t stride;
577 size_t componentsPerPixel;
578 size_t lineNum;
579 ofPixelFormat pixelFormat;
580 };
581
582 struct Lines{
583 Lines(PixelType * _begin, PixelType * _end, size_t stride, size_t componentsPerPixel, size_t lines, ofPixelFormat pixelFormat);
584
585 Line begin();
586
587 Line end();
588
589
590 private:
591 PixelType * _begin;
592 PixelType * _end;
593 size_t stride;
594 size_t componentsPerPixel;
595 size_t lines;
596 ofPixelFormat pixelFormat;
597 };
598
599 struct ConstPixels{
600 ConstPixels(const PixelType * begin, const PixelType * end, size_t componentsPerPixel, ofPixelFormat pixelFormat);
601 ConstPixels(const ConstPixel & begin, const ConstPixel & end);
602 ConstPixel begin() const;
603 ConstPixel end() const;
604 private:
605 const PixelType * _begin;
606 const PixelType * _end;
607 size_t componentsPerPixel;
608 ofPixelFormat pixelFormat;
609 };
610
611 struct ConstLine {
612 ConstLine(const PixelType * _begin, size_t stride, size_t componentsPerPixel, size_t lineNum, ofPixelFormat pixelFormat);
613 const ConstLine& operator*() const;
614 const ConstLine* operator->() const;
615 ConstLine& operator++();
616 ConstLine operator++(int);
617 ConstLine operator+(size_t) const;
618 ConstLine operator+=(size_t);
619 bool operator!=(ConstLine const& rhs) const;
620 bool operator<(ConstLine const& rhs) const;
621 const PixelType * begin() const;
622 const PixelType * end() const;
623 size_t getLineNum() const;
624 size_t getStride() const;
625 ConstPixel getPixel(size_t pixel) const;
626 ConstPixels getPixels() const;
627 ConstPixels getPixels(size_t first, size_t numPixels) const;
628
629 using value_type = ConstLine;
630 using iterator_category = std::forward_iterator_tag;
631 using difference_type = std::ptrdiff_t;
632 using pointer = const value_type*;
633 using reference = const value_type&;
634
635 private:
636 const PixelType * _begin;
637 const PixelType * _end;
638 size_t stride;
639 size_t componentsPerPixel;
640 size_t lineNum;
641 ofPixelFormat pixelFormat;
642 };
643
644 struct ConstLines{
645 ConstLines(const PixelType * _begin, const PixelType * _end, size_t stride, size_t componentsPerPixel, size_t lines, ofPixelFormat pixelFormat);
646
647 ConstLine begin() const;
648
649 ConstLine end() const;
650
651 private:
652 const PixelType * _begin;
653 const PixelType * _end;
654 size_t stride;
655 size_t componentsPerPixel;
656 size_t lines;
657 ofPixelFormat pixelFormat;
658 };
659
660 Line getLine(size_t line);
661 Lines getLines();
662 Lines getLines(size_t first, size_t numLines);
663 Pixels getPixelsIter();
664 ConstLine getConstLine(size_t line) const;
665 ConstLines getConstLines() const;
666 ConstLines getConstLines(size_t first, size_t numLines) const;
667 ConstPixels getConstPixelsIter() const;
668
670
671private:
672 static float bicubicInterpolate(const float *patch, float x,float y, float x2,float y2, float x3,float y3);
673
674 void copyFrom( const ofPixels_<PixelType>& mom );
675
676 template<typename SrcType>
677 void copyFrom( const ofPixels_<SrcType>& mom );
678
679 PixelType * pixels = nullptr;
680 size_t width = 0;
681 size_t height = 0;
682
683 //int channels; // 1, 3, 4 channels per pixel (grayscale, rgb, rgba)
684 size_t pixelsSize = 0;
685 bool bAllocated = false;
686 bool pixelsOwner = true; // if set from external data don't delete it
687 ofPixelFormat pixelFormat = OF_PIXELS_UNKNOWN;
688
689};
690
691
695
696
700
701// sorry for these ones, being templated functions inside a template i needed to do it in the .h
702// they allow to do things like:
703//
704// ofPixels pix;
705// ofFloatPixels pixf;
706// pix = pixf;
707
708template<typename PixelType>
709template<typename SrcType>
711 bAllocated = false;
712 pixelsOwner = false;
713 pixelsSize = 0;
714 pixels = nullptr;
715 width = 0;
716 height = 0;
717 pixelFormat = OF_PIXELS_UNKNOWN;
718 copyFrom( mom );
719}
720
721template<typename PixelType>
722template<typename SrcType>
724 copyFrom( mom );
725 return *this;
726}
727
728template<typename PixelType>
729template<typename SrcType>
731 if(mom.isAllocated()){
732 allocate(mom.getWidth(),mom.getHeight(),mom.getNumChannels());
733
734 const float srcMax = ( (sizeof(SrcType) == sizeof(float) ) ? 1.f : std::numeric_limits<SrcType>::max() );
735 const float dstMax = ( (sizeof(PixelType) == sizeof(float) ) ? 1.f : std::numeric_limits<PixelType>::max() );
736 const float factor = dstMax / srcMax;
737
738 if(sizeof(SrcType) == sizeof(float)) {
739 // coming from float we need a special case to clamp the values
740 for(size_t i = 0; i < mom.size(); i++){
741 pixels[i] = ofClamp(mom[i], 0, 1) * factor;
742 }
743 } else{
744 // everything else is a straight scaling
745 for(size_t i = 0; i < mom.size(); i++){
746 pixels[i] = mom[i] * factor;
747 }
748 }
749 }
750}
751//----------------------------------------------------------------------
752template<typename PixelType>
754 return pixels;
755}
756
757//----------------------------------------------------------------------
758template<typename PixelType>
760 return pixels + size();
761}
762
763//----------------------------------------------------------------------
764template<typename PixelType>
766 return pixels;
767}
768
769//----------------------------------------------------------------------
770template<typename PixelType>
772 return pixels + size();
773}
774
775//----------------------------------------------------------------------
776template<typename PixelType>
778 return pixels + (size() - 1);
779}
780
781//----------------------------------------------------------------------
782template<typename PixelType>
784 return pixels - 1;
785}
786
787//----------------------------------------------------------------------
788template<typename PixelType>
790 return pixels + (size() - 1);
791}
792
793//----------------------------------------------------------------------
794template<typename PixelType>
796 return pixels - 1;
797}
798
799//----------------------------------------------------------------------
800template<typename PixelType>
801inline ofPixels_<PixelType>::Pixel::Pixel(PixelType * pixel, size_t componentsPerPixel, ofPixelFormat pixelFormat)
802:pixel(pixel)
803,componentsPerPixel(componentsPerPixel)
804,pixelFormat(pixelFormat){
805
806}
807
808//----------------------------------------------------------------------
809template<typename PixelType>
811 return *this;
812}
813
814//----------------------------------------------------------------------
815template<typename PixelType>
817 return this;
818}
819
820//----------------------------------------------------------------------
821template<typename PixelType>
823 pixel += componentsPerPixel;
824 return *this;
825}
826
827//----------------------------------------------------------------------
828template<typename PixelType>
830 Pixel tmp(*this);
831 operator++();
832 return tmp;
833}
834
835//----------------------------------------------------------------------
836template<typename PixelType>
838 pixel -= componentsPerPixel;
839 return *this;
840}
841
842//----------------------------------------------------------------------
843template<typename PixelType>
845 Pixel tmp(*this);
846 operator--();
847 return tmp;
848}
849
850//----------------------------------------------------------------------
851template<typename PixelType>
853 return Pixel(pixel + componentsPerPixel * i, componentsPerPixel, pixelFormat);
854}
855
856//----------------------------------------------------------------------
857template<typename PixelType>
859 return Pixel(pixel - componentsPerPixel * i, componentsPerPixel, pixelFormat);
860}
861
862//----------------------------------------------------------------------
863template<typename PixelType>
865 pixel += componentsPerPixel * i;
866 return *this;
867}
868
869//----------------------------------------------------------------------
870template<typename PixelType>
871inline bool ofPixels_<PixelType>::Pixel::operator!=(Pixel const& rhs) const{
872 return pixel != rhs.pixel;
873}
874
875//----------------------------------------------------------------------
876template<typename PixelType>
877inline bool ofPixels_<PixelType>::Pixel::operator<(Pixel const& rhs) const{
878 return pixel < rhs.pixel;
879}
880
881//----------------------------------------------------------------------
882template<typename PixelType>
884 for(size_t i=0;i<componentsPerPixel;++i){
885 pixel[i] = rhs[i];
886 }
887 return *this;
888}
889
890//----------------------------------------------------------------------
891template<typename PixelType>
892inline typename ofPixels_<PixelType>::Pixel & ofPixels_<PixelType>::Pixel::operator=(ConstPixel const& rhs){
893 for(size_t i=0;i<componentsPerPixel;++i){
894 pixel[i] = rhs[i];
895 }
896 return *this;
897}
898
899//----------------------------------------------------------------------
900template<typename PixelType>
901inline PixelType & ofPixels_<PixelType>::Pixel::operator[](size_t idx){
902 return pixel[idx];
903}
904
905//----------------------------------------------------------------------
906template<typename PixelType>
907inline const PixelType & ofPixels_<PixelType>::Pixel::operator[](size_t idx) const{
908 return pixel[idx];
909}
910
911//----------------------------------------------------------------------
912template<typename PixelType>
914 return componentsPerPixel;
915}
916
917//----------------------------------------------------------------------
918template<typename PixelType>
920 return pixelFormat;
921}
922
923//----------------------------------------------------------------------
924template<typename PixelType>
927 switch(pixelFormat){
928 case OF_PIXELS_RGB:
929 c.set( pixel[0], pixel[1], pixel[2] );
930 break;
931 case OF_PIXELS_BGR:
932 c.set( pixel[2], pixel[1], pixel[0] );
933 break;
934 case OF_PIXELS_RGBA:
935 c.set( pixel[0], pixel[1], pixel[2], pixel[3] );
936 break;
937 case OF_PIXELS_BGRA:
938 c.set( pixel[2], pixel[1], pixel[0], pixel[3] );
939 break;
940 case OF_PIXELS_GRAY:
941 c.set( pixel[0] );
942 break;
944 c.set( pixel[0], pixel[0], pixel[0], pixel[1] );
945 break;
946 case OF_PIXELS_RGB565:
947 case OF_PIXELS_NV12:
948 case OF_PIXELS_NV21:
949 case OF_PIXELS_YV12:
950 case OF_PIXELS_I420:
951 case OF_PIXELS_YUY2:
952 case OF_PIXELS_UYVY:
953 case OF_PIXELS_Y:
954 case OF_PIXELS_U:
955 case OF_PIXELS_V:
956 case OF_PIXELS_UV:
957 case OF_PIXELS_VU:
959 default:
960 ofLogWarning() << "returning color not supported yet for " << ofToString(pixelFormat) << " format";
961 return 0;
962 break;
963 }
964
965 return c;
966}
967
968//----------------------------------------------------------------------
969template<typename PixelType>
970inline ofPixels_<PixelType>::Pixels::Pixels(PixelType * begin, PixelType * end, size_t componentsPerPixel, ofPixelFormat pixelFormat)
971:_begin(begin)
972,_end(end)
973,componentsPerPixel(componentsPerPixel)
974,pixelFormat(pixelFormat){}
975
976
977//----------------------------------------------------------------------
978template<typename PixelType>
979inline ofPixels_<PixelType>::Pixels::Pixels(Pixel begin, Pixel end)
980:_begin(&begin[0])
981,_end(&end[0])
982,componentsPerPixel(begin.getComponentsPerPixel())
983,pixelFormat(begin.getPixelFormat()){}
984
985//----------------------------------------------------------------------
986template<typename PixelType>
988 return Pixel(_begin,componentsPerPixel,pixelFormat);
989}
990
991//----------------------------------------------------------------------
992template<typename PixelType>
994 return Pixel(_end,componentsPerPixel,pixelFormat);
995}
996
997//----------------------------------------------------------------------
998template<typename PixelType>
999inline ofPixels_<PixelType>::Line::Line(PixelType * _begin, size_t stride, size_t componentsPerPixel, size_t lineNum, ofPixelFormat pixelFormat)
1000:_begin(_begin)
1001,_end(_begin+stride)
1002,stride(stride)
1003,componentsPerPixel(componentsPerPixel)
1004,lineNum(lineNum)
1005,pixelFormat(pixelFormat){}
1006
1007//----------------------------------------------------------------------
1008template<typename PixelType>
1010 return *this;
1011}
1012
1013//----------------------------------------------------------------------
1014template<typename PixelType>
1016 return this;
1017}
1018
1019//----------------------------------------------------------------------
1020template<typename PixelType>
1022 _begin = _end;
1023 _end = _begin + stride;
1024 ++lineNum;
1025 return *this;
1026}
1027
1028//----------------------------------------------------------------------
1029template<typename PixelType>
1031 Line tmp(*this);
1032 operator++();
1033 return tmp;
1034}
1035
1036//----------------------------------------------------------------------
1037template<typename PixelType>
1039 _end = _begin;
1040 _begin = _end - stride;
1041 --lineNum;
1042 return *this;
1043}
1044
1045//----------------------------------------------------------------------
1046template<typename PixelType>
1048 Line tmp(*this);
1049 operator--();
1050 return tmp;
1051}
1052
1053//----------------------------------------------------------------------
1054template<typename PixelType>
1056 return Line(_begin+stride*i,stride,componentsPerPixel,lineNum+i,pixelFormat);
1057}
1058
1059//----------------------------------------------------------------------
1060template<typename PixelType>
1062 _begin = _begin+stride*i;
1063 _end = _begin + stride;
1064 lineNum += i;
1065 return *this;
1066}
1067
1068//----------------------------------------------------------------------
1069template<typename PixelType>
1070inline bool ofPixels_<PixelType>::Line::operator!=(typename ofPixels_<PixelType>::Line const& rhs) const{
1071 return rhs._begin != _begin || rhs._end != _end || rhs.stride != stride || rhs.lineNum!=lineNum;
1072}
1073
1074//----------------------------------------------------------------------
1075template<typename PixelType>
1076inline bool ofPixels_<PixelType>::Line::operator<(typename ofPixels_<PixelType>::Line const& rhs) const{
1077 return _begin < rhs._begin;
1078}
1079
1080//----------------------------------------------------------------------
1081template<typename PixelType>
1082inline bool ofPixels_<PixelType>::Line::operator>(typename ofPixels_<PixelType>::Line const& rhs) const{
1083 return _begin > rhs._begin;
1084}
1085
1086//----------------------------------------------------------------------
1087template<typename PixelType>
1088inline bool ofPixels_<PixelType>::Line::operator>=(typename ofPixels_<PixelType>::Line const& rhs) const{
1089 return _begin >= rhs._begin;
1090}
1091
1092//----------------------------------------------------------------------
1093template<typename PixelType>
1095 return _begin;
1096}
1097
1098//----------------------------------------------------------------------
1099template<typename PixelType>
1101 return _end;
1102}
1103
1104//----------------------------------------------------------------------
1105template<typename PixelType>
1107 return _begin;
1108}
1109
1110//----------------------------------------------------------------------
1111template<typename PixelType>
1113 return _end;
1114}
1115
1116//----------------------------------------------------------------------
1117template<typename PixelType>
1118inline size_t ofPixels_<PixelType>::Line::getLineNum() const{
1119 return lineNum;
1120}
1121
1122//----------------------------------------------------------------------
1123template<typename PixelType>
1125 ofPixels_<PixelType> pixels;
1126 pixels.setFromExternalPixels(_begin,stride/componentsPerPixel,1,pixelFormat);
1127 return pixels;
1128}
1129
1130//----------------------------------------------------------------------
1131template<typename PixelType>
1133 ofPixels_<PixelType> pixels;
1134 pixels.setFromExternalPixels(_begin,stride/componentsPerPixel,1,pixelFormat);
1135 return pixels;
1136}
1137
1138//----------------------------------------------------------------------
1139template<typename PixelType>
1140inline size_t ofPixels_<PixelType>::Line::getStride() const{
1141 return stride;
1142}
1143
1144//----------------------------------------------------------------------
1145template<typename PixelType>
1147 return Pixel(_begin + (pixel*componentsPerPixel), componentsPerPixel, pixelFormat);
1148}
1149
1150//----------------------------------------------------------------------
1151template<typename PixelType>
1153 return Pixels(_begin,_end,componentsPerPixel,pixelFormat);
1154}
1155
1156//----------------------------------------------------------------------
1157template<typename PixelType>
1158inline typename ofPixels_<PixelType>::Pixels ofPixels_<PixelType>::Line::getPixels(size_t first, size_t numPixels){
1159 return Pixels(&getPixel(first)[0], &getPixel(first+numPixels)[0], componentsPerPixel, pixelFormat);
1160}
1161
1162//----------------------------------------------------------------------
1163template<typename PixelType>
1164inline ofPixels_<PixelType>::Lines::Lines(PixelType * _begin, PixelType * _end, size_t stride, size_t componentsPerPixel, size_t lines, ofPixelFormat pixelFormat)
1165:_begin(_begin)
1166,_end(_end)
1167,stride(stride)
1168,componentsPerPixel(componentsPerPixel)
1169,lines(lines)
1170,pixelFormat(pixelFormat){}
1171
1172//----------------------------------------------------------------------
1173template<typename PixelType>
1175 return Line(_begin,stride,componentsPerPixel,0,pixelFormat);
1176}
1177
1178//----------------------------------------------------------------------
1179template<typename PixelType>
1181 return Line(_end,stride,componentsPerPixel,lines,pixelFormat);
1182}
1183
1184
1185//----------------------------------------------------------------------
1186template<typename PixelType>
1188 return Line(pixels+(width*getNumChannels()*line), width*getNumChannels(), getNumChannels(), line,pixelFormat);
1189}
1190
1191//----------------------------------------------------------------------
1192template<typename PixelType>
1194 return Lines(begin(),end(),width*getNumChannels(),getNumChannels(),getHeight(),pixelFormat);
1195}
1196
1197//----------------------------------------------------------------------
1198template<typename PixelType>
1199inline typename ofPixels_<PixelType>::Lines ofPixels_<PixelType>::getLines(size_t first, size_t numLines){
1200 return Lines(getLine(first).begin(),getLine(first+numLines).begin(),width*getNumChannels(),getNumChannels(),numLines,pixelFormat);
1201}
1202
1203//----------------------------------------------------------------------
1204template<typename PixelType>
1206 return Pixels(begin(),end(),getNumChannels(),pixelFormat);
1207}
1208
1209//----------------------------------------------------------------------
1210template<typename PixelType>
1211inline ofPixels_<PixelType>::ConstPixel::ConstPixel(const PixelType * pixel, size_t componentsPerPixel, ofPixelFormat pixelFormat)
1212:pixel(pixel)
1213,componentsPerPixel(componentsPerPixel)
1214,pixelFormat(pixelFormat){
1215
1216}
1217
1218//----------------------------------------------------------------------
1219template<typename PixelType>
1221 return *this;
1222}
1223
1224//----------------------------------------------------------------------
1225template<typename PixelType>
1227 return this;
1228}
1229
1230//----------------------------------------------------------------------
1231template<typename PixelType>
1233 pixel += componentsPerPixel;
1234 return *this;
1235}
1236
1237//----------------------------------------------------------------------
1238template<typename PixelType>
1240 ConstPixel tmp(*this);
1241 operator++();
1242 return tmp;
1243}
1244
1245//----------------------------------------------------------------------
1246template<typename PixelType>
1248 return ConstPixel(pixel + componentsPerPixel * i, componentsPerPixel, pixelFormat);
1249}
1250
1251//----------------------------------------------------------------------
1252template<typename PixelType>
1254 return ConstPixel(pixel - componentsPerPixel * i, componentsPerPixel, pixelFormat);
1255}
1256
1257//----------------------------------------------------------------------
1258template<typename PixelType>
1260 pixel += componentsPerPixel * i;
1261 return *this;
1262}
1263
1264//----------------------------------------------------------------------
1265template<typename PixelType>
1266inline bool ofPixels_<PixelType>::ConstPixel::operator!=(ConstPixel const& rhs) const{
1267 return pixel != rhs.pixel;
1268}
1269
1270//----------------------------------------------------------------------
1271template<typename PixelType>
1272inline bool ofPixels_<PixelType>::ConstPixel::operator<(ConstPixel const& rhs) const{
1273 return pixel < rhs.pixel;
1274}
1275
1276//----------------------------------------------------------------------
1277template<typename PixelType>
1278inline const PixelType & ofPixels_<PixelType>::ConstPixel::operator[](size_t idx) const{
1279 return pixel[idx];
1280}
1281
1282//----------------------------------------------------------------------
1283template<typename PixelType>
1285 return componentsPerPixel;
1286}
1287
1288//----------------------------------------------------------------------
1289template<typename PixelType>
1291 return pixelFormat;
1292}
1293
1294//----------------------------------------------------------------------
1295template<typename PixelType>
1298 switch(pixelFormat){
1299 case OF_PIXELS_RGB:
1300 c.set( pixel[0], pixel[1], pixel[2] );
1301 break;
1302 case OF_PIXELS_BGR:
1303 c.set( pixel[2], pixel[1], pixel[0] );
1304 break;
1305 case OF_PIXELS_RGBA:
1306 c.set( pixel[0], pixel[1], pixel[2], pixel[3] );
1307 break;
1308 case OF_PIXELS_BGRA:
1309 c.set( pixel[2], pixel[1], pixel[0], pixel[3] );
1310 break;
1311 case OF_PIXELS_GRAY:
1312 c.set( pixel[0] );
1313 break;
1315 c.set( pixel[0], pixel[0], pixel[0], pixel[1] );
1316 break;
1317 case OF_PIXELS_RGB565:
1318 case OF_PIXELS_NV12:
1319 case OF_PIXELS_NV21:
1320 case OF_PIXELS_YV12:
1321 case OF_PIXELS_I420:
1322 case OF_PIXELS_YUY2:
1323 case OF_PIXELS_UYVY:
1324 case OF_PIXELS_Y:
1325 case OF_PIXELS_U:
1326 case OF_PIXELS_V:
1327 case OF_PIXELS_UV:
1328 case OF_PIXELS_VU:
1329 case OF_PIXELS_UNKNOWN:
1330 default:
1331 ofLogWarning() << "returning color not supported yet for " << ofToString(pixelFormat) << " format";
1332 return 0;
1333 break;
1334 }
1335
1336 return c;
1337}
1338
1339//----------------------------------------------------------------------
1340template<typename PixelType>
1341inline ofPixels_<PixelType>::ConstPixels::ConstPixels(const PixelType * begin, const PixelType * end, size_t componentsPerPixel, ofPixelFormat pixelFormat)
1342:_begin(begin)
1343,_end(end)
1344,componentsPerPixel(componentsPerPixel)
1345,pixelFormat(pixelFormat){}
1346
1347//----------------------------------------------------------------------
1348template<typename PixelType>
1349inline ofPixels_<PixelType>::ConstPixels::ConstPixels(const ConstPixel & begin, const ConstPixel & end)
1350:_begin(&begin[0])
1351,_end(&end[0])
1352,componentsPerPixel(begin.getComponentsPerPixel())
1353,pixelFormat(begin.getPixelFormat()){}
1354
1355//----------------------------------------------------------------------
1356template<typename PixelType>
1358 return ConstPixel(_begin,componentsPerPixel,pixelFormat);
1359}
1360
1361//----------------------------------------------------------------------
1362template<typename PixelType>
1364 return ConstPixel(_end,componentsPerPixel,pixelFormat);
1365}
1366
1367//----------------------------------------------------------------------
1368template<typename PixelType>
1369inline ofPixels_<PixelType>::ConstLine::ConstLine(const PixelType * _begin, size_t stride, size_t componentsPerPixel, size_t lineNum, ofPixelFormat pixelFormat)
1370:_begin(_begin)
1371,_end(_begin+stride)
1372,stride(stride)
1373,componentsPerPixel(componentsPerPixel)
1374,lineNum(lineNum)
1375,pixelFormat(pixelFormat){}
1376
1377//----------------------------------------------------------------------
1378template<typename PixelType>
1380 return *this;
1381}
1382
1383//----------------------------------------------------------------------
1384template<typename PixelType>
1386 return this;
1387}
1388
1389//----------------------------------------------------------------------
1390template<typename PixelType>
1392 _begin = _end;
1393 _end = _begin + stride;
1394 ++lineNum;
1395 return *this;
1396}
1397
1398//----------------------------------------------------------------------
1399template<typename PixelType>
1401 ConstLine tmp(*this);
1402 operator++();
1403 return tmp;
1404}
1405
1406//----------------------------------------------------------------------
1407template<typename PixelType>
1409 return ConstLine(_begin+stride*i,stride,componentsPerPixel,lineNum+i,pixelFormat);
1410}
1411
1412//----------------------------------------------------------------------
1413template<typename PixelType>
1415 _begin = _begin+stride*i;
1416 _end = _begin + stride;
1417 lineNum += i;
1418 return *this;
1419}
1420
1421//----------------------------------------------------------------------
1422template<typename PixelType>
1424 return rhs._begin != _begin || rhs._end != _end || rhs.stride != stride || rhs.lineNum!=lineNum;
1425}
1426
1427//----------------------------------------------------------------------
1428template<typename PixelType>
1430 return _begin < rhs._begin || _end < rhs._end;
1431}
1432
1433//----------------------------------------------------------------------
1434template<typename PixelType>
1436 return _begin;
1437}
1438
1439//----------------------------------------------------------------------
1440template<typename PixelType>
1442 return _end;
1443}
1444
1445//----------------------------------------------------------------------
1446template<typename PixelType>
1448 return lineNum;
1449}
1450
1451//----------------------------------------------------------------------
1452template<typename PixelType>
1453inline size_t ofPixels_<PixelType>::ConstLine::getStride() const{
1454 return stride;
1455}
1456
1457//----------------------------------------------------------------------
1458template<typename PixelType>
1460 return ConstPixel(_begin + (pixel*componentsPerPixel), componentsPerPixel, pixelFormat);
1461}
1462
1463//----------------------------------------------------------------------
1464template<typename PixelType>
1466 return ConstPixels(_begin,_end,componentsPerPixel,pixelFormat);
1467}
1468
1469//----------------------------------------------------------------------
1470template<typename PixelType>
1471inline typename ofPixels_<PixelType>::ConstPixels ofPixels_<PixelType>::ConstLine::getPixels(size_t first, size_t numPixels) const{
1472 return ConstPixels(&getPixel(first)[0], &getPixel(first+numPixels)[0], componentsPerPixel, pixelFormat);
1473}
1474
1475//----------------------------------------------------------------------
1476template<typename PixelType>
1477inline ofPixels_<PixelType>::ConstLines::ConstLines(const PixelType * _begin, const PixelType * _end, size_t stride, size_t componentsPerPixel, size_t lines, ofPixelFormat pixelFormat)
1478:_begin(_begin)
1479,_end(_end)
1480,stride(stride)
1481,componentsPerPixel(componentsPerPixel)
1482,lines(lines)
1483,pixelFormat(pixelFormat){}
1484
1485//----------------------------------------------------------------------
1486template<typename PixelType>
1488 return ConstLine(_begin,stride,componentsPerPixel,0,pixelFormat);
1489}
1490
1491//----------------------------------------------------------------------
1492template<typename PixelType>
1494 return ConstLine(_end,stride,componentsPerPixel,lines,pixelFormat);
1495}
1496
1497
1498//----------------------------------------------------------------------
1499template<typename PixelType>
1501 return ConstLine(pixels+(width*getNumChannels()*line), width*getNumChannels(), getNumChannels(), line,pixelFormat);
1502}
1503
1504//----------------------------------------------------------------------
1505template<typename PixelType>
1507 return ConstLines(begin(),end(),width*getNumChannels(),getNumChannels(),getHeight(),pixelFormat);
1508}
1509
1510//----------------------------------------------------------------------
1511template<typename PixelType>
1512inline typename ofPixels_<PixelType>::ConstLines ofPixels_<PixelType>::getConstLines(size_t first, size_t numLines) const{
1513 return ConstLines(getConstLine(first).begin(),getConstLine(first+numLines).begin(),width*getNumChannels(),getNumChannels(),numLines,pixelFormat);
1514}
1515
1516//----------------------------------------------------------------------
1517template<typename PixelType>
1519 return ConstPixels(begin(),end(),getNumChannels(),pixelFormat);
1520}
1521
1522namespace std{
1523template<typename PixelType>
1525 src.swap(dst);
1526}
1527}
ofColor represents a color in openFrameworks.
Definition ofColor.h:20
PixelType v[4]
The pixel values as an array.
Definition ofColor.h:94
void set(float red, float green, float blue, float alpha=limit())
Set an ofColor_ by using RGB values.
Definition ofColor.cpp:214
Derived log class for easy warning logging.
Definition ofLog.h:585
A class representing a collection of pixels.
Definition ofPixels.h:170
size_t getHeight() const
Get the height of the pixel array.
Definition ofPixels.cpp:804
const PixelType & operator[](size_t pos) const
Provides access to each channel of each pixel. If you have RGB pixel data, then you'll have 3 values ...
Definition ofPixels.cpp:789
PixelType * iterator
Definition ofPixels.h:450
~ofPixels_()
Definition ofPixels.cpp:263
size_t getNumPlanes() const
Definition ofPixels.cpp:845
void setFromPixels(const PixelType *newPixels, size_t w, size_t h, size_t channels)
Definition ofPixels.cpp:373
const PixelType * const_iterator
Definition ofPixels.h:451
ofPixels_< PixelType > getPlane(size_t plane)
Definition ofPixels.cpp:877
void setImageType(ofImageType imageType)
Changes the image type for the ofPixels object.
Definition ofPixels.cpp:957
bool resizeTo(ofPixels_< PixelType > &dst, ofInterpolationMethod interpMethod=OF_INTERPOLATE_NEAREST_NEIGHBOR) const
Resize the ofPixels instance to the size of the ofPixels object passed in dst.
Definition ofPixels.cpp:1335
ofPixels_< PixelType > & operator=(const ofPixels_< SrcType > &mom)
Definition ofPixels.h:723
void setColor(size_t x, size_t y, const ofColor_< PixelType > &color)
Set the color of the pixel at the x,y location.
Definition ofPixels.cpp:708
void rotate90(int nClockwiseRotations)
Definition ofPixels.cpp:1142
void mirror(bool vertically, bool horizontal)
Mirror the pixels across the vertical and/or horizontal axis.
Definition ofPixels.cpp:1176
void rotate90To(ofPixels_< PixelType > &dst, int nClockwiseRotations) const
Definition ofPixels.cpp:1074
size_t getNumChannels() const
Get the number of channels that the ofPixels object contains. RGB is 3 channels, RGBA is 4,...
Definition ofPixels.cpp:834
bool blendInto(ofPixels_< PixelType > &dst, size_t x, size_t y) const
Definition ofPixels.cpp:1471
void swap(ofPixels_< PixelType > &pix)
Definition ofPixels.cpp:286
size_t getBitsPerPixel() const
Get number of bits per pixel.
Definition ofPixels.cpp:814
OF_DEPRECATED_MSG("Use getData instead", PixelType *getPixels())
size_t getBytesStride() const
Definition ofPixels.cpp:829
PixelType * getData()
Retrieves pixel data from the ofPixel object.
Definition ofPixels.cpp:500
void clear()
Clear all the data from the ofPixels objects. After calling this you'll need to allocate() the ofPixe...
Definition ofPixels.cpp:584
const_iterator end() const
Definition ofPixels.h:771
reverse_iterator rbegin()
Definition ofPixels.h:777
size_t getWidth() const
Get the width of the pixel array.
Definition ofPixels.cpp:799
const_reverse_iterator rend() const
Definition ofPixels.h:795
const_iterator begin() const
Definition ofPixels.h:765
size_t getBytesPerChannel() const
Get how large each channel of a pixel is.
Definition ofPixels.cpp:819
static size_t bytesFromPixelFormat(size_t w, size_t h, ofPixelFormat format)
Definition ofPixels.cpp:132
iterator end()
Definition ofPixels.h:759
size_t size() const
Get the number of values that the ofPixels object contains, so an RGB data 400x400 would be 480,...
Definition ofPixels.cpp:997
ofPixels_< PixelType > getChannel(size_t channel) const
Get all values of one channel.
Definition ofPixels.cpp:1002
void cropTo(ofPixels_< PixelType > &toPix, size_t x, size_t y, size_t width, size_t height) const
Crop the pixels into the ofPixels reference passed in by toPix. at thexandy` and width the new width ...
Definition ofPixels.cpp:1042
bool resize(size_t dstWidth, size_t dstHeight, ofInterpolationMethod interpMethod=OF_INTERPOLATE_NEAREST_NEIGHBOR)
Resize the ofPixels instance to the dstHeight and dstWidth.
Definition ofPixels.cpp:1262
reverse_iterator rend()
Definition ofPixels.h:783
size_t getTotalBytes() const
Definition ofPixels.cpp:840
OF_DEPRECATED_MSG("Use getData instead", const PixelType *getPixels() const)
void setFromAlignedPixels(const PixelType *newPixels, size_t width, size_t height, size_t channels, size_t stride)
Definition ofPixels.cpp:411
const PixelType * const_reverse_iterator
Definition ofPixels.h:453
void swapRgb()
Swaps the R and B channels of an image, leaving the G and A channels as is.
Definition ofPixels.cpp:550
void setFromExternalPixels(PixelType *newPixels, size_t w, size_t h, size_t channels)
Definition ofPixels.cpp:392
iterator begin()
Definition ofPixels.h:753
ofPixels_(const ofPixels_< SrcType > &mom)
Definition ofPixels.h:710
ofImageType getImageType() const
Get the type of the image.
Definition ofPixels.cpp:952
bool isAllocated() const
Get whether memory has been allocated for an ofPixels object or not.
Definition ofPixels.cpp:794
size_t getPixelIndex(size_t x, size_t y) const
Get the pixel index at a x,y position.
Definition ofPixels.cpp:598
size_t getBitsPerChannel() const
Get how large each channel of a pixels is.
Definition ofPixels.cpp:824
void setNumChannels(size_t numChannels)
Definition ofPixels.cpp:991
ofPixelFormat getPixelFormat() const
Definition ofPixels.cpp:986
void crop(size_t x, size_t y, size_t width, size_t height)
Crop the pixels to a new width and height.
Definition ofPixels.cpp:1032
PixelType * reverse_iterator
Definition ofPixels.h:452
void setChannel(size_t channel, const ofPixels_< PixelType > channelPixels)
Set all the pixel data for a single channel, for instance, the Red pixel values, from an ofPixels obj...
Definition ofPixels.cpp:1017
void allocate(size_t w, size_t h, size_t channels)
Allocates space for pixel data.
Definition ofPixels.cpp:510
ofColor_< PixelType > getColor(size_t x, size_t y) const
Get the color at a x,y position.
Definition ofPixels.cpp:651
static size_t pixelBitsFromPixelFormat(ofPixelFormat format)
Definition ofPixels.cpp:23
ofPixels_()
Definition ofPixels.cpp:259
ofPixels_< PixelType > & operator=(const ofPixels_< PixelType > &mom)
Definition ofPixels.cpp:298
size_t getBytesPerPixel() const
Get the number of bytes per pixel.
Definition ofPixels.cpp:809
bool pasteInto(ofPixels_< PixelType > &dst, size_t x, size_t y) const
Paste the ofPixels object into another ofPixels object at the specified index, copying data from the ...
Definition ofPixels.cpp:1443
const_reverse_iterator rbegin() const
Definition ofPixels.h:789
void mirrorTo(ofPixels_< PixelType > &dst, bool vertically, bool horizontal) const
Definition ofPixels.cpp:1215
Definition ofPixels.h:1522
unsigned int height
Definition ofAppEGLWindow.cpp:125
unsigned int width
Definition ofAppEGLWindow.cpp:124
ofImageType
Used to represent the available channel types in ofImage.
Definition ofGraphicsConstants.h:154
float ofClamp(float value, float min, float max)
Clamp a value between min and max.
Definition ofMath.cpp:120
#define c
#define swap(a, i, j)
ofPixels_< float > ofFloatPixels
Definition ofPixels.h:693
ofPixelFormat
Used to represent the available pixel formats.
Definition ofPixels.h:68
@ OF_PIXELS_UNKNOWN
This indicates an unknown pixel type.
Definition ofPixels.h:152
@ OF_PIXELS_BGRA
A pixel used for color/transparency with a blue/green/red/alpha channel order.
Definition ofPixels.h:97
@ OF_PIXELS_RGB
An RGB pixel with no alpha channel.
Definition ofPixels.h:83
@ OF_PIXELS_I420
A 12-bit YUV format similar to OF_PIXELS_YV12, but with U & V reversed.
Definition ofPixels.h:127
@ OF_PIXELS_NV12
A 12-bit YUV 4:2:0 pixel with an interleaved U/V plane.
Definition ofPixels.h:109
@ OF_PIXELS_RGB565
Definition ofPixels.h:100
@ OF_PIXELS_Y
A single channel pixel, typically used for the luma component of YUV.
Definition ofPixels.h:138
@ OF_PIXELS_NATIVE
This indicates an unknown, native pixel type.
Definition ofPixels.h:154
@ OF_PIXELS_UYVY
A 16-bit YUV 4:2:2 format.
Definition ofPixels.h:135
@ OF_PIXELS_NUM_FORMATS
This is a placeholder to indicate the last valid enum.
Definition ofPixels.h:149
@ OF_PIXELS_RGBA
An RGBA pixel. This is typically used for color with transparency.
Definition ofPixels.h:93
@ OF_PIXELS_GRAY
A single-channel pixel, typically used for greyscale images.
Definition ofPixels.h:72
@ OF_PIXELS_YV12
A 12-bit YUV NxM Y plane followed by (N/2)x(M/2) V and U planes.
Definition ofPixels.h:121
@ OF_PIXELS_BGR
A pixel used for color data with a blue/green/red channel order.
Definition ofPixels.h:87
@ OF_PIXELS_V
A single channel pixel, typically used (with U) for the chroma component of YUV.
Definition ofPixels.h:142
@ OF_PIXELS_YUY2
A 16-bit YUV 4:2:2 format.
Definition ofPixels.h:131
@ OF_PIXELS_NV21
A 12-bit YUV 4:2:0 pixel with an interleaved V/U plane.
Definition ofPixels.h:117
@ OF_PIXELS_GRAY_ALPHA
A single-channel pixel with an alpha channel.
Definition ofPixels.h:76
@ OF_PIXELS_UV
A two channel pixel, with U first, representing both chroma components of YUV.
Definition ofPixels.h:144
@ OF_PIXELS_VU
A two channel pixel, with V first, representing both chroma components of YUV.
Definition ofPixels.h:146
@ OF_PIXELS_U
A single channel pixel, typically used (with V) for the chroma component of YUV.
Definition ofPixels.h:140
ofInterpolationMethod
Definition ofPixels.h:58
@ OF_INTERPOLATE_NEAREST_NEIGHBOR
Definition ofPixels.h:59
@ OF_INTERPOLATE_BICUBIC
Definition ofPixels.h:61
@ OF_INTERPOLATE_BILINEAR
Definition ofPixels.h:60
ofPixels_< unsigned char > ofPixels
Definition ofPixels.h:692
std::string ofToString(const T &v)
Convert a value to a string.
Definition ofUtils.h:657
ofColor_< unsigned char > ofColor
Definition ofPixels.h:10
ofColor_< float > ofFloatColor
Definition ofPixels.h:11
ofColor_< unsigned short > ofShortColor
Definition ofPixels.h:12
ofPixels_< unsigned short > ofShortPixels
Definition ofPixels.h:694
ofFloatPixels & ofFloatPixelsRef
Definition ofPixels.h:698
ofShortPixels & ofShortPixelsRef
Definition ofPixels.h:699
ofPixels & ofPixelsRef
Definition ofPixels.h:697
glm::vec3 operator+(const glm::vec3 &v1, const ofVec3f &v2)
Definition ofVectorMath.h:292
glm::vec3 & operator+=(glm::vec3 &v1, const ofVec3f &v2)
Definition ofVectorMath.h:312
glm::vec3 operator*(const glm::vec3 &v1, const ofVec3f &v2)
Definition ofVectorMath.h:302
glm::vec3 operator-(const glm::vec3 &v1, const ofVec3f &v2)
Definition ofVectorMath.h:297