-bool JpegFlipV(RGB888Type *buffer, int width, int height )
-{
- int bwidth = width;
- int bheight = height;
- //Destination pixel, set as the first pixel of screen
- RGB888Type* to = buffer;
- //Source pixel, as the image is flipped horizontally and vertically,
- //the source pixel is the end of the buffer of size bwidth * bheight
- RGB888Type* from = buffer + bwidth * bheight - 1;
- RGB888Type temp;
- unsigned int endLoop = ( bwidth * bheight ) / 2;
-
- for(unsigned ix = 0; ix < endLoop; ++ ix, ++ to, -- from )
- {
- temp = *from;
- *from = *to;
- *to = temp;
- }
-
- return true;
-}
-
-bool JpegFlipH(RGB888Type *buffer, int width, int height )
-{
- int ix, iy;
- int bwidth = width;
- int bheight = height;
-
- RGB888Type* to;
- RGB888Type* from;
- RGB888Type temp;
-
- for(iy = 0; iy < bheight; iy ++)
- {
- //Set the destination pixel as the beginning of the row
- to = buffer + bwidth * iy;
- //Set the source pixel as the end of the row to flip in X axis
- from = buffer + bwidth * (iy + 1) - 1;
- for(ix = 0; ix < bwidth / 2; ix ++ , ++ to, -- from )
- {
- temp = *from;
- *from = *to;
- *to = temp;
- }
- }
- return true;
-}
-
-bool JpegTranspose( RGB888Type *buffer, int width, int height )
-{
- int ix, iy;
- int bwidth = width;
- int bheight = height;
-
- RGB888Type* to;
- RGB888Type* from;
- RGB888Type temp;
- //Flip vertically only
- for(iy = 0; iy < bheight / 2; iy ++)
- {
- for(ix = 0; ix < bwidth; ix ++)
- {
- to = buffer + iy * bwidth + ix;
- from = buffer + (bheight - 1 - iy) * bwidth + ix;
- temp = *from;
- *from = *to;
- *to = temp;
- }
- }
-
- return true;
-}
-
-bool JpegTransverse( RGB888Type *buffer, int width, int height )
-{
- int bwidth = width;
- int bheight = height;
- Vector<RGB888Type> data;
- data.Resize( bwidth * bheight );
- RGB888Type *dataPtr = data.Begin();
- memcpy(dataPtr, buffer, bwidth * bheight * DECODED_PIXEL_SIZE );
-
- RGB888Type* to = buffer;
- RGB888Type* from;
- for( int iy = 0; iy < bwidth; iy++ )
- {
- for( int ix = 0; ix < bheight; ix++ )
- {
- from = dataPtr + ix * bwidth + iy;
- *to = *from;
- to ++;
- }
- }
-
- return true;
-}
-
-///@Todo: Move all these rotation functions to portable/image-operations and take "Jpeg" out of their names.
-bool JpegRotate90(RGB888Type *buffer, int width, int height )
-{
- int w, hw = 0;
- int ix, iy = 0;
- int bwidth = width;
- int bheight = height;
- Vector<RGB888Type> data;
- data.Resize(width * height);
- RGB888Type *dataPtr = data.Begin();
- memcpy(dataPtr, buffer, width * height * DECODED_PIXEL_SIZE );
- w = bheight;
- bheight = bwidth;
- bwidth = w;
- hw = bwidth * bheight;
- hw = - hw - 1;
-
- RGB888Type* to = buffer + bwidth - 1;
- RGB888Type* from = dataPtr;
-
- for(ix = bwidth; -- ix >= 0;)
- {
- for(iy = bheight; -- iy >= 0; ++from )
- {
- *to = *from;
- to += bwidth;
- }
- to += hw;
- }
-
- return true;
-}
-
-bool JpegRotate180( RGB888Type *buffer, int width, int height )
-{
- int bwidth = width;
- int bheight = height;
- Vector<RGB888Type> data;
- data.Resize( bwidth * bheight );
- RGB888Type *dataPtr = data.Begin();
- memcpy(dataPtr, buffer, bwidth * bheight * DECODED_PIXEL_SIZE );
-
- RGB888Type* to = buffer;
- RGB888Type* from;
- for( int iy = 0; iy < bwidth; iy++ )
- {
- for( int ix = 0; ix < bheight; ix++ )
- {
- from = dataPtr + ( bheight - ix) * bwidth - 1 - iy;
- *to = *from;
- to ++;
- }
- }
-
- return true;
-}
-
-bool JpegRotate270( RGB888Type *buffer, int width, int height )
-{
- int w, hw = 0;
- int ix, iy = 0;
-
- int bwidth = width;
- int bheight = height;
- Vector<RGB888Type> data;
- data.Resize( width * height );
- RGB888Type *dataPtr = data.Begin();
- memcpy(dataPtr, buffer, width * height * DECODED_PIXEL_SIZE );
- w = bheight;
- bheight = bwidth;
- bwidth = w;
- hw = bwidth * bheight;
-
- RGB888Type* to = buffer + hw - bwidth;
- RGB888Type* from = dataPtr;
-
- w = -w;
- hw = hw + 1;
- for(ix = bwidth; -- ix >= 0;)
- {
- for(iy = bheight; -- iy >= 0;)
- {
- *to = *from;
- from ++;
- to += w;
- }
- to += hw;
- }
-
- return true;
-}
-