³o¤@³¹±N²³æ¤¶²Ð GDI¡Ï¡A¨Ã¥H¥»³¹¤¶²Ðªº´XÓ API ¼¶¼g¤@Ó¥i¥HÆ[¬Ý¼ÆºØ®æ¦¡ªºÀ³¥Îµ{¦¡¡C
¦b²Ä¤K³¹®É´¿¤¶²Ð¹L GDI¡]graphics device interface¡A¹Ï§Î¸Ë¸m¤¶±¡^¡A´£¨Ñ¤F»P©PÃä¸Ë¸mµLÃöªºµ{¦¡³]p¤è¦¡¡A¬Æ¦Ü³s Windows §@·~¨t²Î¥»¨¦bø»s¦UÃþ¤¸¥ó¤]³£¾a GDI¡C¦Ó¥»³¹n¤¶²Ðªº GDI¡Ï ¬O¦b¨ä«á¥[¤W¤@Ó¡u¡Ï¡v¡AÅãµM¥i¥H²³æ¦a»{¬°¬O GDI ªº¤É¯Å§ï¨}ª©¥»¡C
ªº½T¦p¦¹¡C¦Û Windows XP ¤Î Windows Server 2003 ¶}©l¥[¤J GDI¡Ï¤§«á¡A¥¦¥i¥H»¡¬O§@·~¨t²Î¤ºªº¤@³¡¤À¤F¡C¥¦´£¨Ñ¤Gºû¦V¶q¹Ï§Î¡B¼v¹³³B²z©M¦L¨ê¼Ë¦¡¤T³¡¤À¡F¨C³¡¤À¦U¦Û¹ïì¨Óªº GDI ¶i¦æ¤F§ï¨}¡A¤]·s²K¤F¤@¨Ç¥\¯à¡C¹ï©ó¼v¹³¦Ó¨¥¡A¤ä´©§ó¦h®æ¦¡ªº¹Ï¤ùÀÉ¡A¥]¬A¤F PNG¡BJPG¡BGIF¡BExif¡BTIFF¡BWMF¡BEMF µ¥¡C
²Ä¤K³¹´£¹L¡AGDI ¶È¤ä´©¦ì¤¸¹Ï¡A¤]´N¬O Bitmap ®æ¦¡ªº¹Ï¤ù¡A¦Ó GDI¡Ï ¤ä´©ªº¹Ï¤ù¸û¦h¡A³o¤]¬O¥»³¹ªº«ÂI¡C¨º»ò¦b¨Ï¥Î GDI¡Ï ªº®ÉÔ¡A¦³¤°»ònª`·Nªº¶Ü¡H
¦b¨Ï¥Î GDI¡Ï «e¡A¶·ª`·N©³¤U¤T¥ó¨Æ¡G
²Ä¤@¡A¦pªG¨Ï¥Î WinInc §t¤JÀÉ·f°t UASM ²ÕĶ¡A¨º»ò¦b²Õ¦X»y¨¥ì©lµ{¦¡ªº«e±¡A»Ý§â¡uGDIPLUS.INC¡v¥]§t¶i¨Ó¡C¦P®É¤]n¥[¤J¡uGDIPLUS.LIB¡v¶×¤Jµ{¦¡®w¡A¥H«K¨Ï³sµ²¾¹ª¾¹D¦p¦ó¦b¡uGDIPLUS.DLL¡v§ä¨ì©Ò¨Ï¥Îªº GDI¡Ï ¨ç¦¡¡Cµ{¦¡½X¦p¤U¡G
INCLUDE GDIPLUS.INC INCLUDELIB GDIPLUS.LIB
²Ä¤G¡A¦b©I¥s GDI¡Ï ¨ç¦¡¤§«e¡A¥²¶·¥ý©I¥s GdiplusStartup¡A¥Hªì©l¤Æ GDI¡Ï¡AµM«á¤~¯à©I¥s¨ä¥L GDI¡Ï ¨ç¦¡¡F·í¤£¦A¨Ï¥Î GDI¡Ï ®É¡A¥²¶·©I¥s GdiplusShutdown §iª¾¨t²Îµ²§ô GDI¡Ï¡A¥HÄÀ©ñ GDI¡Ï ©Ò¨Ï¥Îªº¸ê·½¡C
²Ä¤T¡AGDI¡Ï ¨ç¦¡ªº¦^¶ÇÈ»P¨ä¥L Win64 API ¤£¤Ó¤@¼Ë¡C¹ï GDI¡Ï ¨ç¦¡¦Ó¨¥¡A¦^¶ÇȬ° 0 ¥Nªí°õ¦æ¦¨¥\¡F¦^¶ÇȬ°¨ä¥L¼ÆÈ¡A¥Nªí°õ¦æ¥¢±Ñ¡A¦Ó¸Ó¼ÆÈ¥Nªí¿ù»~¥N½X¡CWindows ¯S§O§â GDI¡Ï ªº¦^¶ÇȺ٬° GpStatus¡C¹ï 64 ¦ì¤¸ªº Windows¡AGpStatus ªºªø«×³£¬O QWORD¡A¦s©ó RAX ¼È¦s¾¹¤º¡C¤Uªí¬O GDI¡Ï API ªº¦^¶ÇȤηN¸q¡G
Status | ¼ÆÈ | »¡©ú |
OK | 0 | °õ¦æ¦¨¥\ |
GenericError | 1 | ¤@¯ë¿ù»~¡A«üªº¬O¥¼³QÂkÃþªº¿ù»~ |
InvalidParameter | 2 | °Ñ¼Æ¤£¥¿½T |
OutOfMemory | 3 | °O¾ÐÅ餣¨¬ |
ObjectBusy | 4 | ¹Á¸Õ¾Þ§@¥¿¦b³Q¨ä¥L°õ¦æºü©Îµ{¦¡Âê©wªºª«¥ó |
InsufficientBuffer | 5 | ´£¨Ñªº½w½Ä°Ï¤j¤p¤£¨¬¥H¦s©ñ¾Þ§@µ²ªG |
NotImplemented | 6 | ¸Ó¨ç¼Æ¥Ø«e©|¥¼³Q¹ê§@¡A¥i¯à¬Oª©¥»¤£²Å©Î³]³Æ¥¼¤ä´© |
Win32Error | 7 | ªí¥Ü¨Ó¦Û Win32 API ªº¿ù»~ |
WrongState | 8 | ªí¥Üª«¥óªºª¬ºA»P©Ò»Ý¾Þ§@¤£¤@P¡A¨Ò¦p¦b¥¼¸gªì©l¤Æª¬ºA¤U°õ¦æø»s¾Þ§@ |
Aborted | 9 | ªí¥Ü¾Þ§@³Q¤¤¤î |
FileNotFound | 0Ah | ¨S§ä¨ìÀÉ®× |
ValueOverflow | 0Bh | °õ¦æ²£¥Í¼ÆÈ·¸¦ìªººâ³N¹Bºâ |
AccessDenied | 0Ch | ¤£¤¹³\ÀÉ®×¼g¤J |
UnknownImageFormat | 0Dh | ¥¼ª¾ªº¹Ï¤ùÀɮ׮榡 |
FontFamilyNotFound | 0Eh | §ä¤£¨ì«ü©wªº¦r§Î¡A¨Ò¦p¦r§Î¦WºÙ¤£¥¿½T©Î¥¼¦w¸Ë¦r§Î |
FontStyleNotFound | 0Fh | §ä¤£¨ì«ü©wªº¦r§Î·®æ |
NotTrueTypeFont | 10h | ±q HDC ©Î LOGFONT ©ÒÂ^¨úªº¦r§Î¤£¬O TrueType ¦r§Î¡AµLªk»P GDI¡Ï ·f°t¨Ï¥Î |
UnsupportedGdiplusVersion | 11h | ¦w¸Ë¦b¨t²Îªº GDI¡Ï ª©¥»»PÀ³¥Îµ{¦¡¤£¬Û²Å |
GdiplusNotInitialized | 12h | GDI¡Ï API ¤£¬O³B©óªì©l¤Æª¬ºA¡A ©I¥s GdiplusStartup ¥H¸Ñ¨M¦¹¿ù»~ |
PropertyNotFound | 13h | ¼v¹³¤¤¨S¦³«ü©wªºÄÝ©Ê |
PropertyNotSupported | 14h | ¼v¹³®æ¦¡¤£¤ä´©«ü©wªºÄÝ©Ê¡A¦]¦¹µLªk³]©w |
ProfileNotFound | 15h | §ä¤£¨ì¥H CMYK ®æ¦¡Àx¦s¼v¹³©Ò»Ýªº¦â±m³]©wÀÉ |
©³¤U¨Ó¤¶²Ð¥»³¹·|¥Î±o¨ìªº GDI¡Ï API¡A¥H¤Î¤@¨Ç·§©À¡C
¨C·ín¨Ï¥Î GDI¡Ï «e¡A³£n©I¥s GdiplusStartup¡A¹ï GDI¡Ï ¶i¦æªì©l¤u§@¡CGdiplusStartup ªºì«¬¦p¤U¡G
invoke GdiplusStartup,\ pToken,\ ; receives the GDI+ session handle pGdipStartInput,\ ; provides GDI+ initialization settings pGdipStartOutput ; returns additional initialization details
pToken ¬O«ü¦V token ªº¦ì§}¡A¹ï 64 ¦ì¤¸ªº Windows ¦Ó¨¥¡Atoken ªºªø«×¬O QWORD¡CToken ¬O GDI¡Ï ®Ö¤ß°õ¦æÀô¹Òªº¼Ð»x¡A¨t²Î¥Î¥¦ºÞ²z¨ä¥Í©R©P´Á¡A³z¹L token¡AGDI¡Ï ¯à°÷°lÂÜ©M²M²z¨ä¤º³¡¸ê·½¡A½T«OÀ³¥Îµ{¦¡ªºÃ©w©Ê©M¸ê·½ªº¥¿½T¦^¦¬¡C·í¤£¦A¨Ï¥Î GDI¡Ï ®É¡A¥²¶·©I¥s¥H¦^¦¬¸ê·½¡A³o®ÉÔ¤]·|¥Î¨ì token¡C§ÚÌ¥i¥H²³æ¦a§â token ·Q¹³¬°¥N½X¡]handle¡^¡C
pGdipStartInput ¬°µ²ºcÅé GdiplusStartupInput ªº¦ì§}¡A¸Óµ²ºcÅ骺Äæ¦ì¬O¡G
GdiplusStartupInput STRUCT 8 GdiplusVersion UINT32 ? ;GDI¡Ïª©¥» DebugEventCallback DebugEventProc ? ;°£¿ù¨ç¦¡¦ì§} SuppressBackgroundThread BOOL ? ;¬O§_±Ò¥Î«á¥x°õ¦æºü SuppressExternalCodecs BOOL ? ;¬O§_¤¹³\¨Ï¥Î¥~³¡½s¸Ñ½X¾¹ GdiplusStartupInput ENDS
µ²ºcÅé GdiplusStartupInput ªº¥Î³~¦b©óªì©l¤Æ GDI¡Ï¡A¦]¦¹¦b©I¥s GdiplusStartup «e¡A¥²¶·§â³oÓµ²ºcÅ餺ªº¦UÄæ¦ì³£¶ñ¤W¾A·íªº¸ê®Æ¡C©I¥s GdiplusStartup ®É¡AWindows ÂǥѳoÓµ²ºcÅ餺ªº¸ê®Æ¡A¹ï GDI¡Ï ¶i¦æªì©l¤Æ¤u§@¡C©³¤U¤¶²Ð¦UÄæ¦ì¡G
pGdipStartOutput ¬°µ²ºcÅé GdiplusStartupOutput ªº¦ì§}¡A¦¹µ²ºc¥i¥Î©ó´£¨Ñ¤@¨Ç±Ò°Ê GDI¡Ï «áªºªþ¥[¸ê°T¡A¯S§O¬O±±¨î«á¥x°õ¦æºüªººÞ²z¡C¦pªG²Ä¤GӰѼƩҫüµ²ºcÅ餤ªº²Ä¤TÓÄæ¦ì¡ASuppressBackgroundThread¡A¬° FALSE¡A«h pGdipStartOutput ¥i¥H¬O 0¡CGdiplusStartupOutput µ²ºcÅ骺ÓÄæ¦ì¦p¤U¡G
GdiplusStartupOutput STRUCT NotificationHook NotificationHookProc ? ;ÄdºI¨ç¦¡¦ì§}¡A¥Î©ó³qª¾À³¥Îµ{¦¡ GDI¡Ï ªº«á¥x°õ¦æºü¥¿¦b±Ò°Ê NotificationUnhook NotificationUnhookProc ? ;ÄdºI¨ç¦¡¦ì§}¡A¥Î©ó³qª¾À³¥Îµ{¦¡ GDI¡Ï ªº«á¥x°õ¦æºü¥¿¦b°±¤î GdiplusStartupOutput ENDS
¦b¤j¦h¼Æ±¡ªp¤U¡AGdiplusStartupOutput µ²ºcÅ餺ªº¨âÄæ¦ì§¡¥i³]¬° 0¡Aªí¥Ü¤£»Ýn¥ÎÄdºI¨ç¦¡³B²z«á¥x°õ¦æºü¡CµM¦Ó¡A·íÀ³¥Îµ{¦¡»Ýn²Ó½o¦aºÞ²z GDI¡Ï ªº«á¥x°õ¦æºü®É¡A¥i¥H¾A·í³]©w³o¨âÓÄæ¦ì¡C
¦pªG GdiplusStartup °õ¦æ¦¨¥\¡AGdiplusStartup ªº¦^¶ÇȬ° 0¡F¦pªG¥¢±Ñ¡A¦^¶ÇȬ°¨ä¿ù»~½X¡A¨£¤Wªí¤@¡C
GdiplusShutdown ·|²M°£ GDI¡Ï ©Ò¨Ï¥Îªº¸ê·½¡C¨C©I¥s¤@¦¸ GdiplusStartup¡A³£À³¸Ó¤]©I¥s¤@¦¸ GdiplusShutdown¡CGdiplusShutdown ªºì«¬¦p¤U¡G
invoke GdiplusShutdown,\
token ; the GDI+ session handle
GdiplusShutdown ¥u¦³¤@ӰѼơA´N¬O±q©I¥s GdiplusStartup ±o¨ìªº token¡C¦b«Ø¥ß¥ô¦ó GDI¡Ï ª«¥ó¤§«e±o¥ý©I¥s GdiplusStartup ªì©l¤Æ¡A¦Ó¥B¤]¥²¶·¥ý§R°£©Ò¦³ GDI¡Ï ª«¥ó¡A¤~¯à©I¥s GdiplusShutdown¡CGdiplusShutdown ¨S¦³¦^¶ÇÈ¡C
¹ï²³æ¥\¯àªº GDI¡Ï À³¥Îµ{¦¡¦Ó¨¥¡AGDI¡Ï ªºªì©l¤Æ»P²M°£¡A¥i·Ó¥H¤U»¡©ú¶i¦æ¡C³q±`¨Ï GdiplusStartupInput ³]¬° <1,0,0,0>¡A¦Ó pGdipStartOutput ¤]³]¬° 0¡Cªì©l¤Æ¤u§@¡A¥i¥H¦bÀ³¥Îµ{¦¡¤@¶}©l¡A©Î¬O«Ø¥ßµøµ¡¤§«á¶i¤J°T®§°j°é¤§«e¡F¦Ó¦bµ²§ô°T®§°j°é¤§«áµ²§ô GDI¡Ï¡C¦p¤U±µ{¦¡½X¡G
.DATA hwnd HWND ? token DQ ? status DQ ? gsi GdiplusStartupInput <1,0,0,0> ⁝ main PROC ⁝ mov hwnd,RV(CreateWindowEx,¡K¡K) mov status,RV(GdiplusStartup,OFFSET token,OFFSET gsi,0) .while TRUE invoke GetMessage,ADDR msg,0,0,0 .break .if rax==0 invoke TranslateMessage,ADDR msg invoke DispatchMessage,ADDR msg .endw invoke GdiplusShutdown,token ⁝
°²¦p¨Ï¥Î WinInc ¥]§tÀÉ¡A¨º»ò¦b GdiPlusInit.INC ¤º«Å§i GdiplusShutdown ªºì«¬¦³»~¡AÀ³±N¨ä§ï¦¨¡G
@DefProto WINGDIPAPI, GdiplusShutdown, stdcall, , <:QWORD>, 4
GdipLoadImageFromFile ·|®Ú¾Ú¹Ï¤ùÀÉ®×«Ø¥ß GpImage ª«¥ó¡C¦b GDI¡Ï ¤¤¦³³\¦hÃö©ó¹Ï§Îªºª«¥ó¡AGDI¡Ï ¨ç¦¡¥H³o¨Çª«¥ó¶i¦æø»s¡B¶î¦â¡B±ÛÂ൥¾Þ§@¡CGpImage ¥u¬O¨ä¤¤¤§¤@¡A¥i¥H§â GpImage ª«¥ó·Q¹³¦¨¬O¤@ºØ¥N½X¡AGDI¡Ï ¥i¥H¹ï³o GpImage ª«¥ó¶i¦æ¾Þ§@¡F´N¹³µøµ¡¥N½X¤@¼Ë¡A¨t²Î¥i¥H¹ïµøµ¡¥N½X¶i¦æ¾Þ§@¡A¨Ò¦p©ñ¤j¡BÁY¤p¡BÃö³¬µ¥¡CGdipLoadImageFromFile ªºì«¬¦p¤U¡G
invoke GdipLoadImageFromFile,\ lpFileName,\ ; pointer to name of the file pGpImage ; pointer to a GpImage object
lpFileName ¬OÀɮצWºÙªº¦ì§}¡A¦¹ÀÉ®×¥i¥H¬O PNG¡BJPG¡BGIF¡BExif¡BTIFF¡BWMF¡BEMF µ¥®æ¦¡ªº¹Ï¤ùÀÉ¡A¦Ó¥BÀɦW¥²¶·¬O¸U°ê½XÀɦW¡CpGpImage ¬O GpImage ª«¥ó¦ì§}¡AGpImage ª«¥ó«ü¦V GDI¡Ï ¤º³¡ªº¸ê®Æ¡A¡uGp¡v¥Nªí GDI plus ªº·N«ä¡C
¦pªG GdipLoadImageFromFile °õ¦æ¦¨¥\¡A¦^¶ÇȬ° 0¡F¦pªG¥¢±Ñ¡A¦^¶ÇȬ°¨ä¿ù»~½X¡A¨£¤Wªí¤@¡C·í¤£¦A¨Ï¥Î GpImage ª«¥ó®É¡A»Ý©I¥s GdipDisposeImage ¨ç¦¡¨ÓÄÀ©ñ¸Óª«¥ó¡A¥HÁקKµo¥Í¿ù»~¡C
¨ú±o GpImage ª«¥óªº¼e«×¡A쫬¦p¤U¡G
invoke GdipGetImageWidth,\ gdipImage,\ ; GpImage object pWidth ; pointer to width of a GpImage
gdipImage ¬O GpImage ª«¥ó¡CpWidth ¬OÅܼƦì§}¡A¦¹Åܼƪø 32 ¦ì¤¸¡C·í GdipGetImageWidth °õ¦æ¦¨¥\¡A¦^¶ÇȬ° 0¡A¥B¨t²Î·|§â GpImage ª«¥ó¤¤ªº¹Ï¤ù¼e«×¼g¤J¦¹ÅܼƤ¤¡A³æ¦ì¬O¹³¯À¡F¦pªG¥¢±Ñ¡A¦^¶ÇȬ°¨ä¿ù»~½X¡A¨£¤Wªí¤@¡C
¨ú±o GpImage ª«¥óªº°ª«×¡A쫬¦p¤U¡G
invoke GdipGetImageHeight,\ gdipImage,\ ; GpImage object pHeight ; pointer to height of a GpImage
gdipImage ¬O GpImage ª«¥ó¡CpHeight ¬OÅܼƦì§}¡A¦¹Åܼƪø 32 ¦ì¤¸¡C·í GdipGetImageHeight °õ¦æ¦¨¥\¡A¦^¶ÇȬ° 0¡A¥B¨t²Î·|§â GpImage ª«¥ó¤¤ªº¹Ï¤ù°ª«×¼g¤J¦¹ÅܼƤ¤¡A³æ¦ì¬O¹³¯À¡F¦pªG¥¢±Ñ¡A¦^¶ÇȬ°¨ä¿ù»~½X¡A¨£¤Wªí¤@¡C
GdipCreateFromHDC ¥Î©ó«Ø¥ß»P«ü©w¸Ë¸m¤º®e¬ÛÃöÁpªº GpGraphics ª«¥ó¡A¤]´N¬O»¡±q«ü©wªº³]³Æ¤º®e«Ø¥ß¤@Ó GpGraphics ª«¥ó¡CGpGraphics ¬O GDI¡Ï ªºª«¥ó¤§¤@¡A¥¦¤]¬O¤@Ó«ü¼Ð¡Aªø«×¬O 64 ¦ì¤¸¡A«ü¦V GDI¡Ï ¤º³¡ªº¸ê®Æµ²ºc¡C¨C·ínø»s¹Ï§Î®É¡AGDI¡Ï ³£¬O¾Þ§@ GpGraphics ª«¥ó¡AµM«á¦b¸Ë¸m¤º®eø¥X¹Ï§Î¡C¥i¥H GpGraphics ª«¥ó·Q¹³¦¨¬O GDI¡Ï ª©ªº¸Ë¸m¤º®e¡CGdipCreateFromHDC ªºì«¬¬O¡G
invoke GdipCreateFromHDC,\ hdc,\ ; handle to device context pGpGraphics ; pointer to a GpGraphics object
hdc ¬On§â¹Ï§Îø©ó¨ä¤Wªº¸Ë¸m¤º®e¥N½X¡A¥i¥H¸g¥Ñ©I¥s BeginPaint¡BGetDC ©Î CreateCompatibleDC ±o¨ì¡CpGpGraphics ¬O GpGraphics ª«¥óªº¦ì§}¡C
¦pªG GdipCreateFromHDC °õ¦æ¦¨¥\¡A¦^¶ÇȬ° 0¡F¦pªG¥¢±Ñ¡A¦^¶ÇȬ°¨ä¿ù»~½X¡A¨£¤Wªí¤@¡C·í¤£¦A¨Ï¥Î GpGraphics ª«¥ó®É¡A»Ý©I¥s GdipDeleteGraphics ¨ç¦¡¨ÓÄÀ©ñ¸Óª«¥ó¡A¥HÁקKµo¥Í¿ù»~¡C
GdipDrawImageRectI ¥Î©ó±N¹Ï§Î¡]¦p¦ì¤¸¹Ï©Î¦V¶q¹Ï§Î¡^ø»s¨ì«ü©wªº GpGraphics ª«¥ó¤W¡C³oӨ禡¨Ï¥Î¾ã¼Æ«¬ºAªº°Ñ¼Æ¨Ó«ü©w¼v¹³ªº¦ì¸m¡A¦Ó¤£¬O¯BÂI¼Æ«¬ºA¡CGdipDrawImageRectI ªºì«¬¦p¤U¡G
invoke GdipDrawImageRectI,\ gdipGraphics,\ ; GpGraphics object gdipImage,\ ; GpImage object x,\ ; the x-coordinate of the upper-left corner of the rendered image y,\ ; the y-coordinate of the upper-left corner of the rendered image width,\ ; width of the destination rectangle height ; height of the destination rectangle
GdipDrawImageRectI «e¨âӰѼƬO«ü§â GpImage ª«¥óø»s©ó GpGraphics ¤W±¡CGpImage ª«¥ó³q±`¬O©I¥s GdipLoadImageFromFile ©Î GdipCreateBitmapFromHBITMAP ²£¥Í¡C°²¦p GpGraphics ¬O¥Ñ¿Ã¹õ¸Ë¸m¤º®e²£¥Í¡A¨º»ò GpImage ª«¥ó´N·|Åã¥Ü©ó¿Ã¹õ¤W¡Cx¡By ¬Oµøµ¡¤u§@°Ï®y¼Ð¡A¨t²Î·|§â GpImage ªº¥ª¤W¨¤Ã¸»s©ó¦¹®y¼Ð¤W¡Cx¡By ¬O 32 ¦ì¤¸µL¸¹¾ã¼Æ¡A¥H¹³¯À¬°³æ¦ì¡Cwidth¡Bheight ¬Onø»sªº¥Ø¼Ð¯x§Îªº¼e«×»P°ª«×¡A¥H¹³¯À¬°³æ¦ì¡C°²¦p width¡Bheight »P GpImage ª«¥ó¤¤ªº¼e«×»P°ª«×¤£¦Pªº¸Ü¡A¨º»ò´N·|©ñ¤j©ÎÁY¤p¡A¤]¥i¯à·|©Ô¦ù©ÎÀ£ÁY¡C
¦pªG°õ¦æ¦¨¥\¡A¦^¶ÇȬ° 0¡F¦pªG¥¢±Ñ¡A¦^¶ÇȬ°¨ä¿ù»~½X¡A¨£¤Wªí¤@¡C
ÁÙ¦³¤@Ó GdipDrawImageRect GDI¡Ï API¡A¥\¯à»P GdipDrawImageRectI Ãþ¦ü¡A¨ç¦¡¦WºÙ¶È¬Û®t¤@Ó¡uI¡v¡CGdipDrawImageRect ªºì«¬¬O¡G
invoke GdipDrawImageRect,\ gdipGraphics,\ ; GpGraphics object gdipImage,\ ; GpImage object x,\ ; the x-coordinate of the upper-left corner of the rendered image y,\ ; the y-coordinate of the upper-left corner of the rendered image width,\ ; width of the destination rectangle height ; height of the destination rectangle
GdipDrawImageRectI »P GdipDrawImageRect ªº®t§O¦b©ó¡A«eªÌªº x¡By¡Bwidth¡Bheight ³£¬O 32 ¦ì¤¸¾ã¼Æ¡A«áªÌ«h¬O 32 ¦ì¤¸¯BÂI¼Æ¡]¤£½×¬O 64 ¦ì¤¸©Î 32 ¦ì¤¸ªº Windows ¤¤¡A¦¹³Bªº¯BÂI¼Æ³£¬O 32 ¦ì¤¸ªø¡^¡C«áªÌ¾A¦X»Ýn°ªºë«×ø»s¡A¨Ò¦p±ÛÂà®É¨Ï¥Î¡C
GdipDeleteGraphics ¥Î©óÄÀ©ñ GpGraphics ª«¥ó¡A¥H¸`¬Ù¸ê·½¡C¨ä쫬¬°¡G
invoke GdipDeleteGraphics,\
gdipGraphics ; GpGraphics object
GdipDeleteGraphics ¥u¦³¤@ӰѼơA´N¬OnÄÀ©ñªº GpGraphics ª«¥ó¡C¦pªG°õ¦æ¦¨¥\¡A¦^¶ÇȬ° 0¡F¦pªG¥¢±Ñ¡A¦^¶ÇȬ°¨ä¿ù»~½X¡A¨£¤Wªí¤@¡C
GdipDisposeImage ¥Î©óÄÀ©ñ GpImage ª«¥ó¡A¨ä쫬¬°¡G
invoke GdipDisposeImage,\
gdipImage ; GpImage object
GdipDisposeImage ¥u¦³¤@ӰѼơA´N¬OnÄÀ©ñªº GpImage ª«¥ó¡C¦pªG°õ¦æ¦¨¥\¡A¦^¶ÇȬ° 0¡F¦pªG¥¢±Ñ¡A¦^¶ÇȬ°¨ä¿ù»~½X¡A¨£¤Wªí¤@¡C
°²¦pn¥Î GDI¡Ï ©óµøµ¡¤u§@°Ï¤WÅã¥Ü¹Ï¤ùÀÉ¡A¬O¤£¿ùªº¿ï¾Ü¡A¦]¬° GDI¡Ï ¤ä´©³\¦hºØ®æ¦¡ªº¹Ï¤ùÀÉ¡C©³¤U²z³o¬q¹Lµ{¡G
¤W±ªº¹Lµ{¬O³Ì®Ö¤ßªº³¡¤À¡A¨Ã¤£¥]§t¨Ï¥Î GDI¡Ï «eªºªì©l¤Æ¤Î¨Ï¥Î«áªºÄÀ©ñ GDI¡Ï ¸ê·½¡A¤]¤£¥]§tÄÀ©ñ GpGraphics »P GpImage ª«¥ó¡C°²¦pnÅýÅã¥Ü¦bµøµ¡¤u§@°Ï¹Ï¤ùÀɼe«×»P°ª«×¡A«ê¦n®e¯Ç©ó¤u§@°Ï¤º¡A¨º»ò´N±o½Õ¾ãµøµ¡¤u§@°Ï¤j¤p¡A³s±a¤]·|½Õ¾ãµøµ¡¤j¤p¡C
AdjustWindowRectEx ¯à®Ú¾ÚÀ³¥Îµ{¦¡©Ò«ü©wªº¤u§@°Ï¼e«×»P°ª«×¡Apºâµøµ¡¤j¤p¡CAdjustWindowRectEx ¶Èpºâµøµ¡ªº¤Ø¤o¡A¨Ã¤£·|¯u¥¿§ïÅܨä¤Ø¤o¡A¦]¦¹ÁÙn§â©Ò±oªºµøµ¡¤j¤p¡A¥H°Ñ¼Æ¶Çµ¹ CreateWindowEx ©Î SetWindowPos ¤~¯à¯u¥¿Åýµøµ¡¤ºªº¤u§@°Ï¡A²Å¦XÀ³¥Îµ{¦¡©Ò«ü©wªº¡CAdjustWindowRectEx ªºì«¬¦p¤U¡G
invoke AdjustWindowRectEx,\ lpRect,\ ; pointer to client-rectangle structure dwStyle,\ ; window styles bMenu,\ ; menu-present flag dwExStyle ; extended style
©³¤U»¡©ú³o¨Ç°Ñ¼Æªº·N¸q¡G
lpRect ©Ò«üªº RECT µ²ºcÅé¦b©I¥s«e¡A¥ª¤W¨¤®y¼Ð¤£¤@©w¥²¶·¬O ( 0,0 )¡A¥i¥H¬O¨ä¥L®y¼Ð¡C§ÚÌ¥i¥H§â RECT µ²ºcÅ骺¥ª¤W¨¤»P¥k¤U¨¤®y¼Ð¡A·Q¹³¦¨¬O¿Ã¹õ®y¼Ð¡A¦Ó¨ä®tÈ´N¬O¤u§@°Ïªº¼e«×»P°ª«×¡CAdjustWindowRectEx pºâ®É¡A·|±NÃä®Ø¡B¼ÐÃDÄæµ¥¦]¯À¦Ò¼{¶i¥h¡A¦Ó¨Ï¥ª¤W¨¤®y¼Ð©¹¥ª¤W¤èÂX¥R¡A¥k¤U¨¤®y¼Ð©¹¥k¤U¤èÂX¥R¡A¥H¦Ü©ó¨Ï RECT µ²ºcÅéÅܦ¨µøµ¡ªº¥ª¤W¨¤»P¥k¤U¨¤®y¼Ð¡A¦ý¨ä¤u§@°Ïªº¥ª¤W¨¤»P¥k¤U¨¤®y¼Ð¤´¤£ÅÜ¡A¥u¬O¨Sªí¥Ü¥X¨Ó¡C
AdjustWindowRectEx ¤£·|±N WS_VSCROLL ©Î WS_HSCROLL ¯Ç¤J¦Ò¼{¡CYn¦Ò¼{±²°Ê¶b¡A½Ð¨Ï¥Î SM_CXVSCROLL ©Î SM_CYHSCROLL ©I¥s GetSystemMetrics¡C¦pªG¥D¥\¯àªí¦³¨â¦C¡A¨º»ò AdjustWindowRectEx µLªk³B²z¡A¥²¶·¥Î SM_CYMENU ¬°°Ñ¼Æ©I¥s GetSystemMetrics¡A±o¨ì¥D¥\¯àªí¨C¦C°ª«×¡C¦pªG AdjustWindowRectEx °õ¦æ¦¨¥\¦^¶ÇȬ° 1¡A§_«h¬°¹s¡C
±µ¤U¨Ó´N±N¤W±©Ò´£¹Lªºì²z¤Î GDI¡Ï API À³¥Î¦b²Õ¦X»y¨¥ùØ¡A¼¶¼g¤@Ó¯àÆ[¬Ý¸û¦h®æ¦¡¹Ï¤ùÀɪº VIEWIMG À³¥Îµ{¦¡¡C©³¤U¬O VIEWIMG.EXE.MANIFEST ªº¤º®e¡G
1 2 3 4 5 6
7 8 9 10 11 12
13 14 15 16 17 18
19 20 21 |
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
type="win32"
name="AtHome.Wanker.ViewImg"
version="1.0.0.0"
processorArchitecture="amd64"
/>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="amd64"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly> |
©³¤U¬O VIEWIMG.RC ªº¤º®e¡G
1 2 3 4 5 6 |
#include "RESOURCE.H"
#define RT_MANIFEST 24
1 RT_MANIFEST MOVEABLE PURE "VIEWIMG.EXE.MANIFEST"
2000 ICON EYE.IC |
©³¤U¬O VIEWIMG.ASM ªº¤º®e¡G
1 2 3 4 5 6
7 8 9 10 11 12
13 14 15 16 17 18
19 20 21 22 23 24
25 26 27 28 29 30
31 32 33 34 35 36
37 38 39 40 41 42
43 44 45 46 47 48
49 50 51 52 53 54
55 56 57 58 59 60
61 62 63 64 65 66
67 68 69 70 71 72
73 74 75 76 77 78
79 80 81 82 83 84
85 86 87 88 89 90
91 92 93 94 95 96
97 98 99 100 101 |
OPTION CASEMAP:NONE
OPTION WIN64:3
OPTION LITERALS:ON
UNICODE EQU 1 ;¨Ï¥ÎUNICODE½s½X¦r¤¸
INCLUDE WINDOWS.INC ;¥]§tGDIPLUS.INC¡A«Å§iGDI¡Ï¨ç¦¡
INCLUDE GDIPLUS.INC ;¥]§tGDIPLUS.LIB¡A¨ÏGDI¡Ï¨ç¦¡¯à¶¶§Q³sµ²
INCLUDELIB GDIPLUS.LIB
INCLUDELIB GDI32.LIB
INCLUDELIB KERNEL32.LIB
INCLUDELIB USER32.LIB
;*******************************************************************************
.DATA
hInst DQ ?
gdipToken DQ ? ;Token
gdipImage DQ ? ;GpImageª«¥ó
gdipGraphics DQ ? ;GpGraphicsª«¥ó
gdipStart GdiplusStartupInput <1,0,0,0> ;ªì©l¤ÆGDI¡Ï©Ò»Ý¸ê®Æ
szClassName DW "VIEWIMG",0
szTitle DW 770bh,5716h,7a0bh,5f0fh,0 ;¬Ý¹Ïµ{¦¡
szFileName DW "re2r.jpg",0 ;¹Ï¤ùÀɪºÀɦW
;*******************************************************************************
.CODE
;-------------------------------------------------------------------------------
WndProc PROC hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
LOCAL hDC:HDC,ps:PAINTSTRUCT,cxImg:DWORD,cyImg:DWORD,rcWnd:RECT
.if uMsg==WM_PAINT
mov hDC,RV(BeginPaint,hWnd,ADDR ps)
;§â¹Ï¤ùÀÉÅܦ¨GpImageª«¥ó¡B«Ø¥ß»PhDC¬ÛÃöÁpªºGpGraphicsª«¥ó¡A±o¨ìGpImageªº¤Ø¤o
invoke GdipLoadImageFromFile,OFFSET szFileName,OFFSET gdipImage
invoke GdipCreateFromHDC,hDC,OFFSET gdipGraphics
invoke GdipGetImageWidth,gdipImage,ADDR cxImg
invoke GdipGetImageHeight,gdipImage,ADDR cyImg
;pºâµøµ¡¤Ø¤o¡A¥H²Å¦X¹Ï¤ù¤Ø¤o
mov rcWnd.left,0
mov rcWnd.top,0
mov eax,cxImg
mov ecx,cyImg
mov rcWnd.right,eax
mov rcWnd.bottom,ecx
invoke AdjustWindowRectEx,ADDR rcWnd,WS_OVERLAPPEDWINDOW,0,0
;³]©wµøµ¡¦ì¸m¤Î¤Ø¤o
mov r10d,rcWnd.right
mov r11d,rcWnd.bottom
sub r10d,rcWnd.left
sub r11d,rcWnd.top
invoke SetWindowPos,hWnd,0,50,50,r10d,r11d,SWP_NOZORDER
;§âGpImageª«¥óø»s©óGpGraphics¤W
invoke GdipDrawImageRectI,gdipGraphics,gdipImage,0,0,cxImg,cyImg
;ÄÀ©ñGpImage»PGpGraphicsª«¥ó
invoke GdipDisposeImage,gdipImage
invoke GdipDeleteGraphics,gdipGraphics
invoke EndPaint,hWnd,ADDR ps
.elseif uMsg==WM_DESTROY
invoke PostQuitMessage,0
.else
def: invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.endif
rtn: xor rax,rax
ret
WndProc ENDP
;-------------------------------------------------------------------------------
main PROC
LOCAL hwnd:HWND,msg:MSG,wc:WNDCLASSEX
mov hInst,RV(GetModuleHandle,0)
mov wc.cbSize,SIZEOF WNDCLASSEX
lea rdx,WndProc
mov wc.style,CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc,rdx
mov wc.cbClsExtra,0
mov wc.cbWndExtra,0
mov wc.hInstance,rax
mov wc.hIcon,RV(LoadIcon,hInst,2004)
mov wc.hIconSm,rax
mov wc.hCursor,RV(LoadCursor,0,IDC_ARROW)
mov wc.hbrBackground,COLOR_WINDOW+1
mov wc.lpszMenuName,0
lea rdx,szClassName
mov wc.lpszClassName,rdx
invoke RegisterClassEx,ADDR wc
mov hwnd,RV(CreateWindowEx,0,ADDR szClassName,OFFSET szTitle,\
WS_OVERLAPPEDWINDOW,50,50,400,200,0,0,hInst,0)
invoke GdiplusStartup,OFFSET gdipToken,OFFSET gdipStart,0
invoke ShowWindow,hwnd,SW_SHOWNORMAL
invoke UpdateWindow,hwnd
.while TRUE
invoke GetMessage,ADDR msg,0,0,0
.break .if rax==0
invoke TranslateMessage,ADDR msg
invoke DispatchMessage,ADDR msg
.endw
invoke GdiplusShutdown,gdipToken
invoke ExitProcess,0
main ENDP
;*******************************************************************************
END main |
³oÓµ{¦¡ªºì²z³£¤w¸g´£¹L¡A¤£¦h»¡¤F¡C