News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Graphic Library

Started by Grincheux, February 18, 2007, 06:16:05 PM

Previous topic - Next topic

six_L

Hello,Grincheux
help me how clear screen.
.386
.Model Flat, StdCall
Option Casemap :None
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\gdiplus.inc
include \masm32\include\gdi32.inc
include \masm32\include\debug.inc

includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\gdiplus.lib
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\debug.lib
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
S macro pdata:VARARG
LOCAL Buff
.data
ifidni <pdata>,<>           
Buff db 0       
else           
Buff db pdata,0
endif
.code
exitm <OFFSET Buff>
endm
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
GdiplusStartupInput STRUCT
GdiplusVersion           DWORD ?
DebugEventCallback       DWORD ?
SuppressBackgroundThread DWORD ?
SuppressExternalCodecs   DWORD ?
GdiplusStartupInput ENDS
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.const
RR equ 30       
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.data?
sRect RECT {?}
hInstance HINSTANCE ?
hWin HANDLE ?
gdiplusToken dd ?
mouseRup_flag dd ?
x1 dd ?
y1 dd ?
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.code
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
OnDraw1 proc uses ebx ecx edx esi edi hdc,x0,y0,w0,h0
local @Pen1,@pGraphics,@DashStyle

invoke GdipCreateFromHDC,hdc,addr @pGraphics

;invoke GdipGraphicsClear,@pGraphics,0FFFFFFFFh
invoke GdipCreatePen1,0FFFFA200h,03FFF0000h,0,addr @Pen1
mov @DashStyle,3
invoke GdipSetPenDashStyle,@Pen1,@DashStyle
mov eax,x0
mov ecx,y0
mov esi,w0
mov edi,h0
invoke GdipDrawRectangleI,@pGraphics,@Pen1,eax,ecx,esi,edi
invoke GdipDeletePen,@Pen1
invoke GdipDeleteGraphics,@pGraphics
ret
OnDraw1 endp
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
OnDraw proc uses ebx ecx edx esi edi hdc,x,y,lpRECT
local @Pen1,@Pen2,@pGraphics

.if x!=-1 && y!=-1
mov ebx,lpRECT
assume ebx:ptr RECT
invoke GdipCreateFromHDC,hdc,addr @pGraphics

;invoke GdipGraphicsClear,@pGraphics,0FFFFFFFFh
invoke GdipCreatePen1,0FF00FF00h,3F800000h,0,addr @Pen1
invoke GdipDrawLineI,@pGraphics,@Pen1,0,y,[ebx].right,y
invoke GdipDrawLineI,@pGraphics,@Pen1,x,0,x,[ebx].bottom

invoke GdipCreatePen1,0FFFF0000h,3F800000h,0,addr @Pen2
mov eax,x
sub eax,RR/2
mov ecx,y
sub ecx,RR/2
mov esi,RR
mov edi,RR
invoke GdipDrawEllipseI,@pGraphics,@Pen2,eax,ecx,esi,edi
;invoke GdipDrawRectangleI,@pGraphics,@Pen2,eax,ecx,esi,edi

invoke GdipDeletePen,@Pen1
invoke GdipDeletePen,@Pen2
invoke GdipDeleteGraphics,@pGraphics
assume ebx:nothing
.endif
ret
OnDraw endp
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
WndProc proc hWnd:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
local hdc,x,y

.if uMsg==WM_CREATE
push hWnd
pop hWin
mov mouseRup_flag,FALSE
mov x1,0
mov y1,0
.elseif uMsg==WM_DESTROY
invoke PostQuitMessage,NULL
.elseif uMsg==WM_SIZE
mov x,-1
mov y,-1
.elseif uMsg==WM_LBUTTONDOWN
movzx eax, word ptr lParam
mov x1, eax
movzx eax, word ptr lParam+2
mov y1, eax
mov mouseRup_flag, TRUE
;invoke ShowWindow, hWnd, SW_HIDE ;clear screen
;invoke ShowWindow, hWnd, SW_MAXIMIZE ;clear screen
.elseif uMsg==WM_MOUSEMOVE

invoke SetCursor,0
movzx eax, word ptr lParam
mov x, eax
movzx eax, word ptr lParam+2
mov y, eax
invoke GetDC,hWnd
mov hdc,eax
invoke GetClientRect,hWnd,addr sRect
invoke SetROP2,hdc,R2_XORPEN 
push eax
invoke OnDraw,hdc,x,y,addr sRect

.if mouseRup_flag==TRUE
mov     eax, x1
mov     ebx, y1
mov     ecx, x
mov     edx, y
.if (eax > ecx) && (ebx > edx)
xchg eax, ecx
xchg ebx, edx
.elseif (eax > ecx) && (ebx < edx)
xchg eax, ecx
.elseif (eax < ecx) && (ebx > edx)
xchg ebx, edx
.endif
sub ecx,eax
sub edx,ebx
invoke OnDraw1,hdc,eax,ebx,ecx,edx
.endif
pop eax
invoke SetROP2,hdc,eax                       
invoke ReleaseDC,hWnd,hdc

.elseif uMsg == WM_LBUTTONUP
mov mouseRup_flag, FALSE
;invoke ReleaseCapture
.elseif uMsg==WM_KEYUP
.if eax == 0Dh || 1BH ;ESCAPE KEY
invoke PostQuitMessage,NULL
.endif
.else
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.endif
xor    eax,eax
ret
WndProc endp
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
LOCAL wc   :WNDCLASSEX
LOCAL msg  :MSG
local hWnd :HWND
   
mov wc.cbSize,sizeof WNDCLASSEX
mov wc.style,CS_HREDRAW or CS_VREDRAW or CS_BYTEALIGNWINDOW
mov wc.lpfnWndProc,offset WndProc
mov wc.cbClsExtra,NULL
mov wc.cbWndExtra,NULL
push hInst
pop wc.hInstance
mov wc.hbrBackground,0;COLOR_BTNFACE+1           
mov wc.lpszMenuName,NULL
mov wc.lpszClassName,S("test")
invoke LoadIcon,hInst,100
mov wc.hIcon,eax
mov wc.hCursor,0
mov wc.hIconSm,0
invoke RegisterClassEx, ADDR wc
invoke CreateWindowEx,NULL,S("test"),S("test"),WS_POPUP or WS_POPUPWINDOW,\
0,0,400,200,NULL,NULL,hInst,NULL
mov hWnd,eax
invoke ShowWindow,hWnd,SW_MAXIMIZE
invoke UpdateWindow,hWnd
   
.while TRUE
invoke GetMessage,addr msg,0,0,0
.break .if (!eax)
invoke TranslateMessage,addr msg
invoke DispatchMessage,addr msg
.endw
   
mov eax,msg.wParam
ret

WinMain endp
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
InitGgdplus proc
local @gdis:GdiplusStartupInput

invoke RtlZeroMemory,addr @gdis,sizeof @gdis
mov @gdis.GdiplusVersion,1
invoke GdiplusStartup,addr gdiplusToken,addr @gdis,NULL
ret

InitGgdplus endp
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
start:
invoke GetModuleHandle, NULL
mov hInstance,eax
invoke InitGgdplus
invoke WinMain, hInstance,NULL,NULL,SW_SHOWDEFAULT
invoke GdiplusShutdown,gdiplusToken
invoke ExitProcess,eax
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

end start
regards

Grincheux

If you just just want to clear the screen I cannot see why you use de GDI+. You have two other ways.
First : Create a bitmap brush and set it into the WNDCLASSEX structure.
Second : On WM_PAINT just draw a rect using FillRect. You can mix with the WNDCLASSEX brush.

ClearScreen PROC USES EBX EDI ESI,__hWnd:HWND,__hDC:HDC
      LOCAL _hDC:HDC

      .IF __hDC == NULL
          INVOKE GetDC,__hWnd
          mov _hDC,eax
      .ELSE
          mov eax,__hDC
          mov _hDC,eax
      .ENDIF

      INVOKE FillRect,_hDC,ADDR rcWindow,hBrush

      .IF __hDC == NULL
         INVOKE ReleaseDC,__hWnd,_hDC
      .ENDIF

      ret
ClserScreen ENDP

Variables with one underscore are locals. Variables with two underscores are parameters. Variables without any underscore are globals.

It it can help you.
Kenavo

Grincheux
_____________________________________________________
http://www.phrio.biz

six_L

Hello,Grincheux
thank you very much.

QuoteVariables with one underscore are locals. Variables with two underscores are parameters. Variables without any underscore are globals.
[/b]
this's very helpful.

i wonder why gdi can do that and gdi+ can't.

[attachment deleted by admin]
regards

Grincheux

I look at your pgm, this very good :U. In the next version there will possibilities to draw effects following angles. This nearly is what I certainly have to do. This could be helpfull when adding tools.

Can you replace the ellipse by an image ?

If I had to do the same thing I would have use the LineDDA function. But I never have used it again.
It is a good idea... Bravo ! :U :U :U
Kenavo

Grincheux
_____________________________________________________
http://www.phrio.biz

six_L

Hello,Grincheux
QuoteCan you replace the ellipse by an image ?
did on gdi+
.386
.Model Flat, StdCall
Option Casemap :None
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\gdiplus.inc
include \masm32\include\gdi32.inc

includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\gdiplus.lib
includelib \masm32\lib\gdi32.lib
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
S macro pdata:VARARG
LOCAL Buff
.data
ifidni <pdata>,<>           
Buff db 0       
else           
Buff db pdata,0
endif
.code
exitm <OFFSET Buff>
endm
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
GdiplusStartupInput STRUCT
GdiplusVersion           DWORD ?
DebugEventCallback       DWORD ?
SuppressBackgroundThread DWORD ?
SuppressExternalCodecs   DWORD ?
GdiplusStartupInput ENDS
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.const
Rx equ 300       
Ry equ 200       
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.data

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.data?
sRect RECT {?}
hInstance HINSTANCE ?
hWin HANDLE ?
gdiplusToken dd ?
@pGraphics dd ?
@image dd ?
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.code
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
OnDraw proc uses ebx ecx edx esi edi hdc,x,y,lpRECT
local @Pen1,@Pen2,@Brush

.if x!=-1 && y!=-1
mov ebx,lpRECT
assume ebx:ptr RECT
invoke GdipCreateFromHDC,hdc,addr @pGraphics

;//-------------------------------------------------
invoke GdipGraphicsClear,@pGraphics,0FFFFFFFFh
invoke GdipCreatePen1,0FF00FF00h,3F800000h,0,addr @Pen1
invoke GdipDrawLineI,@pGraphics,@Pen1,0,y,[ebx].right,y
invoke GdipDrawLineI,@pGraphics,@Pen1,x,0,x,[ebx].bottom
;//-------------------------------------------------
invoke GdipCreateTexture,@image,0,addr @Brush
invoke GdipCreatePen2,@Brush,041D00000h,0,addr @Pen2 ;41200000h = 10.0

mov eax,x
sub eax,Rx/2
mov ecx,y
sub ecx,Ry/2
mov esi,Rx
mov edi,Ry

invoke GdipDrawEllipseI,@pGraphics,@Pen2,eax,ecx,esi,edi
mov eax,x
sub eax,Rx/2
add eax,260
mov ecx,y
sub ecx,Ry/2
sub ecx,200

invoke GdipFillEllipseI,@pGraphics,@Brush,eax,ecx,esi,edi
;//-------------------------------------------------
invoke GdipDeletePen,@Pen1
invoke GdipDeletePen,@Pen2
invoke GdipDeleteBrush,@Brush
invoke GdipDeleteGraphics,@pGraphics
assume ebx:nothing
.endif
@Exit:
ret
OnDraw endp
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
WndProc proc hWnd:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
local hdc,x,y
local @buf[16]:word

.if uMsg==WM_CREATE
push hWnd
pop hWin
invoke MultiByteToWideChar,CP_ACP,0,S("movie.jpg"),-1,addr @buf,16
invoke GdipLoadImageFromFile,addr @buf,addr @image
.if eax
invoke ExitProcess,NULL
.endif
.elseif uMsg==WM_DESTROY
invoke GdipDisposeImage,@image
invoke PostQuitMessage,NULL
.elseif uMsg==WM_SIZE
mov x,-1
mov y,-1
.elseif uMsg==WM_MOUSEMOVE
invoke SetCursor,0
movzx eax, word ptr lParam
mov x, eax
movzx eax, word ptr lParam+2
mov y, eax
invoke GetDC,hWnd
mov hdc,eax
invoke GetClientRect,hWnd,addr sRect
invoke OnDraw,hdc,x,y,addr sRect
invoke ReleaseDC,hWnd,hdc
.elseif uMsg==WM_KEYUP
.if eax == 0Dh || 1BH ;ESCAPE KEY
invoke GdipDisposeImage,@image
invoke PostQuitMessage,NULL
.endif
.else
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.endif
xor    eax,eax
ret
WndProc endp
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
LOCAL wc   :WNDCLASSEX
LOCAL msg  :MSG
local hWnd :HWND
   
mov wc.cbSize,sizeof WNDCLASSEX
mov wc.style,CS_HREDRAW or CS_VREDRAW or CS_BYTEALIGNWINDOW
mov wc.lpfnWndProc,offset WndProc
mov wc.cbClsExtra,NULL
mov wc.cbWndExtra,NULL
push hInst
pop wc.hInstance
mov wc.hbrBackground,0 ;COLOR_BTNFACE+1           
mov wc.lpszMenuName,NULL
mov wc.lpszClassName,S("test")
invoke LoadIcon,hInst,100
mov wc.hIcon,eax
mov wc.hCursor,0
mov wc.hIconSm,0
invoke RegisterClassEx, ADDR wc
invoke CreateWindowEx,NULL,S("test"),S("test"),WS_POPUP or WS_POPUPWINDOW,\
200,200,400,200,NULL,NULL,hInst,NULL
mov hWnd,eax
invoke ShowWindow,hWnd,SW_MAXIMIZE
invoke UpdateWindow,hWnd
   
.while TRUE
invoke GetMessage,addr msg,0,0,0
.break .if (!eax)
invoke TranslateMessage,addr msg
invoke DispatchMessage,addr msg
.endw
   
mov eax,msg.wParam
ret

WinMain endp
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
InitGgdplus proc
local @gdis:GdiplusStartupInput

invoke RtlZeroMemory,addr @gdis,sizeof @gdis
mov @gdis.GdiplusVersion,1
invoke GdiplusStartup,addr gdiplusToken,addr @gdis,NULL
ret

InitGgdplus endp
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
start:
invoke GetModuleHandle, NULL
mov hInstance,eax
invoke InitGgdplus
invoke WinMain, hInstance,NULL,NULL,SW_SHOWDEFAULT
invoke GdiplusShutdown,gdiplusToken
invoke ExitProcess,eax
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

end start

the attachment is the Exe file.

clearing screen has some troubles.

[edit]: add the movie.jpg

[attachment deleted by admin]
regards

Grincheux

On my PC there is nothing ! :'(
Kenavo

Grincheux
_____________________________________________________
http://www.phrio.biz

six_L

forget to give the movie.
regards

Grincheux

Kenavo

Grincheux
_____________________________________________________
http://www.phrio.biz

six_L

hello,Grincheux
can still not show the result of running?
let me know.

put an image in the dir which there is the xyimg_1.exe, and change the image name into "movie.jpg" .
regards

Grincheux

 :U
Now it works fine.

Just a suggestion : Can you delete the blinking effect ?

What do you want to do with this program ?
Kenavo

Grincheux
_____________________________________________________
http://www.phrio.biz

six_L

Hello,Grincheux
QuoteCan you delete the blinking effect ?
although i try hardly to figure out the problem(Clear screen), until now i can't get any progress. hope someone would help me.

QuoteWhat do you want to do with this program ?
continue your work for making a simple and rapid image viewer, simultaneous wasting my leisure times.

now a digital photo has 10M sizes. there are a hundred digital photos in a directory. if all of them are been added into imagelist with multithread, the pc will be dead quickly.  i want know how do you handle the bigger image(JPG OF 10M) with simultaneity.
regards

Grincheux

When a user selects a folder, I-View searches for all files. It creates a temp file each time it has found one hundred files. I think the file search is very quick. Copy it, it seems that it is what you are searching for.
Kenavo

Grincheux
_____________________________________________________
http://www.phrio.biz

Grincheux

A new major update has been released. You can download sources files at http://www.idcat39.com/download.IVSrc.exe and the binaries can be dowloaded at http://www.idcat39.com/download/IVBin.exe.

1-This update doesn not permit to select the zoom toolbar icon until an image is selected.
2-You can now select the default language.
3-You can modify some parameters and translate virtual folders name for each installated language.

Have fun
Kenavo

Grincheux
_____________________________________________________
http://www.phrio.biz

Grincheux

A new major update has been released. You can download sources files at http://www.idcat39.com/download.IVSrc.exe and the binaries can be dowloaded at http://www.idcat39.com/download/IVBin.exe.

1-This update doesn not permit to select the zoom toolbar icon until an image is selected.
2-You can now select the default language.
3-You can modify some parameters and translate virtual folders name for each installated language.

Have fun
Kenavo

Grincheux
_____________________________________________________
http://www.phrio.biz

ipadilla

Hi Philippe,
I am trying to send you the Spanish Language translation to your forum , but I can not attach the .zip on it. Here you are the .dll .

.ini file
-----------------------------
[I-View]
Language=3

[Constants]
Auto save effects=1
Diapo Height=192
Diapo Width=256
Max Files Per Folder=1000
Number of pictures per page=10000

[Directories]
Main Directory=C:\I-View
Masks Directory=C:\I-View\Masks
Pattern Mask Directory=C:\I-View\Motifs\Masks
Patterns Directory=C:\I-View\Motifs
Temporary Directory=C:\I-View\Temp

[Images]
Diapo Normale=C:\I-View\Images\Diapo Normale.jpg
Diapo Selectionnee=C:\I-View\Images\Diapo Selectionnee.jpg
Preview Pattern=C:\I-View\Images\Fond Preview.bmp

[Languages]
1=Français
2=Anglais
3=Español

[Languages Files]
Anglais=Langues\English.dll
Français=Langues\French.dll
Español=Langues\Spanish.dll


[Français]
Poste de Travail=Poste de Travail
Bureau=Bureau
Mes Documents=Mes Documents
Mes Images=Mes Images
Mes Videos=Mes Vidéos
Ma Musique=Ma Musique

[Anglais]
Poste de Travail=My Computer
Bureau=Desktop
Mes Documents=My Documents
Mes Images=My Images
Mes Videos=My Videos
Ma Musique=My Music

[Español]
Poste de Travail=Mi PC
Bureau=Desktop
Mes Documents=Mis Documentos
Mes Images=Mis Imágenes
Mes Videos=Mis Videos
Ma Musique=Mi Música


ipadilla

[attachment deleted by admin]