I'm trying to do and make a software driver for one old device and i added bitmap support to it successfully. The problem is that all bitmaps are vertically flipped and I need somehow to flip them around.
My array has 230400 elements(for the resolution 320x240 as 320*3 colors is 960 elements per one y pixel, so 230400 in total)
I tried this one from Reversing arrays in C yesterday but today i realised that i need to switch every 960 elements from start to end to (i think) have it vertically flipped.
I also tried one array reverse guide on the internet but it reversed all elements and so colors changed and it flipped horizontally after sucessfully flipping vertically
For importing the 320x240 bitmap i used https://stackoverflow.com/a/9296467 ,renamed data do BMPdata and added my piece of code to the B,G,R to R,G,B code
data[(i+y*320)] = BMPdata[i];
data[(i+y*320)+1] = BMPdata[i+1];
data[(i+y*320)+2] = BMPdata[i+2];
This piece of code sets every pixel in red(first line), green(second), blue(third) to the needed value from BMPdata array.
So i expect it to flip vertically because the one used before was not working and the second one which reverses the whole array from 0-230400 to 230400-0 changed also colors(which is logical for me) but also flipped the image horizontally so i also can't use that.
I want it to have every 960 elements switch from start to end without changing anything in them, so in example: i have array of 5760 elements
960-1920: Test of the second line.
1920-2880: Third test
2880-3840: 4th line of text
3840-4800: Nearly the last thing.
4800-5760: Last line.
I expect it to flip like this:
0-960: Last line.
960-1920: Nearly the last thing.
1920-2880: 4th line of text
2880-3840: Third test
3840-4800: Test of the second line.
4800-5760: This is a test of the first line.
But it looks like it flipped like this with the reverse array thing:
0-960: .enil tsaL
960-1920: .gniht tsal eht ylraeN
1920-2880: txet fo enil ht4
2880-3840: tset drihT
3840-4800: .enil dnoces eht fo tseT
4800-5760: .enil tsrif eht fo tset a si sihT