@@ -262,29 +262,27 @@ void TFT_eSPI::tconHostAreaPackedPixelWrite(TCONLdImgInfo* pstLdImgInfo,TCONArea
262262 TDWord i,j;
263263 // Source buffer address of Host
264264 TWord* pusFrameBuf = (TWord*)pstLdImgInfo->ulStartFBAddr ;
265- TByte pusFrameBufTemp[pstAreaImgInfo->usWidth ] = {0 };
266- TByte *pusFrameBufBytes = (TByte *)pusFrameBuf;
267265 // Set Image buffer(IT8951) Base address
268266 tconSetImgBufBaseAddr (pstLdImgInfo->ulImgBufBaseAddr );
269267 // Send Load Image start Cmd
270268 tconLoadImgAreaStart (pstLdImgInfo , pstAreaImgInfo);
271-
272-
273- // tconSetImgRotation(IT8951_ROTATE_180);
274269 // printf("---IT8951 Host Area Packed Pixel Write begin---\r\n");
275270 // Host Write Data
276- for (j=0 ;j< pstAreaImgInfo->usHeight ;j++)
277- {
278- for (i=0 ;i< pstAreaImgInfo->usWidth / 2 ;i++)
279- {
280- pusFrameBufTemp[i] = pusFrameBufBytes[j * pstAreaImgInfo->usWidth + i];
281- pusFrameBufBytes[j * pstAreaImgInfo->usWidth + i] = pusFrameBufBytes[j * pstAreaImgInfo->usWidth + (pstAreaImgInfo->usWidth - i)];
282- pusFrameBufBytes[j * pstAreaImgInfo->usWidth + (pstAreaImgInfo->usWidth - i)] = pusFrameBufTemp[i];
283- // pusFrameBufTemp[j * (pstAreaImgInfo->usWidth ) + i] = (reverse_bits_8(pusFrameBufTemp[j * (pstAreaImgInfo->usWidth) + i]));
284- }
285- }
286- tconWirteNData (pusFrameBuf, pstAreaImgInfo->usHeight * pstAreaImgInfo->usWidth / 2 );
287-
271+ uint16_t *mirroredFrameBuf = (uint16_t *)malloc (pstAreaImgInfo->usWidth * pstAreaImgInfo->usHeight * sizeof (uint16_t ));
272+ if (mirroredFrameBuf == NULL ) {
273+ return ;
274+ }
275+
276+ for (uint16_t j = 0 ; j < pstAreaImgInfo->usHeight ; j++) {
277+ for (uint16_t i = 0 ; i < pstAreaImgInfo->usWidth ; i++) {
278+ if (pstLdImgInfo->usFilp )
279+ mirroredFrameBuf[j * pstAreaImgInfo->usWidth + i] = reverse_bits_16 (pusFrameBuf[j * pstAreaImgInfo->usWidth + i]);
280+ else
281+ mirroredFrameBuf[j * pstAreaImgInfo->usWidth + i] = pusFrameBuf[j * pstAreaImgInfo->usWidth + (pstAreaImgInfo->usWidth - 1 - i)];
282+ }
283+ }
284+ tconWirteNData (mirroredFrameBuf, pstAreaImgInfo->usHeight * pstAreaImgInfo->usWidth / 2 );
285+ free (mirroredFrameBuf);
288286 // for(j=0;j< pstAreaImgInfo->usHeight;j++)
289287 // {
290288 // for(i=0;i< pstAreaImgInfo->usWidth/2;i++)
@@ -348,7 +346,7 @@ void TFT_eSPI::tconLoad1bppImage(const TByte* p1bppImgBuf, TWord usX, TWord usY,
348346
349347 // Setting Load image information
350348 stLdImgInfo.ulStartFBAddr = (TDWord) p1bppImgBuf;
351- stLdImgInfo.usEndianType = IT8951_LDIMG_B_ENDIAN ;
349+ stLdImgInfo.usEndianType = IT8951_LDIMG_L_ENDIAN ;
352350 stLdImgInfo.usPixelFormat = IT8951_8BPP; // we use 8bpp because IT8951 dose not support 1bpp mode for load image�Aso we use Load 8bpp mode ,but the transfer size needs to be reduced to Size/8
353351 stLdImgInfo.usRotate = IT8951_ROTATE_0;
354352 stLdImgInfo.ulImgBufBaseAddr = _gulImgBufAddr;
@@ -371,7 +369,7 @@ void TFT_eSPI::tconLoadImage(const TByte* pImgBuf, TWord usX, TWord usY, TWord u
371369
372370 // Setting Load image information
373371 stLdImgInfo.ulStartFBAddr = (TDWord) pImgBuf;
374- stLdImgInfo.usEndianType = IT8951_LDIMG_B_ENDIAN ;
372+ stLdImgInfo.usEndianType = IT8951_LDIMG_L_ENDIAN ;
375373 stLdImgInfo.usPixelFormat = IT8951_4BPP; // we use 8bpp because IT8951 dose not support 1bpp mode for load image�Aso we use Load 8bpp mode ,but the transfer size needs to be reduced to Size/8
376374 stLdImgInfo.usRotate = IT8951_ROTATE_0;
377375 stLdImgInfo.ulImgBufBaseAddr = _gulImgBufAddr;
0 commit comments