繁体   English   中英

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

[英]How to convert CLI Image^ into any standard C++ bitmap

我已经将JPG图像加载到Image^对象,但是现在我想“返回”在程序中使用标准C ++,因此我想以某种方式将Image ^对象转换为任何BMP class Object (我不知道哪个c ++类很好)。

我想编辑该位图中特定像素的颜色。

请帮我做。

   // 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;
}

尝试使用Image.save方法。 您可以在那里保存到文件或流,并可以指定文件格式。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM