How to read PNG, GIF, and jpg images in Symbian

Source: Internet
Author: User
Transferred from: tangl_99 Column

In the example of/Symbian/6.1/series60/series60ex/BMP manip, we explain how to read a GIF image and convert it to fbsbitmap.

Symbian provides cmdaimagedesctobitmaputility and cmdaimagefiletobitmaputility to specifically process and read GIF, PNG, and jpg compressed images. However, they are all activity Objects Based on the main Symbian thread, and the entire openl and convertl processes are executed asynchronously. That is to say, it is impossible for you to complete the entire loading and conversion in the execution of the handler function.

It uses the callback function. First, you execute an openl open. After the active object runs several laps, you can immediately execute the mmdaimageutilobserver: miuoopencomplete function. Then you can execute convertl for conversion, wait for the activity object to run a few more laps, and then execute another callback miuoconvertcomplete function. With their parameters, you can know whether the conversion is successful or not.

However, there are several points to explain.

The first is about cmdaimagedesctobitmaputility. Its openl parameter is a descriptor. However, please note that this descriptor must be maintained before miuoconvertcomplete is executed. Therefore, you must never directly use tptrc8 (abuf, abufsize) to send it to openl. Once executed in this way, it will give you an (-5) notsuppoted error message in miuoopencomplete. The same situation applies to newdesplayerreadonlyl of cmdaaudioplayerutility.

Second, the cfbsbitmap method for direct access to its data buffer. if the SDK is 1.0, you need to use the tbitmaputil: Begin function to lock the memory before operating its buffer. after the operation is complete, you need to use tbitmaputil: end to release the lock. for SDK 2.0, you can directly use the lockheap and unlockheap functions. If you want to lock two or more bitmaps at the same time, the second and later tbitmaputil should use constructors that contain the tbitmaputil reference parameters. Otherwise, an endless loop occurs when the begin function is locked for the second time.

Third, in the cfbsbitmap memory, the data between each row is not continuous. The number of buffered bytes in each row should be a multiple of Word (4 bytes. This is similar to DX and BMP files. If your cfbsbitmap is an odd number of widths and the color is a 12-bit color, a 16-bit white space unit should be created after each row of pixel data.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.