The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Faiseur on May 25, 2005, 05:07:00 PM

Title: Function of gdi+
Post by: Faiseur on May 25, 2005, 05:07:00 PM
Hello all,

I am irritated because I do not convert correctly a code VB (or C++) of GDI+ in asm. I want to save an image bitmap in JPEG file with the library GDI+.  That functions !  But if I want to change the quality of the encoding, to decrease the size of the image further,  that does not function apparently, because the size of the saved image does not change...   

If somebody already used this function thank you to light me! And sorry for my bad english. I think that the problem is in the adjustment of the encoding. Here the portion of the code. 



EncoderParameter  STRUC 
pGUID             DWORD ?   
NumberOfValues    DWORD ?   
vType             DWORD ? 
value             DWORD ?           
EncoderParameter  ENDS


EncoderParameters   STRUC 
  Count              DWORD ?                 
Parameter          EncoderParameter <>   
EncoderParameters   ENDS

.data
DecodeParam EncoderParameters <>

EncQuality  dd 1D5BE4B5h
dw 0FA4Ah
dw 452Dh
db 9ch,0ddh,5dh,0b3h,51h,05h,0e7h,0ebh

code.
...

; PBitmap <--- handle of a picture BMP

invoke GdipCreateBitmapFromHBITMAP,PBitmap,0,addr lpImgPtr

mov [DecodeParam].EncoderParameters.Count,1
mov [DecodeParam].EncoderParameters.Parameter.pGUID,offset EncQuality
mov [DecodeParam].EncoderParameters.Parameter.NumberOfValues,1
mov [DecodeParam].EncoderParameters.Parameter.vType,4
mov [DecodeParam].EncoderParameters.Parameter.value,18 ; quality !

invoke GdipSaveImageToFile,lpImgPtr ,addr lzDestFile,Encoder,addr DecodeParam

...



Result: Image saved ok, but size not change if quality value change...
Title: Re: Function of gdi+
Post by: dougiem on May 25, 2005, 09:43:13 PM
Hi Faiseur,
the line,
Quotemov [DecodeParam].EncoderParameters.Parameter.pGUID,offset EncQuality
the pGUID is a structure for a GUID not for a pointer.

EncoderParameter  STRUC  ; NOTE: pGUID is a GUID STRUCTURE
pGUID             GUID <?> ; GUID
NumberOfValues    DWORD ? 
vType             DWORD ? ; EncoderParameterValueType
value             DWORD ?
EncoderParameter  ENDS

You have to get the GUID for the installed image encoder in unitext.
I wrote some examples in The WorkShop "GDI+ Images". (these were on a 98 with gdi+ installed)
( see GetEncoderClsid proc )

There are a host of gdi ways to create images I hope this helps.
dougiem
Title: Re: Function of gdi+
Post by: Faiseur on May 25, 2005, 11:01:28 PM
Hi dougiem,

very, very thanks for your help. Its ok !!


I do not understand why your work ("gdipfunctions.asm","gdiplus_structs.inc" update) is not in post it... 

It is really useful to those which need some.

Still thank you...

Best regards,

Faiseur