     unsigned int y = blockIdx.y * blockDim.y + threadIdx.y;
 
     if (x < dst.cols && y < dst.rows)
-        ((uchar4*)dst.ptr(y))[x] = tex2D(resize8UC4_tex, x * sx, y * sy);
+    {
+        float4 val = tex2D(resize8UC4_tex, x * sx, y * sy);
+        ((uchar4*)dst.ptr(y))[x] = make_uchar4(val.x * 255, val.y * 255, val.z * 255, val.w * 255);
+    }
 }
 
 

{
    cudaChannelFormatDesc desc = cudaCreateChannelDesc<uchar4>();
    cudaBindTexture2D(0, resize8UC4_tex, src.data, desc, src.cols, src.rows, src.step);

    dim3 threads(32, 8);
    dim3 grid(div_up(dst.cols, threads.x), div_up(dst.rows, threads.y));

{
    cudaChannelFormatDesc desc = cudaCreateChannelDesc<unsigned char>();
    cudaBindTexture2D(0, resize8UC1_tex, src.data, desc, src.cols, src.rows, src.step);
    resize8UC1_tex.filterMode = cudaFilterModeLinear;

    dim3 threads(32, 8);
    dim3 grid(div_up(dst.cols, threads.x), div_up(dst.rows, threads.y));
