Simple 2-dimensional array operation (90 degrees, 180/270 degree rotation, mirror, flip), I hope some people provide better / faster ways. Use it at your owmbsk!
// by oneGA
#include #include using namespace std; template void array_rotatel90 (const DT * PSRC, INT H, INT W, DT * DEST) {// PSRC [H] [W], DEST [ w] [h] if (0 == psrc || h <= 0 || W <= 0 || 0 == DEST) RETURN; int index = 0; int constant1 = (W-1) * h; for INT i = 0; i
Template Void Array_Rotater 90 (Const DT * PSRC, INT H, INT W, DT * DEST) {// PSRC [H] [W], DEST [W] [H] IF (0 == PSRC || H <= 0 || W <= 0 || 0 == DEST) RETURN; INT VAR = 0; INT constant1 = H - 1; for (int J = 0; j void array_rotate180 (const DT2 * PSRC, INT N, INT M, DT2 * DEST) {/ / psrc [n] [m] int constant1 = (m-1) * n n-1; int var = 0; // i * n int index = 0; for (int i = 0; i void print_Array (const dt * psrc, int w, int h, const char * desc = 0 ) {// this is for test / debug online, effect; if (0 == psrc || h <= 0 || W <= 0) return; std :: ostringstream OSS; if (DESC == 0 ) Oss << "array" << std :: endl; else oss << desc << std :: endl; For (int i = 0; i void array_flip (const dt * psrc, int w, int h, dt * dest) {= (0 == PSRC || h <= 0 || W <= 0 || 0 == DEST) RETURN; int off_start = 0; int offset2 = 0; for (INT i = 0; i
i ) {offset2 = offset - row_start; // (w-1) * h - i * h for (int J = 0; j Void Array_Mirror (const dt * PSRC, INT W, INT H, DT * DEST) {IF (0 == PSRC || H <= 0 || W <= 0 || 0 == DEST) RETURN; INT H_1 = H - 1; int index = 0; for (int i = 0; i ) {for (int J = 0; j (TEST [0], 3, 2, DEST [0]); Print_Array ((int *) dest [0] , 2, 3, "after array_rotatel90");