Author Topic: Miscellaneous snippets  (Read 19730 times)

daydreamer

  • Member
  • ****
  • Posts: 907
  • watch Chebyshev on the backside of the Moon
Re: Miscellaneous snippets
« Reply #120 on: May 19, 2019, 12:19:26 AM »
Thanks, Daydreamer. Arrayplot is Gdi, actually. Speedwise, check the Sinus plot template (attached). Re GET & PUT: There are ways to do something similar in MasmBasic, but I doubt that LordAdef is using them.
if its gdi draw chinese characters,please check in my thread if you can show a smoother solution to this problem Jochen
http://masm32.com/board/index.php?topic=7834.0
Quote from Flashdance
Nick  :  When you give up your dream, you die
*wears a flameproof asbestos suit*
Gone serverside programming p:  :D

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 9686
  • Assembler is fun ;-)
    • MasmBasic
Re: Miscellaneous snippets
« Reply #121 on: May 19, 2019, 05:16:09 AM »
The text is not the problem, Gdi draws fonts OK. It is the ragged line. Below an excerpt from the plot where I added a line drawn with Gdi+, using high quality anti-aliasing. It does make a difference, but the extra quality is not overwhelming.

You must zoom in quite a lot to see a difference. On Chrome/SlimJet it's holding Control and pushing the mousewheel forward.

Btw this is line width 3; for finer lines, the difference between plain Gdi and high quality anti-aliased Gdi+ is almost negligible. On the right side of the graph, I added a comparison between 5px and 1px lines. If you zoom to 200 or 250%, the difference becomes evident. Note also how neat the Chinese text looks - it's really fine.

daydreamer

  • Member
  • ****
  • Posts: 907
  • watch Chebyshev on the backside of the Moon
Re: Miscellaneous snippets
« Reply #122 on: May 19, 2019, 06:01:06 AM »
The text is not the problem, Gdi draws fonts OK. It is the ragged line. Below an excerpt from the plot where I added a line drawn with Gdi+, using high quality anti-aliasing. It does make a difference, but the extra quality is not overwhelming.

You must zoom in quite a lot to see a difference. On Chrome/SlimJet it's holding Control and pushing the mousewheel forward.

Btw this is line width 3; for finer lines, the difference between plain Gdi and high quality anti-aliased Gdi+ is almost negligible. On the right side of the graph, I added a comparison between 5px and 1px lines. If you zoom to 200 or 250%, the difference becomes evident. Note also how neat the Chinese text looks - it's really fine.
maybe d3d can antialias better and faster with full antialias settings
Quote from Flashdance
Nick  :  When you give up your dream, you die
*wears a flameproof asbestos suit*
Gone serverside programming p:  :D

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 9686
  • Assembler is fun ;-)
    • MasmBasic
Re: Miscellaneous snippets
« Reply #123 on: May 19, 2019, 06:18:16 AM »
maybe - post a demo ;-)

LiaoMi

  • Member
  • ****
  • Posts: 574
Re: Miscellaneous snippets
« Reply #124 on: May 19, 2019, 07:08:31 PM »
Hi,

I take my words back  :biggrin: It looks like its just impossible to make normal smoothing with GDI, other technologies have to deal with it.

https://software.intel.com/en-us/articles/mlaa-efficiently-moving-antialiasing-from-the-gpu-to-the-cpu
SMAA: Subpixel Morphological Antialiasing https://github.com/iryoku/smaa
Demo - https://web.archive.org/web/20121023110459/http://www.iryoku.com/mlaa/downloads/Jimenez-MLAA-DX10-v1.5.exe

Below, I gave examples showing the difference between display technologies.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 9686
  • Assembler is fun ;-)
    • MasmBasic
Re: Miscellaneous snippets
« Reply #125 on: May 19, 2019, 08:03:31 PM »
Project upgrade failed (your source is 2007, I tried with Visual Crap 2010) 8)

daydreamer

  • Member
  • ****
  • Posts: 907
  • watch Chebyshev on the backside of the Moon
Re: Miscellaneous snippets
« Reply #126 on: May 20, 2019, 09:01:26 PM »
maybe - post a demo ;-)
docs says it doesnt antialias lines,only polys in fullscene antialias
Quote from Flashdance
Nick  :  When you give up your dream, you die
*wears a flameproof asbestos suit*
Gone serverside programming p:  :D

LiaoMi

  • Member
  • ****
  • Posts: 574
Re: Miscellaneous snippets
« Reply #127 on: May 20, 2019, 10:46:18 PM »
Project upgrade failed (your source is 2007, I tried with Visual Crap 2010) 8)

Hi jj2007,

I also have no success in the visual studio 2019, I will try on another machine. The first example shows that in GDI it is not reachable, and the second example shows how ideally it should be, taking into account that another mechanism is used. The speed and processing of both techniques are completely different. I do not think it's worth puzzling over this problem  :rolleyes:

daydreamer

  • Member
  • ****
  • Posts: 907
  • watch Chebyshev on the backside of the Moon
Re: Miscellaneous snippets
« Reply #128 on: May 25, 2019, 10:34:45 PM »
Thanks, Daydreamer. Arrayplot is Gdi, actually. Speedwise, check the Sinus plot template (attached). Re GET & PUT: There are ways to do something similar in MasmBasic, but I doubt that LordAdef is using them.
you use GDI background color=bitmap? or use background color=null?
for example want to have a moving object,just redraw it together with erase few pixels behind it?

I found this direct2d vs GDI,look below at the images direct2d is smoother curves
https://docs.microsoft.com/sv-se/windows/desktop/direct2d/direct2d-overview
Quote from Flashdance
Nick  :  When you give up your dream, you die
*wears a flameproof asbestos suit*
Gone serverside programming p:  :D

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 9686
  • Assembler is fun ;-)
    • MasmBasic
Re: Miscellaneous snippets
« Reply #129 on: May 25, 2019, 11:26:11 PM »
I found this direct2d vs GDI,look below at the images direct2d is smoother curves

The curves are Gdi vs D2D, not Gdi+. They write "When rendering in software, applications that use Direct2D experience substantially better rendering performance than with GDI+ and with similar visual quality." - and I bet they mean "almost the same quality".

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 9686
  • Assembler is fun ;-)
    • MasmBasic
WM_DROPFILES
« Reply #130 on: June 20, 2019, 06:15:26 PM »
GuiParas equ "Event Dropfiles demo", x1000, y20, w350, h700, cblack, b00FFFFD0h
include \masm32\MasmBasic\Res\MbGui.asm

Event DropFiles
  GfNoPaths=1                           ; optional: don't include the paths
  For_ ecx=0 To eax-1                   ; #files was returned in eax
        wPrintLine wRec$(Files$(ecx))   ; show the files in the console window
  Next
  GuiRefresh                            ; GuiText needs a WM_PAINT handler

Event Paint
  For_ ecx=0 To Files$(?)-1
        GuiText 3, ecx*20, Files$(ecx)
  Next
GuiEnd

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 9686
  • Assembler is fun ;-)
    • MasmBasic
InternetCrackUrl
« Reply #131 on: July 03, 2019, 08:13:59 AM »
Little problems, it works only partially:

Code: [Select]
include \masm32\MasmBasic\MasmBasic.inc ; download
uselib WinInet

if 0
 URL_COMPONENTSA STRUCT
 dwStructSize DWORD ?
 lpszScheme LPSTR ?
 dwSchemeLength DWORD ?
 nScheme DWORD ?
 lpszHostName LPSTR ?
 dwHostNameLength DWORD ?
 nPort      INTERNET_PORT <>
 lpszUserName LPSTR ?
 dwUserNameLength DWORD ?
 lpszPassword LPSTR ?
 dwPasswordLength DWORD ?
 lpszUrlPath LPSTR ?
 dwUrlPathLength DWORD ?
 lpszExtraInfo LPSTR ?
 dwExtraInfoLength DWORD ?
 URL_COMPONENTSA ENDS
endif
.data?
UrlComp URL_COMPONENTS <>
HostName db 100 dup(?)
UserName db 100 dup(?)
UrlPath db 1000 dup(?)
ExtraInfo db 100 dup(?)

  Init
  add UrlComp.dwStructSize, URL_COMPONENTS
  mov UrlComp.lpszScheme, Chr$("Whatever suits you")
  add UrlComp.dwSchemeLength, c$Len
  mov UrlComp.lpszHostName, offset HostName
  add UrlComp.dwHostNameLength, 100
  add UrlComp.nScheme, INTERNET_SCHEME_UNKNOWN ; INTERNET_SCHEME_DEFAULT
  mov UrlComp.lpszUserName, offset UserName
  add UrlComp.dwUserNameLength, 100
  mov UrlComp.lpszUrlPath, offset UrlPath
  add UrlComp.dwUrlPathLength, 1000
  mov UrlComp.lpszExtraInfo, offset ExtraInfo
  add UrlComp.dwExtraInfoLength, 100

  invoke InternetCrackUrl, Chr$("https://docs.microsoft.com/en-us/windows/win32/api/wininet/nf-wininet-internetcrackurla"), 0, ICU_DECODE, addr UrlComp
  deb 4, "res", eax, $Err$(), $UrlComp.lpszScheme, $offset HostName, $offset UserName, $UrlPath, $ExtraInfo, UrlComp.nPort
  invoke InternetCrackUrl, Chr$("http://www.google.com/test.html"), 0, ICU_DECODE, addr UrlComp
  deb 4, "res", eax, $Err$(), $UrlComp.lpszScheme, $offset HostName, $offset UserName, $UrlPath, $ExtraInfo, UrlComp.nPort
 
EndOfCode

Code: [Select]
res
eax             1
$Err$()         Operazione completata.__
$UrlComp.lpszScheme     https
$offset HostName        docs.microsoft.com
$offset UserName
$UrlPath        470     <not a pointer>
$ExtraInfo      00      <not a pointer>
UrlComp.nPort   443

res
eax             0
$Err$()         Area dati passata ad una chiamata al sistema troppo piccola.__
$UrlComp.lpszScheme     http
$offset HostName        www.google.com
$offset UserName
$UrlPath        470     <not a pointer>
$ExtraInfo      00      <not a pointer>
UrlComp.nPort   80

TimoVJL

  • Member
  • ***
  • Posts: 431
Re: Miscellaneous snippets
« Reply #132 on: July 03, 2019, 04:55:34 PM »
Init buffer sizes between calls
May the source be with you

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 9686
  • Assembler is fun ;-)
    • MasmBasic
Re: Miscellaneous snippets
« Reply #133 on: July 03, 2019, 05:59:18 PM »
Thanks, Timo. Right, even a mov UrlComp.dwUserNameLength, 1 is sufficient. It seems that if you pass a pointer to a buffer, the length must be at least one even if you don't get a text back.