From: Varun Date: Wed, 7 Dec 2016 20:42:21 +0000 (-0500) Subject: Flip the image during conversion X-Git-Tag: accepted/tizen/common/20161208.135359^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e975887eb3332afbe2120bc9c6de8d33f7ce9667;p=platform%2Fcore%2Flocation%2Fmaps-plugin-mapzen.git Flip the image during conversion saves an extra iteration over the entire image Change-Id: I1eb2f4b59b11ec7f67fc14c5657ae86db76ed75a --- diff --git a/src/mapzen/tangram_view.cpp b/src/mapzen/tangram_view.cpp index fd09ffd..7945270 100644 --- a/src/mapzen/tangram_view.cpp +++ b/src/mapzen/tangram_view.cpp @@ -595,29 +595,18 @@ mapzen_error_e TangramView::getBitmapMarkerImage(maps_view_object_h object, unsi break; } - // convert data from rgba to bgra + // convert data from rgba to bgra (also flip the image) for (int i = 0; i < imgHeight; i++) { for (int j = 0; j < imgWidth; j++) { int offset = ((i * imgWidth) + j) * 4; - *(imgData + offset) = *(srcData + offset + 2); - *(imgData + offset + 1) = *(srcData + offset + 1); - *(imgData + offset + 2) = *(srcData + offset); - *(imgData + offset + 3) = *(srcData + offset + 3); + int offset_flip = (((imgHeight - 1 - i) * imgWidth) + j) * 4; + *(imgData + offset_flip) = *(srcData + offset + 2); + *(imgData + offset_flip + 1) = *(srcData + offset + 1); + *(imgData + offset_flip + 2) = *(srcData + offset); + *(imgData + offset_flip + 3) = *(srcData + offset + 3); } } - // flip converted image - unsigned int *flippedImg = (unsigned int*)imgData; - unsigned int temp; - for (int i = 0; i < (imgHeight>>1); i++) { - unsigned int* lower = flippedImg + (i * imgWidth); - unsigned int* upper = flippedImg + ((imgHeight - i - 1) * imgWidth); - for (int j = 0; j < imgWidth; j++) { - temp = lower[j]; - lower[j] = upper[j]; - upper[j] = temp; - } - } } while (0); return (mapzen_error_e)convert_maps_error_to_mapzen_error(error);