I have loaded an JPG image to the Image^
object but now I would like to "go back" to using standard C++ in my program so I would like to somehow convert Image^ object into any BMP class Object
(I don't know which c++ class is good).
I would like to edit color of particular pixels in that bitmap.
Please help me do it.
// 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;
}
try the Image.save method. There you can save to a file or stream and you can specify the file format.