Pixel level manip question

It’s been a long time for me and C++. I’m trying to load an image and break it up into several strips of textures which I can redraw individually later. In the example below i just put 1px spaces in between scan lines so I can see where it is broken up. The issue is that I just get white boxes. Am I missing fundamental? Would you approach it differently? Thanks.

-charlie

  
// .h  
// ===================================================================  
ofImage im;  
ofTexture scans[10];  
int numScans, scanHeight;  
  
// .cpp  
// ===================================================================  
void testApp::setup() {  
	ofBackground(0x66,0x66,0x66);  
	ofSetFrameRate(60);  
	  
	numScans = 10;  
  
	// -----------------------------------------  
	im.loadImage("img/img_01.jpg");			// 600x600 px  
	unsigned char * pix = im.getPixels();  
	  
	scanHeight = floor(im.height / numScans);  
	int pixelsPerScan = (im.width * im.height) / numScans;  
	int bytesPerScan = pixelsPerScan * 3;  
	// ----------------------------------------  
	  
	// make image slices  
	int i = 0;  
	int k = 0;  
	for(int i=0; i<numScans; i++){  
		unsigned char* scanBytes = new unsigned char[bytesPerScan];  
		  
		// fill temp array with pixel data  
		for(k=0; k<bytesPerScan; k++){  
			scanBytes[k] = pix[(i*bytesPerScan) + k];  
		}  
		  
		// setup single scanline texture  
		ofTexture tex;  
		tex.allocate(im.width, scanHeight, GL_RGB);  
		tex.loadData(scanBytes, im.width, scanHeight, GL_RGB);  
		scans[i] = tex;  
		  
		delete [] scanBytes;  
	}  
}  
  
//--------------------------------------  
void testApp::draw() {  
	glTranslatef(500.0f, 50.0f, 0.0f);	  
  
	for(int i=0; i<numScans; i++){  
		scans[i].draw(-300, i*(scanHeight+1));  
	}  
}  

first suggestion: rather than this

  
      ofTexture tex;  
      tex.allocate(im.width, scanHeight, GL_RGB);  
      tex.loadData(scanBytes, im.width, scanHeight, GL_RGB);  
      scans[i] = tex;  

try doing this:

  
      scans[i].allocate(im.width, scanHeight, GL_RGB);  
      scans[i].loadData(scanBytes, im.width, scanHeight, GL_RGB);  

That was it exactly damian. Thanks a ton! I guess I was allocating double the space for the textures and the array references were pointing to the unallocated textures. It’s always frustrating re-learning to walk in a different language but I’m loving OF so far.