Table of Contents

 
CellPosRC
 

Purpose

Takes a cell and converts it to a row and column location given the number of rows and columns passed in

 

Protoype

CVector CImageMngr::CellPosRC (int i_cell_id, int i_num_cols, int i_num_rows)
 

Parameters

cell_id the ID of the cell to convert
num_cols the number of columns in the template
num_rows the number of rows in the template
 

Description

This function takes a cell number in a template and returns the location of the cell in a row,col format via a CVector object. All cells in a template begin with 0 and proceed to the right and down. So a 4x4 template would have cells 0, 1, 2, 3 in the top row, cells 4, 5, 6, 7 in the second row, etc. By passing in the number of rows and columns in the template the function can calculate the total number of cells to figure out the location of the given cell. The row,col location is returned in a CVector object.

NOTE: In this format the rows = y and the columns = x.

 

Use

CImageMngr image;
// get the location of the 4rd cell in a 4x4 template
CVector row_col = image.CellPosRC(3, 4, 4);
// extract the individual row and column locations
int row = row_col.vy;
int col = row_col.vx;
 

Prev: Assign
Next: CellPosXY