News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Help me/ jpeg compression using masam32

Started by hamidfarhadiyan2, March 14, 2014, 08:21:19 AM

Previous topic - Next topic

hamidfarhadiyan2

Hi
I am working on a program that it is to be capturing screenshots
I created of it 80%, But I have a problem, It can capturing screenshots with .bmp and size each screenshots is very big, "about 1.5 mb"

I needing to a "jpeg compression using masam32" or a "jpeg compression sample codes masm" or a "gdi+ jpeg saving using masm32"
that it be could capturing screenshots with .jpeg format and size each screenshots to be with "low quickly" and size it  " like 70 kb"
Shrink the image using low-quality interpolation

Please help me

MichaelW

#1
No comments or error handling, and no control over the encoder parameters:


;==============================================================================
    include \masm32\include\masm32rt.inc
    include \masm32\include\gdiplus.inc
    includelib \masm32\lib\gdiplus.lib
;==============================================================================
    .data
    .code
;==============================================================================
GdipBmpToJpg proc uses ebx esi pBmpFilename:DWORD, pJpgFilename:DWORD

    LOCAL token:DWORD
    LOCAL image:DWORD
    LOCAL numEncoders:DWORD
    LOCAL sizeImageCodecInfo:DWORD
    LOCAL gdipsi:GdiplusStartupInput

    invoke RtlZeroMemory, ADDR gdipsi, SIZEOF GdiplusStartupInput + 16
    mov gdipsi.GdiplusVersion, 1

    invoke GdiplusStartup, ADDR token, ADDR gdipsi, NULL
    invoke GdipLoadImageFromFile, pBmpFilename, ADDR image
    invoke GdipGetImageEncodersSize, ADDR numEncoders, ADDR sizeImageCodecInfo
    mov esi, alloc(sizeImageCodecInfo)
    invoke GdipGetImageEncoders, numEncoders, sizeImageCodecInfo, esi

    xor ebx, ebx
    .WHILE ebx < numEncoders
        .IF ucmp$([esi].ImageCodecInfo.MimeType, uni$("image/tiff"))
            invoke GdipSaveImageToFile, image, pJpgFilename, esi, NULL
            printf("%d\n\n",eax)
            .BREAK
        .ENDIF
        add esi, SIZEOF ImageCodecInfo
        inc ebx
    .ENDW

    invoke GdipDisposeImage, image
    invoke GdiplusShutdown, token
    free esi

    ret
GdipBmpToJpg endp
;==============================================================================
start:
;==============================================================================

    invoke GdipBmpToJpg, uni$("\masm32\examples\exampl04\car\car.bmp"),
                         uni$("out.jpg")

    inkey
    exit
;==============================================================================
end start

%StatusOk = 0
%StatusGenericError = 1
%StatusInvalidParameter = 2
%StatusOutOfMemory = 3
%StatusObjectBusy = 4
%StatusInsufficientBuffer = 5
%StatusNotImplemented = 6
%StatusWin32Error = 7
%StatusWrongState = 8
%StatusAborted = 9
%StatusFileNotFound = 10
%StatusValueOverflow = 11
%StatusAccessDenied = 12
%StatusUnknownImageFormat = 13
%StatusFontFamilyNotFound = 14
%StatusFontStyleNotFound = 15
%StatusNotTrueTypeFont = 16
%StatusUnsupportedGdiplusVersion = 17
%StatusGdiplusNotInitialized = 18
%StatusPropertyNotFound = 19
%StatusPropertyNotSupported = 20


http://www.jose.it-berater.org/gdiplus/iframe/index.htm
Well Microsoft, here's another nice mess you've gotten us into.

Gunther

Hi Michael,

Quote from: MichaelW on March 14, 2014, 12:32:22 PM
http://www.jose.it-berater.org/gdiplus/iframe/index.htm

very good reference link. Thank you.

Gunther
You have to know the facts before you can distort them.

hamidfarhadiyan2

Michael very very thanks for help to me
You are a big man

vishwadt

thank you very much for reference link  :eusa_clap:
http://www.jose.it-berater.org/gdiplus/iframe/index.htm

Vortex

Hi hamid,

Also don't forget to check the masm32 imagine routines capable of loading .jpg images.