News:

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

Main Menu

Sending images to a window in two lines

Started by TouEnMasm, May 08, 2013, 02:48:24 PM

Previous topic - Next topic

TouEnMasm

Those three samples need only two lines to put one image in a window.
The first line give you a dc object for the wmpaint message.
The second line is in the WM_PAINT message.
The image could be in a resource or in the directory of the .exe.
The Imgctx interface (problem with windows 7) allow you to use various formats of images,png,jpg,gif ...
It's the more simple way to put images in a window.

The image.zip made the same thing but with the IPicture interface.
Less differents formats are supported.He would work with windows 7

The gdiplus_dcobject.zip use gdiplus to do the same thing.
This allow to use png and jpg format.
If you used a resource file delare it as follow:
Quote
1200 RCDATA "ShapesR90.jpg"
You need also to add the init of gdiplus in your source code.
.sdk files are here:
http://masm32.com/board/index.php?topic=563.msg4563#msg4563

Fa is a musical note to play with CL

qWord

Seems to not work on Win7.
The call to IImgCtx::StretchBlt(...) doesn't look correct, especially the last parameter:
COM pfam,StretchBlt,Ps.hdc,0,0,long,400,0,0,DCfam.x,DCfam.y,DCfam.Hdc ; dwROP =! HDC
MREAL macros - when you need floating point arithmetic while assembling!

TouEnMasm

Have you try it in debug version builded on your system ?.
I have verify the stack before and after the call ,it's ok and it work with XP.
Perhaps coded in c ?
Fa is a musical note to play with CL

qWord

The method fails with E_NOINTERFACE - stepping through the call shows that the function is not implemented (mov eax,E_NOINTERFACE ; ret;). Either there are some COM settings that block the method or Microsoft has simply remove it. Regardless that, the last parameter of IImgCtx::StretchBlt describes the raster operation and not a DC. (e.g. SRCCOPY).


BTW: I would build the application if there were some comments on the dependencies and where to get the needed includes :t
MREAL macros - when you need floating point arithmetic while assembling!

TouEnMasm

Just stay to find where is the second hdc in the declaration.
STDMETHOD(StretchBlt)\
(THIS_ HDC hdc, int dstX, int dstY, int dstXE, int dstYE, int srcX,\
       int srcY, int srcXE, int srcYE, DWORD dwROP

Only ONE !
the DWORD dwROP is where it work (normally SRCCOPY)
Need chance to solve that.

To build you need only,the full sdk translate:
http://masm32.com/board/index.php?topic=563.0

I have try the define prototype of StretchBlt (without using the function):
invoke StretchBlt,Ps.hdc,0,0,long,haut,DCfam.Hdc,0,0,DCfamx,DCfam.y,SRCCOPY
no chance.
Fa is a musical note to play with CL


qWord

Quote from: ToutEnMasm on May 09, 2013, 02:54:53 AM
Just stay to find where is the second hdc in the declaration.
STDMETHOD(StretchBlt)\
(THIS_ HDC hdc, int dstX, int dstY, int dstXE, int dstYE, int srcX,\
       int srcY, int srcXE, int srcYE, DWORD dwROP

Only ONE !
the DWORD dwROP is where it work (normally SRCCOPY)
Need chance to solve that.
there is no need for a source-DC, because the source is the image object that is accessed through the IImgCtx interface.
I've test the method with my own example and it does also not work (however, ImgCtx::Draw() works) - I'm afraid that this functionality is no longer available or that there are some unknown requirements ... that's why we should not use undocumented stuff  :biggrin:

Quote from: ToutEnMasm on May 09, 2013, 02:54:53 AMTo build you need only,the full sdk translate:
http://masm32.com/board/index.php?topic=563.0
OK - and where to get sdk32.inc?
MREAL macros - when you need floating point arithmetic while assembling!

TouEnMasm


Here,it is the more simple one
Quote
comment * «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

    The SDK32 Runtime Library include file.

  ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««« *

         .686P   
      .XMM
      .MMX
                                 
         .model flat, stdcall                     
         option casemap :none               

   .NOLIST         ;signifie: ne rien mettre dans le listing

   include translate.inc   ;SDK translate include files (voir mon site)
   include windows.sdk

;     libraries
;     ~~~~~~~~~
    ; ------------------------------------------
    ; import libraries for Windows API functions
    ; ------------------------------------------
      includelib gdi32.lib
      includelib user32.lib
      includelib kernel32.lib
      includelib Comctl32.lib
      includelib comdlg32.lib
      includelib shell32.lib
      includelib oleaut32.lib
      includelib ole32.lib

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
I am making the same sample,with documented interface.

Fa is a musical note to play with CL

dedndave

i remember reading the the imgctx stretchblt was broken in windows 7
because it is poorly documented, you may have to play with parameters to make it work

qWord

Quote from: dedndave on May 09, 2013, 08:09:34 AM
i remember reading the the imgctx stretchblt was broken in windows 7
because it is poorly documented, you may have to play with parameters to make it work
that is a good argument ( :icon_mrgreen: ) ... however I've already played with it and I wasn't able to get it work... :(
Also, the comments on codeproject indicates that's the API is broken.
MREAL macros - when you need floating point arithmetic while assembling!

dedndave

well - you don't have to use it - we really only need the load and save functions
you can use regular GDI StretchBlt to make it fit   :P

TouEnMasm


I have added (in the first post) image.zip who would work with windows 7
He do the same things with less suported formats.
Fa is a musical note to play with CL

TouEnMasm


This last sample,use gdiplus to do the same thing (jpg and png).
I have added (in the first post) gdiplus_dcobject.zip.
Show also how to use a resource with gdi+ (it is special).

Fa is a musical note to play with CL