The MASM Forum

General => The Campus => Topic started by: Fraile on October 23, 2015, 05:56:29 AM

Title: level lower the compression in images jpg.
Post by: Fraile on October 23, 2015, 05:56:29 AM
Hi all,

how I can, lower the resolution the compression to image JPG, with the  GdipSaveImageToStream function. using EncoderParameters?

thank you

Title: Re: level lower the compression in images jpg.
Post by: qWord on October 23, 2015, 06:09:18 AM
Using Image Encoders and Decoders (https://msdn.microsoft.com/en-us/library/windows/desktop/ms533814%28v=vs.85%29.aspx) (see the point: Setting JPEG Compression Level)
Title: Re: level lower the compression in images jpg.
Post by: Vortex on October 23, 2015, 06:35:35 AM
The member named value of the structure EncoderParameter is storing the compression ratio :

EncoderParameter STRUC
    pGUID             GUID  <>
    NumberOfValues    DWORD ?
    vType             DWORD ?
    value             DWORD ?
EncoderParameter ENDS

EncoderParameters STRUC
    Count       DWORD ?
    Parameter   EncoderParameter <>
EncoderParameters ENDS


.data
ImgQuality dd  50
.
.
.code
mov EncoderParameters.Parameter.value[esi],OFFSET ImgQuality


An example :

http://www.jose.it-berater.org/smfforum/index.php?topic=1860.0
Title: Re: level lower the compression in images jpg.
Post by: dedndave on October 23, 2015, 08:03:11 AM
this is an interesting subject   :biggrin:

i have an older program named PicView
it seems to use IImageCtx to work with JPG's
when i convert an image to JPG, it offers controls for both "Quality" and "Smoothing"
i haven't taken the time to figure out how it works   :P
Title: Re: level lower the compression in images jpg.
Post by: TWell on October 23, 2015, 09:06:45 AM
CLSID EncoderQuality {1D5BE4B5-FA4A-452D-9CDD-5DB35105E7EB} ?
This way?EncoderQuality GUID <01D5BE4B5H,0FA4AH,0452DH,<09CH,0DDH,05DH,0B3H,051H,005H,0E7H,0EBH>>
uQuality dd 50
_EncPars EncoderParameters < 1, \
< <01D5BE4B5H,0FA4AH,0452DH,<09CH,0DDH,05DH,0B3H,051H,005H,0E7H,0EBH>>, 1, 4, uQuality> \
>
Title: Re: level lower the compression in images jpg.
Post by: Fraile on October 23, 2015, 08:32:35 PM
thank all, but Vortex, I have to move values to properties,  pGUID, NumberOfValues, vType?.
or not is necesary.
Title: Re: level lower the compression in images jpg.
Post by: TouEnMasm on October 24, 2015, 02:29:29 AM
MSDN show this method to change the format of a file
https://msdn.microsoft.com/en-us/library/windows/desktop/ms535406(v=vs.85).aspx
Title: Re: level lower the compression in images jpg.
Post by: Vortex on October 24, 2015, 05:44:02 AM
Hi AsmAlmeria12,

Attached is an example converting a bitmap to jpg.