Back up BMP to JPG code on the wince platform 1

Source: Internet
Author: User
Tags bmp image

This was about a year ago. At that time, the project was required to convert BMP to JPG on the wince platform. After several months of hard work, the project was finally completed. Now it's almost a year later, it is estimated that you will never touch anything related to wince in the future, and you are also prepared to delete all the study notes and code projects. It is also rubbish to put these things that have not been sorted out on the computer. It is better to put them on the internet for reference.

Development Environment:Vs2005

Development Platform:Epc6960 wince Development Board

Main objectives:Convert BMP image to JPG on the wince Platform

Implementation Method:Use C ++ to compile the converted DLL file, use C # To compile the interface, and then call the DLL

Knowledge points involved in code:

1. Create a DLL.

2. function input parameters, outgoing parameters.

3. Bitmap format.

4. Bitmap operations and format conversion.

5. File Operations.

6. dll call

7 .......

1. dll project for converting image formats

//****************************

// ** Wincecppcamdll Project

// ** This project references the camera driver DLL file provided by the Development Board Company.

//****************************

1.1 import and reference DLL Parameters

Epcscam. h

1 # pragma once
2
3
4 /*
5 * Corresponds to cam_ioctl_samsung_cam_pr. After the RGB channel is enabled, the video image data is obtained from uirgb_addr. Note that when you access uirgb_addr,
6 * kernel mode is required. Use the setkmode function (true) and set flag to 0 after reading uirgb_addr.
7 * When a frame of data is sent, the underlying flag is set to 1 and uirgb_addr is set. This facilitates reading data from each frame.
8 */
9 typedef struct _ pingpong_pr
10 {
11 unsigned int uirgb_addr;
12 unsigned char flag;/* When the value is 1, the video data is valid */
13} pingpong_pr;
14
15
16 /*
17 * corresponding to cam_ioctl_samsung_cam. After the YUV channel is enabled, the video image data is obtained from uiy_addr, uicb_addr, and uicr_addr.
18 * When you ask three addresses, you must use the kernel mode, use the setkmode function (true), and set flag to 0 after reading address data,
19 * if there is data in the next frame, the underlying layer sets the flag to 1 and sets the YUV address values. This facilitates reading data from each frame.
20 */
21 typedef struct Pingpong
22 {
23 unsigned int uiy_addr;
24 unsigned int uicb_addr;
25 unsigned int uicr_addr;
26 unsigned char flag;
27} pingpong;
28
29 /*
30 * this structure is used to set the size of the video output image. The video output contains two channels: RGB channel and YUV channel. The RGB channel is rgb565 data.
31 * format. The RGB channel is used for video preview.
32 */
33 typedef struct _ image_size
34 {
35 DWORD dwrgb_width;/* width of the output image of the RGB channel */
36 DWORD dwrgb_height;/* Height of the output image of the RGB channel */
37 DWORD dwyuv_width;/* width of the output image of the YUV channel */
38 DWORD dwyuv_height;/* Height of the output image of the YUV channel */
39 DWORD dwhoroffset;/* horizontal shear offset of the video source */
40 DWORD dwveroffset;/* vertical shear offset of the video source */
41} image_size;
42
43
44
45 typedef bool (* pepccamcapture) (bool bisrgb, bool bisyuv );
46 typedef bool (* pepccampreviewon) (DWORD dwxsize, DWORD dwysize );
47 typedef bool (* pepccamsetimage) (image_size * pimagesize );
48 typedef bool (* pepccamgetrgbframe) (pingpong_pr * praddinfo );
49
50
51
52 class epcscam
53 {
54 public:
55 epcscam (void );
56 public:
57 ~ Epcscam (void );
58
59
60 public:
61 hinstance hdll; // instance handle for loading DLL
62 char * pbmpdata;
63
64 public:
65
66 /************************************** **************************************** ***************************
67 ** function name: epccamcapture
68 ** descriptions: This function is used to enable or disable video capture for camera. If the values of bisrgb and bisyuv are false, video capture is disabled,
69 ** if either of bisrgb and bisyuv is true, video capture is enabled.
70 ** input parameters: Enable the RGB channel when bisrgb is true, and disable the RGB channel when it is false.
71 ** enable the YUV channel when bisyuv is true, and disable the YUV channel when it is false
72 ** output parameters: None
73 ** returned value: true: Successful; false: Failed
74 *************************************** **************************************** **************************/
75
76
77
78
79 /************************************** **************************************** ***************************
80 ** function name: epccampreviewon
81 ** descriptions: This function is used to start preview images. After video capture (enable RGB channel) is enabled, the image display effect is displayed.
82 ** we recommend that you set the image resolution to be smaller than the display resolution when starting preview.
83 ** Note: The operation fails in the following cases: 1. In full screen mode, 2. the RGB channel image value is greater than 360*288 pixels.
84 ** input parameters: dwxsize: X coordinate of the preview image (starting from the upper left corner of the LCD, which can be a negative value)
85 ** dwysize: Y coordinate of the preview image (starting from the upper left corner of the LCD, which can be a negative value)
86 ** output parameters: None
87 ** returned value: true: Successful; false: Failed
88 *************************************** **************************************** **************************/
89
90
91
92
93 /************************************** **************************************** ***************************
94 ** function name: epccamsetimage
95 ** descriptions: This function is used to set the size of the output image of camera, including the video output size of RGB channel and YUV channel.
96 ** when this interface is enabled, the default RGB and YUV image sizes are 320*240.
97 ** Note: operations may fail in the following situations: 1. video capturing; 2. Preview; 3. Full Screen mode.
98 ** input parameters: pimagesize: used to set the video output size of two channels
99 ** output parameters: None
100 ** returned value: true: Successful; false: Failed
101 *************************************** **************************************** **************************/
102
103
104
105 /************************************** **************************************** ***************************
106 ** function name: epccamgetrgbframe
107 ** descriptions: This function is used to obtain the data cache address of an RGB channel image.
108 ** input parameters: praddinfo stores the obtained address. Use setkmode (true) to access the image data of this address)
109 ** output parameters: None
110 ** returned value: true: Successful; false: Failed
111 *************************************** **************************************** **************************/
112
113 bool epccamcapture (bool bisrgb, bool bisyuv );
114 bool epccampreviewon (DWORD dwxsize, DWORD dwysize );
115 bool epccamsetimage (image_size * pimagesize );
116 bool epccamgetrgbframe (pingpong_pr * praddinfo );
117
118
119 };

Epcscam. cpp

1 # include "stdafx. H"
2 # include "epcscam. H"
3
4 /************************************** **************************************** ***************************
5 ** function name: epccamcapture
6 ** descriptions: This function is used to enable or disable video capture for camera. If the values of bisrgb and bisyuv are false, video capture is disabled,
7 ** if either of bisrgb and bisyuv is true, video capture is enabled.
8 ** input parameters: Enable the RGB channel when bisrgb is true, and disable the RGB channel when it is false.
9 ** if bisyuv is true, enable the YUV channel. If it is false, disable the YUV channel.
10 ** output parameters: None
11 ** returned value: true: Successful; false: Failed
12 *************************************** **************************************** **************************/
13
14
15
16 /************************************** **************************************** ***************************
17 ** function name: epccampreviewon
18 ** descriptions: This function is used to start preview images. After video capture (enable RGB channel) is enabled, the image display effect is displayed.
19 ** we recommend that you set the image resolution to be smaller than the display resolution when starting preview.
20 ** Note: The operation fails in the following situations: 1. In full screen mode, 2. the RGB channel image value is greater than 360*288 pixels.
21 ** input parameters: dwxsize: X coordinate of the preview image (starting from the upper left corner of the LCD, which can be a negative value)
22 ** dwysize: Y coordinate of the preview image (starting from the upper left corner of the LCD, which can be a negative value)
23 ** output parameters: None
24 ** returned value: true: Successful; false: Failed
25 *************************************** **************************************** **************************/
26
27
28
29
30 /************************************** **************************************** ***************************
31 ** function name: epccamsetimage
32 ** descriptions: This function is used to set the size of the output image of camera, including the video output size of RGB and YUV channels.
33 ** when this interface is enabled, the default RGB and YUV image sizes are 320*240.
34 ** Note: operations may fail in the following situations: 1. video capturing; 2. Preview; 3. Full Screen mode.
35 ** input parameters: pimagesize: used to set the video output size of two channels
36 ** output parameters: None
37 ** returned value: true: Successful; false: Failed
38 *************************************** **************************************** **************************/

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.