Hi to everyone.
I want to do an algorithm of image rotation. The code is like this
__global__ void Rotate(__read_only image2d_t imageIn, uchar4 * output, int width, int height, float angle)
{
const int xOut=get_global_id(0); //block dimension x=16
const int yOut=get_global_id(0); //block dimension y=4
int x=(yout*width)+xOut;
int y=(xOut*height)+yOut;
if(x < width && y < height)
{
// variables to hold the center coordinate of the image.
// Texture operations use floating point coordinates
float xf = (float)x - (float)width / 2.0f;
float yf = (float)y - (float)height / 2.0f;
// transform to polar coordinates
float r = sqrt((float)(xf*xf + yf*yf));
float theta = atan2f(xf,yf) + 3.14159f / 2.0f;
// compute the new theta by adding the rotation angle
theta += radians(angle);
// convert back to cartesian coordinates oriented at 0,0
yf = r * sinf(theta);
yf += (float)h / 2.0f;
xf = -r * cosf(theta);
xf += (float)w / 2.0f;
const sampler_t sampler=CLK_NORMALIZED_COORD_FALSE|CLK_ADDRESS_CLAMP|CLK_FILTER_NEAREST;
float4 out_val_f = tex2D(sampler,(float2)(xf,yf));
// convert back to unsigned char and scale.
uchar4 out_val;
out_val.x = (unsigned char)(255.0f * out_val_f.x);
out_val.y = (unsigned char)(255.0f * out_val_f.y);
out_val.z = (unsigned char)(255.0f * out_val_f.z);
out_val.w = 255;
out_image[x] = out_val;
}
}
I have the problem when i try to use tex2d and sampler_t. This is the error
:117: error:unexpected type name ‘float2’ : expected expression float4 out_val_f=tex2D(sampler,(float2)(xf,yf));
Help me