Convert BMP bitmap to JPEG format in Windows XP

Source: Internet
Author: User

1. Bitmap Class Based on C #

 

  Using  System;
Using System. Collections. Generic;
Using System. text;
Using System. IO;
Using System. drawing;
Using System. Drawing. imaging;

Namespace Lelebmp tojpeg
{
Class Program
{

Static Void Main ( String [] ARGs)
{
String BMP filepath = " Testbmp .bmp " ;
Bitmap m_bitmap = New Bitmap (BMP filepath ); // Reads bitmap files in a specified directory and constructs bitmap objects.

String Jpgfilepath = " Jpegresult.jpg " ;
M_bitmap.save (jpgfilepath, imageformat. JPEG ); // Save image files


// Note:
// 1. There are many other options for saving the image format, such as GIF and PNG.
// 2. You can save the conversion result as a file stream or a memory stream.
}
}
}

 

 

 

Note: This method can only be used in WINXP. In wince, the bitmap statement cannot run normally. I don't know why, it may be that such advanced functions are not provided in wince. Finally, the format is converted using C ++ through the iimagefactory interface.

 

 

 

II. C ++-based ATL support class cimage

Use vs2005 to create C ++ in WINXPProgramAnd select the ATL support when creating the program.

Then, in the main fileCodeAs follows:

 
// Winxpcppatl. cpp: defines the entry point of the console application. // # Include "stdafx. H "# include" winxpcppatl. H "# include <atlimage. h> // Cyan: header file of the cimage class # ifdef _ debug # define new debug_new # endif // unique application object cwinapp theapp; using namespace STD; int _ tmain (INT argc, tchar * argv [], tchar * envp []) {int nretcode = 0; // initialize MFC and display an error if (! Afxwininit (: getmodulehandle (null), null,: getcommandline (), 0) {// todo: change the error code to meet your needs _ tprintf (_ T ("error: MFC initialization failed \ n"); nretcode = 1;} else {// todo: write code for the behavior of the application here. Cimage m_image; m_image.load (_ T ("\ recvbmp data.bmp"); m_image.save (_ T ("\ recvbmp data.jpg");} return nretcode ;}

Note: This method can be used for file operations or in-memory transcoding operations, but it can only be performed under WINXP and cannot be successful under wince. Although the ATL in wince also has this cimage class, the method provided is limited than that in XP, and cannot meet the format conversion requirements in the wince platform.

 

 

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.