gdi+ GdipCreateBitmapFromGraphics, 100, 50, gicbImg, addr hTmpBmp ; MasmForum (http://www.masmforum.com/board/index.php?topic=6494.0)
gdi+ GdipSaveImageToFile, hTmpBmp, wChr$("TestImage.gif"), addr gif, 0
gdi+ GdipSaveImageToFile, hTmpBmp, wChr$("TestImage.jpg"), addr jpeg, 0
gdi+ GdipSaveImageToFile, hTmpBmp, wChr$("TestImage2.jpg"), addr jpeg2, 0
gdi+ GdipSaveImageToFile, hTmpBmp, wChr$("TestImage3.jpg"), addr jpeg3, 0
gdi+ GdipSaveImageToFile, hTmpBmp, wChr$("TestImage.bmp"), addr bmp, 0
gdi+ GdipSaveImageToFile, hTmpBmp, wChr$("TestImage.png"), addr png, 0
gdi+ GdipDisposeImage, hTmpBmp
jpeg GuidFromString({557cf401-1a04-11d3-9a73-0000f81ef32e}) ; SOF
png GuidFromString({557cf406-1a04-11d3-9a73-0000f81ef32e})
jpeg2 GuidFromString({25336920-03F9-11cf-8FD0-00AA00686F13}) ; CLSID at:
; HKEY_CLASSES_ROOT\MIME\Database\Content Type\image/jpeg
; HKEY_LOCAL_MACHINE\SOFTWARE\Classes\MIME\Database\Content Type\image/jpeg
jpeg3 GuidFromString({607fd4e8-0a03-11d1-ab1d-00c04fc9b304})
gif GuidFromString({25336920-03F9-11cf-8FD0-00AA00686F13})
bmp GuidFromString({25336920-03F9-11cf-8FD0-00AA00686F13})
Trouble is that most of them fail - and the only one that doesn't bark at me creates a black image :(
** line 41, GdipCreateBitmapFromGraphics Ok
** line 42, GdipSaveImageToFile FileNotFound
** line 43, GdipSaveImageToFile Ok
** line 44, GdipSaveImageToFile FileNotFound
** line 45, GdipSaveImageToFile FileNotFound
** line 46, GdipSaveImageToFile FileNotFound
** line 47, GdipSaveImageToFile Ok
** line 48, GdipDisposeImage Ok
Hi Jochen,
Here is an example.
Build in encoders:
Clsid: {557CF400-1A04-11D3-9A73-0000F81EF32E}
FormatID: {B96B3CAB-0728-11D3-9D7B-0000F81EF32E}
CodecName: Built-in BMP Codec
FormatDescription: BMP
FilenameExtension: *.BMP;*.DIB;*.RLE
MimeType: image/bmp
Version: 1
Clsid: {557CF401-1A04-11D3-9A73-0000F81EF32E}
FormatID: {B96B3CAE-0728-11D3-9D7B-0000F81EF32E}
CodecName: Built-in JPEG Codec
FormatDescription: JPEG
FilenameExtension: *.JPG;*.JPEG;*.JPE;*.JFIF
MimeType: image/jpeg
Version: 1
Clsid: {557CF402-1A04-11D3-9A73-0000F81EF32E}
FormatID: {B96B3CB0-0728-11D3-9D7B-0000F81EF32E}
CodecName: Built-in GIF Codec
FormatDescription: GIF
FilenameExtension: *.GIF
MimeType: image/gif
Version: 1
Clsid: {557CF405-1A04-11D3-9A73-0000F81EF32E}
FormatID: {B96B3CB1-0728-11D3-9D7B-0000F81EF32E}
CodecName: Built-in TIFF Codec
FormatDescription: TIFF
FilenameExtension: *.TIF;*.TIFF
MimeType: image/tiff
Version: 1
Clsid: {557CF406-1A04-11D3-9A73-0000F81EF32E}
FormatID: {B96B3CAF-0728-11D3-9D7B-0000F81EF32E}
CodecName: Built-in PNG Codec
FormatDescription: PNG
FilenameExtension: *.PNG
MimeType: image/png
Version: 1
Quote
Type: image/bmp, GUID: {557CF400-1A04-11D3-9A73-0000F81EF32E}
Type: image/jpeg, GUID: {557CF401-1A04-11D3-9A73-0000F81EF32E}
Type: image/gif, GUID: {557CF402-1A04-11D3-9A73-0000F81EF32E}
Type: image/tiff, GUID: {557CF405-1A04-11D3-9A73-0000F81EF32E}
Type: image/png, GUID: {557CF406-1A04-11D3-9A73-0000F81EF32E}
GetEncoderClsids proc
LOCAL num,_size,pImageCodecInfo
invoke GdipGetImageEncodersSize, addr num ,addr _size
.if _size
MOV pImageCodecInfo,halloc(_size)
invoke GdipGetImageEncoders,num, _size, pImageCodecInfo
MOV ESI,pImageCodecInfo
XOR EDI,EDI
@@:invoke StringFromGUID2,esi,addr strGuid,255
printf("\nType: %s,GUID: %s",[ESI].ImageCodecInfo.MimeType,addr strGuid)
ADD ESI, sizeof ImageCodecInfo
INC EDI
CMP EDI,num
JNE @B
hfree(pImageCodecInfo)
.endif
ret
GetEncoderClsids endp
Thanks to all of you - that was truely inspiring (=I ruthlessly stole your ideas) :biggrin:
Jokes apart, I got it running, see here (http://masm32.com/board/index.php?topic=94.msg61603#msg61603), but WOW, Microsoft has built features into GdiPlus (https://social.msdn.microsoft.com/Forums/vstudio/en-US/d603d347-53ec-4b82-be4b-7581a485d61c/gdiplus-lock-the-file-not-able-to-delete?forum=vclanguage) that I would never had thought of :dazzled:
QuoteDesperate user: While loading a JPG file using Gdiplus::Bitmap::FromFile(fileName), the file is being locked, so i am not able to delete the file.
...
Expert: GDI+ does tend to hold files open for images for the duration of the image.
Yeah, it "does tend", actually it defends the files like a lioness her kids until you shut down GdiPlus completely. It's almost as perfect as the RichEdit control :greensml:
But I cheated them, and a simple
SaveImageToFile wFiles$(imgCt) will do the job now :P
The "w" before Files$() simply means it expects Unicode, so that you can drag your Arabic ladies collection over the exe 8)
Quote from: Vortex on November 06, 2016, 07:30:44 PM
Hi Jochen,
Here is an example.
Thanks very much for this excellent info. Exactly what I was looking for. :t
MSDN is less helpful than usual here, they just tell you to use the C++ Class.
... read some code .... notices some stuff .... brain starts to hurt ...reads a bit more ....gets dizzy ..... OMG its actually built that way ;) lol ok ok ... I get it, but seriously thanks for the info, cool snippet.