DMagick image processing with D.

Andrej Mitrovic andrej.mitrovich at gmail.com
Wed Nov 2 19:07:33 PDT 2011


On 11/3/11, Andrej Mitrovic <andrej.mitrovich at gmail.com> wrote:
> Unhandled Exception: EXCEPTION_ACCESS_VIOLATION(0xc0000005) at
> CORE_RL_magick_.dll (0x100c1267) thread(3440)

I think I've found the issue:

void[] pixels = new T[area.width*area.height];

Here you're allocating width*height, but you didn't take into account
that each exported channel specified by map will need more
width*height storage. Here's what I did to fix it:

import std.utf;
auto pixels = new T[]((area.width * area.height) * map.count);
// call ExportImagePixels
return pixels;

I think the DLL tried to write to memory beyond what the GC allocated
for the array, and hence the access violation.


More information about the Digitalmars-d-announce mailing list