(Howto) Convert a vpi Picture to a GDI+ Image
Posted: 18 May 2006 8:47
After some searching on the web, I manage to convert
a vpi Picture to a gdi+ Image:
The above globalAlloc and globalLock are the usual C equivalent
of the same name.
I have yet to find a way to convert the other way round, i.e. from
Image to Picture (other than saving the Image as a file and reading
the file using vpi).
Chan Bok
Axon Research
a vpi Picture to a gdi+ Image:
Code: Select all
gpPictToImage(Pict,Image):-
PictBin = vpi::pictToBin(Pict),
MemSize = binary::getSize(PictBin),
HGlobal = util::globalAlloc(0x0042,MemSize),
% GMEM_MOVEABLE + GMEM_ZEROINIT = 0x0002 + 0x0040
Pointer = util::globalLock(HGlobal),
PointerBin = uncheckedConvert(pointer,PictBin),
memory::copy(Pointer,PointerBin,MemSize),
_ = createStreamOnHGlobal(HGlobal,b_true,Stream), % b_true = DeleteOnRelease
_ = gdip::gdipLoadImageFromStream(Stream,Image).
of the same name.
I have yet to find a way to convert the other way round, i.e. from
Image to Picture (other than saving the Image as a file and reading
the file using vpi).
Chan Bok
Axon Research