Select Page

Digital Zoom/Rotation of Bitmap Images

Introduction

This mini project aims at using the various aspects of LCD screen and the touchscreen facility available on STM32F103ZET6. The device comes with a resistive touchscreen and a LCD of QVGA size(320×240) which is well suited for testing a wide range of multimedia applications. Here, we focus on two applications:

  • scaling and rotating of a pre-loaded image
  • paint editor
  • Board Feature

    Olimex STM32F103ZET6 board

    • STM32F103ZE (ARM® Cortex™-M3 32-bit) having RISC core operating at a 72 MHz frequency
    • 512 Kbytes Flash memory
    • 64 Kbytes SRAM
    • Mini USB
    • TFT 320×240 pixels colored LCD with resistive touch screen
    • 8 MHz crystal oscillator
    • Accelerometer
    • Mini SD/MMC
    • JTAG Debug Interface
    • Display Interface

      Display interface Bringing up the display is one of the primary tasks. The simplest way to display is to set the starting location of the window and write value to the contiguous locations. The two functions we use for the same are:

       LCD_SetDisplayWindow(row,col, height, width);
       LCD_WriteRAM(u16 value); 
      

      The reference index for the above function is the top-left of the LCD screen which acts as (0,0) thus pixels extend upto (240,320) as bottom-right of the screen. In addition to the above, there are few more rows beyond 320, which include the home,address book,contacts etc icons which are typical in any phone screen.

      Another twist in the tale is that the above LCD_WriteRAM function expects a 16 bit RGB565 format image. Thus for any normal image in jpeg to be displayed on board we need to do the necessary manipulation.

    • Technical Issues

      The implementation of the project involves various operations. Some of the major ones are

      • Read and Display Image
      • To obtain the desired amount of zoom
      • Use the Affine Transform for image rotation

      Among these, reading the image in the proper format and displaying it on the LCD is the most crucial part. The display expects a RGB 5-6-5 format (i.e. 16 bits per pixel where Red is represented by 5 bits, Green 6 and Blue 5). The image is stored in the code itself in the form of an array. This is done because as the processor has limited RAM, it cannot store an entire image in the RAM. Hence this is to be stored as a constant array of 16 bit words. A software named BMP24toRGB565 is used to convert the images to 24 bit BMP images into RGB 565 offline. An easier way to store the image as an array is to use a hex editor like Neo Hex Editor

      Another important issue is the non-trivial rotation of image (Non-Trivial in the sense by an angle other than the right angle). Affine transform involves the multiplication of real values with the integers. This has to be properly handled. Ultimately we require the integral values. Hence while converting the real products into integers, proper care is to be taken for displaying the images at the desired location. The sine and cosine values of the desired angles can be stored in the form of arrays. Care should be taken that if these are stored in the RAM and if these exceed the limit, the code may not work properly and does not even give a warning. A better way is to store these in as constant arrays.

      ImplementationThe touchscreen interface is to be implemented in the form of states. This is because every touch sense has a different meaning in every different display. Also every time BACK is pressed, proper sequence of states is to be maintained. This is not a problem with HOME as every time it is pressed, the control returns to the HOME screen, as though it is reset.

      As shown in the image, every time BACK is pressed, the control returns to the parent state (e.g from ZOOM to OPERATE).

      Results


    • Future Enhancements

      This project is an example of basic things that can be done on a processor board like STM32-LCD. A lot more improvements are possible like storing the image in SD card. Also other complex operations on images like edge detection, blurring, sharpening can also be implemented on the board. The USART ports available can be used to transfer files from a desktop to the board.

      Project Team

      • Manjunath Kulkarni
      • Paras Wadekar