View Issue Details

IDProjectCategoryView StatusLast Update
0001444NoesisGUIC++ SDKpublic2019-04-08 11:33
ReporterdecaiAssigned Tosfernandez 
Status feedbackResolutionopen 
Product Version2.2.1 
Target VersionFixed in Version 
Summary0001444: BitmapSource::Create from MFC CImage Bits crashed on x64
DescriptionWe add bellow code in HelloWorld sample for test create BitmapSource from MFC CImage.
When we build x86 is ok, when we changed to x64 the app crashed as "Exception thrown at 0x00007FFA47395280 (Noesis.dll) in Samples.HelloWorld.exe: 0xC0000005: Access violation reading location 0x000002380DFF52B3." at the line BitmapSource::Create.

We just modiy the HelloWorld sample.




2019-04-05 13:46


Main.cpp (2,807 bytes)
1.png (7,339 bytes)
1.png (7,339 bytes)


2019-04-05 21:15

manager   ~0005600

Could you also attach a minidump please?



2019-04-06 11:20

reporter   ~0005603

Last edited: 2019-04-06 11:28

View 2 revisions

here is the dump:



2019-04-08 11:33

manager   ~0005614

Hi, according to CImage documentation:, if the pitch value returned by the CImage is negative it indicates that it is creating a bottom-up DIB, and the pointer returned by GetBits() points to the last row of the image. That is the case with the image you supplied.

Our BitmapSource::Create() expects a positive stride and a pointer to the first pixel in the buffer, but I see we are not checking this and no error message explaining what happened is shown, so we will add it for next versions.

Your code should look as follows to properly work:
CImage *image = new CImage();
HRESULT sr = image->Load("d:\\1.png");
if (sr == S_OK)
    int w = image->GetWidth();
    int h = image->GetHeight();
    uint8_t *data = (uint8_t*)image->GetBits();
    int pitch = image->GetPitch();
    float dpi = 96.0f;

    if (pitch < 0)
        pitch = -pitch;
        data = data - (h - 1) * pitch;

    BitmapSource::Format bitmapFormat = Noesis::BitmapSource::Format_BGRA8;
    auto imageSource = BitmapSource::Create(w, h, dpi, dpi, data, pitch, bitmapFormat);
    if (imageSource)
        printf("image source create ok");

Issue History

Date Modified Username Field Change
2019-04-05 13:46 decai New Issue
2019-04-05 13:46 decai Tag Attached: C++
2019-04-05 13:46 decai File Added: Main.cpp
2019-04-05 13:46 decai File Added: 1.png
2019-04-05 16:19 sfernandez Assigned To => sfernandez
2019-04-05 16:19 sfernandez Status new => assigned
2019-04-05 21:15 jsantos Note Added: 0005600
2019-04-05 21:15 jsantos Status assigned => feedback
2019-04-06 11:20 decai Note Added: 0005603
2019-04-06 11:20 decai Status feedback => assigned
2019-04-06 11:28 decai Note Edited: 0005603 View Revisions
2019-04-08 11:33 sfernandez Status assigned => feedback
2019-04-08 11:33 sfernandez Note Added: 0005614