c# - Tiling tile buffer in an Image buffer Index calculation issue -


i have problem in tiling image buffer tile buffer of square size. kindly point, doing wrong.

the idea image buffer filled predefined square tile buffer condition. output image buffer tilled tile, keeping in mind, image can rectangular (not square)

thank you.

i have tried this.

static int imgwidth = 150; static int imgheight=100;     static int gl_fxf = 4;//4*n     byte[] img_byte8rgbbuff = new byte[imgwidth*imgheight*3];// variable size     byte[] tile_byte8rgbbuff = new byte[gl_fxf * gl_fxf * 3];// can of size 4nx4n      public byte[] fillwithtile(byte[] in_image, byte[] tile)      {         byte[] img_byte8rgbbuff_out = new byte[in_image.length];           int somemainindex;           action<int, int, int> tffxmethod = (int a_h, int b_w, int in_indx) =>         {              int t_indx;             //int t_indx2;              int counter = 0;              (int j = a_h; j < a_h + gl_fxf; j++)                 (int = b_w; < b_w + gl_fxf; i++)                 {                     t_indx = j * 3 * imgwidth + * 3;                     // wrong in index calculation arrays                     if (in_image[in_indx] == 255)// ex. condition in_image[in_indx] == 255 red component                     {                         img_byte8rgbbuff_out[t_indx] = tile[counter];                         img_byte8rgbbuff_out[t_indx+1] = tile[counter+1];                         img_byte8rgbbuff_out[t_indx+2] = tile[counter+2];                      }                     counter = counter + 1;                 }          };           (int palboxh = 0; palboxh <= imgheight; palboxh = palboxh + gl_fxf)             (int palboxw = 0; palboxw <= imgwidth; palboxw = palboxw + gl_fxf)             {                  somemainindex = palboxh * 3 * gl_fxf * imgwidth + palboxw * 3 * gl_fxf;                  tffxmethod(palboxh, palboxw, somemainindex);               } return img_byte8rgbbuff_out;      }//  

figured out myself

counter should following code , no need in_indx

 counter = counter +3; 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -