Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <chrono>
- #include "../../../../Arbeit/Repository/Programming/trunk/edu/rtcv/algorithms/tools/FunctionTimer.h"
- #include <iterator>
- class Image
- {
- public:
- Image() : m_width(0), m_height(0), mp_data(nullptr) {}
- ~Image() { delete[] mp_data; }
- Image(const Image& rhs)
- {
- m_width = rhs.m_width;
- m_height = rhs.m_height;
- mp_data = new unsigned char[m_width*m_height];
- std::copy(rhs.mp_data, rhs.mp_data + m_width * m_height, mp_data);
- //memcpy(mp_data, rhs.mp_data, m_width*m_height * sizeof(unsigned char));
- }
- Image& operator=(const Image& rhs)
- {
- m_width = rhs.m_width;
- m_height = rhs.m_height;
- delete[] mp_data;
- mp_data = new unsigned char[m_width*m_height];
- memcpy(mp_data, rhs.mp_data, m_width*m_height * sizeof(unsigned char));
- return *this;
- }
- void resize(unsigned int width, unsigned int height)
- {
- m_width = width;
- m_height = height;
- delete[] mp_data;
- mp_data = new unsigned char[m_width * m_height];
- }
- void release()
- {
- delete[] mp_data;
- mp_data = nullptr;
- m_width = m_height = 0;
- }
- private:
- unsigned int m_width;
- unsigned int m_height;
- unsigned char * mp_data;
- };
- void main()
- {
- Image ref;
- ref.resize(1024, 1024);
- for(int j = 0; j < 10; ++j)
- {
- int numIter = 5000;
- double et = 0;
- {
- BlockTimer t(et);
- for (int i = 0; i < numIter; ++i)
- {
- Image img(ref);
- }
- }
- std::cout << et << std::endl;
- }
- system("PAUSE");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement