This repository has been archived on 2024-05-02. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
2022-04-05 11:42:28 +03:00

32 lines
702 B
C++

#pragma once
#include <pangolin/image/managed_image.h>
#include <pangolin/utils/compontent_cast.h>
namespace pangolin
{
template <typename To, typename T>
void ImageConvert(Image<To>& dst, const Image<T>& src, To scale = 1.0)
{
for(unsigned int y = 0; y < dst.h; ++y)
{
const T* prs = src.RowPtr(y);
To* prd = dst.RowPtr(y);
for(unsigned int x = 0; x < dst.w; ++x)
{
*(prd++) = scale * ComponentCast<To, T>::cast(*(prs++));
}
}
}
template <typename To, typename T>
ManagedImage<To> ImageConvert(const Image<T>& src, To scale = 1.0)
{
ManagedImage<To> dst(src.w, src.h);
ImageConvert<To,T>(dst,src,scale);
return dst;
}
}