Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8909133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:21:25+00:00 2026-06-15T03:21:25+00:00

Given the following Bitmap raw image data in char array Image width and height

  • 0

Given the following

  • Bitmap raw image data in char array
  • Image width and height
  • Path wzAppDataDirectory in std::wstring generated using the following code

// Get a good path.
wchar_t wzAppDataDirectory[MAX_PATH];
wcscpy_s( wzAppDataDirectory, MAX_PATH, Windows::Storage::ApplicationData::Current->LocalFolder->Path->Data() );
wcscat_s( wzAppDataDirectory, MAX_PATH, (std::wstring(L"\\") + fileName).c_str() );

How can we save the image as JPG? (Include encoding as well as the char array is raw bitmap form)

Code example is very much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T03:21:26+00:00Added an answer on June 15, 2026 at 3:21 am

    This is an example code which I obtained from my friend.

    It uses OpenCV’s Mat data structure. Note that, you need to ensure the unsigned char data array within cv::Mat is in continuous form. cv::cvtColor will do the trick (Or, cv::Mat.clone).

    Take note, do not use OpenCV’s imwrite. As at current time of writing, imwrite doesn’t pass Windows Store Certification Test. It is using several APIs, which is prohibited in WinRT.

    void SaveMatAsJPG(const cv::Mat& mat, const std::wstring fileName)
    {
        cv::Mat tempMat;
        cv::cvtColor(mat, tempMat, CV_BGR2BGRA);
    
        Platform::String^ pathName = ref new Platform::String(fileName.c_str());
    
        task<StorageFile^>(ApplicationData::Current->LocalFolder->CreateFileAsync(pathName, CreationCollisionOption::ReplaceExisting)).
        then([=](StorageFile^ file)
        {
            return file->OpenAsync(FileAccessMode::ReadWrite);
        }).
        then([=](IRandomAccessStream^ stream)
        {
            return BitmapEncoder::CreateAsync(BitmapEncoder::JpegEncoderId, stream);
        }).
        then([=](BitmapEncoder^ encoder)
        {
            const Platform::Array<unsigned char>^ pixels = ref new Platform::Array<unsigned char>(tempMat.data, tempMat.total() * tempMat.channels());
            encoder->SetPixelData(BitmapPixelFormat::Bgra8, BitmapAlphaMode::Ignore, tempMat.cols , tempMat.rows, 96.0, 96.0, pixels);
            encoder->FlushAsync();
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

// given following array: $data = array( 0=>array( data=>object1, col=>array( 0=>array( data=>object2, col=>array( 0=>array(
Given the following code public static Bitmap PrintWindow(IntPtr hWnd) { int width = GetWindowInfo(hWnd).rcWindow.Width;
Given following array: var arr = [undefined, undefined, 2, 5, undefined, undefined]; I'd like
Given: A Flex TileList with the following event: <mx:nativeDragDrop> <![CDATA[ if(event.clipboard.hasFormat(ClipboardFormats.FILE_LIST_FORMAT)) { var files:Array
Given following Statment: String query = "Select * from T_spareParts where SparePartPK IN (?
Installing egit on indigo im given following options : I've just checked 'Eclipse Egit'
Given the following code: $(.force-selection).blur(function() { var value = $('matched-item').val(); //check if the input's
Given the following code: final class retVal { int photo_id; } Gson gson =
Given the following XML: <Contact> <ContactID>41111-f15a-4fa1-b643-47877608f557</ContactID> <ContactStatus>ACTIVE</ContactStatus> <Name>ABC Ltd</Name> <EmailAddress>xxx@xxx.co</EmailAddress> <SkypeUserName>xxxdemo</SkypeUserName> <Addresses> <Address> <AddressType>STREET</AddressType>
Given the following models: team.rb class Team < ActiveRecord::Base has_many :events, :dependent => :destroy

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.