C++ 如何将CLI Image^转换为任何标准C++;位图

C++ 如何将CLI Image^转换为任何标准C++;位图,c++,.net,image,c++-cli,bmp,C++,.net,Image,C++ Cli,Bmp,我已经把一个JPG图像加载到了图像> 对象,但是现在我想在程序中使用“标准C++”,所以我想把图像^对象转换成任何 BMP类对象< /C>(我不知道哪个C++类是好的)。p> 我想编辑位图中特定像素的颜色 请帮我做这件事 // a.cpp : main project file. #include "stdafx.h" #include "Form1.h" #using <mscorlib.dll> //requires CLI using namespace System;

我已经把一个JPG图像加载到了图像> 对象,但是现在我想在程序中使用“标准C++”,所以我想把图像^对象转换成任何<代码> BMP类对象< /C>(我不知道哪个C++类是好的)。p> 我想编辑位图中特定像素的颜色

请帮我做这件事

   // a.cpp : main project file.

#include "stdafx.h"
#include "Form1.h"
#using <mscorlib.dll> //requires CLI
using namespace System;
using namespace System::IO;
using namespace System::Windows::Media::Imaging;
using namespace System::Windows::Media;
using namespace System::Windows::Controls;
using namespace a;

[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
    // Enabling Windows XP visual effects before any controls are created
    Application::EnableVisualStyles();
    Application::SetCompatibleTextRenderingDefault(false); 

    // Create the main window and run it
    Application::Run(gcnew Form1());


    // Open a Stream and decode a JPEG image
        Stream^ imageStreamSource = gcnew FileStream("C:/heart.jpg", FileMode::Open, FileAccess::Read, FileShare::Read);

        JpegBitmapDecoder^ decoder = gcnew JpegBitmapDecoder(imageStreamSource, BitmapCreateOptions::PreservePixelFormat, BitmapCacheOption::Default);
        BitmapSource^ bitmapSource = decoder->Frames[0];//< --mamy bitmape
        // Draw the Image
        System::Windows::Controls::Image^ myImage = gcnew System::Windows::Controls::Image();  //<--- this image in the Form1  -------
        myImage->Source = bitmapSource;
        myImage->Stretch = Stretch::None;


//CONVERT MYIMAGE INTO C++ BMP

    return 0;
}
//a.cpp:主项目文件。
#包括“stdafx.h”
#包括“表格1.h”
#使用//需要CLI
使用名称空间系统;
使用名称空间系统::IO;
使用命名空间System::Windows::Media::Imaging;
使用命名空间System::Windows::Media;
使用命名空间系统::Windows::控件;
使用名称空间a;
[属性]
int main(数组^args)
{
//在创建任何控件之前启用Windows XP视觉效果
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
//创建主窗口并运行它
应用程序::运行(gcnewform1());
//打开流并解码JPEG图像
Stream^imageStreamSource=gcnewfilestream(“C:/heart.jpg”,FileMode::Open,FileAccess::Read,FileShare::Read);
JpegBitmapDecoder^decoder=gcnew JpegBitmapDecoder(imageStreamSource,BitmapCreateOptions::PreservePixelFormat,BitmapCacheOption::Default);
BitmapSource ^BitmapSource=解码器->帧[0];/<--mamy bitmape
//画图像
System::Windows::Controls::Image ^myImage=gcnew System::Windows::Controls::Image();//Source=bitmapSource;
myImage->Stretch=Stretch::无;
//将MIG图像转换成C++ BMP
返回0;
}

试试这个方法。在那里,您可以保存到文件或流,并可以指定文件格式。

是否可以直接从c++/cli编辑像素?图形可用于访问位图像素。