0
이미지의 일부분을 회전 된 다른 것으로 대체하려고합니다. 이미지 소스는 origin_source가 image * this의 orign_dest에서 끝나는 방식으로 나타나야합니다. 픽셀을 교체하기 전에 원본을 origin_source 주위로 회전해야합니다.회전 된 이미지를 캔버스에 그립니다.
아래 코드는 R이 미러 매트릭스 일 때 작동하지만 실제로 회전 매트릭스를 만들면 결과 이미지가 전단됩니다. 뭐가 잘못 되었 니? 정규화 벡터를 또한
inline Matrix22<double> transformRotationCreate(const Vector2d<double>& direction)
{
return (Matrix22<double>){direction.x, -direction.y, direction.y, direction.x};
}
Vector2d<T>& operator*=(const Matrix22<T>& M)
{
x=x*M.xx + y*M.xy;
y=x*M.yx + y*M.yy;
return *this;
}
이다
template<class T>
struct Matrix22
{
T xx;
T xy;
T yx;
T yy;
};
방향 이중
T = 여기
void Image::imageApply(const Image& source,const Point& origin_dest,const Point& origin_source,const Point& direction)
{
Matrix22<double> R=transformRotationCreate(direction);
Point source_new_size=sqrt(2)*((Point){source.widthGet(),source.heightGet()});
Point blit_start=origin_dest;
for(unsigned int k=0;k<source_new_size.y;k++)
{
for(unsigned int l=0;l<source_new_size.x;l++)
{
Point point_source=(Point){l,k};
Point point_dest=point_source-origin_source;
point_dest*=R;
point_dest+=blit_start;
if(point_source.rectangleInIs((Point){0,0},(Point){source.widthGet(),source.heightGet()})
&&point_dest.rectangleInIs((Point){0,0},(Point){widthGet(),heightGet()}))
{
(*this)(point_dest)=source(point_source);
}
}
}
}
사용할 다른 함수들이다
'transformRotationCreate()'의 코드를 게시 할 수 있습니까? – user1118321