News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Miscellaneous snippets

Started by jj2007, August 20, 2017, 08:02:31 AM

Previous topic - Next topic

daydreamer

Quote from: jj2007 on May 18, 2019, 10:29:03 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
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

jj2007

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

Quote from: jj2007 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.
maybe d3d can antialias better and faster with full antialias settings
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

jj2007


LiaoMi

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

Project upgrade failed (your source is 2007, I tried with Visual Crap 2010) 8)

daydreamer

Quote from: jj2007 on May 19, 2019, 06:18:16 AM
maybe - post a demo ;-)
docs says it doesnt antialias lines,only polys in fullscene antialias
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

LiaoMi

Quote from: jj2007 on May 19, 2019, 08:03:31 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

Quote from: jj2007 on May 18, 2019, 10:29:03 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.
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
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

jj2007

Quote from: daydreamer on May 25, 2019, 10:34:45 PMI 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

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

Little problems, it works only partially:

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


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

Init buffer sizes between calls
May the source be with you

jj2007

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.

jj2007

A snippet that allows to copy a table e.g. from Excel and paste it here:

include \masm32\MasmBasic\MasmBasic.inc
  Init
  Let esi=Clip$()
  .if Len(esi)
Let esi=Replace$(esi, CrLf$, Chr$("[/td][/tr]", 13, 10, "[tr][td]"))
Let esi=Replace$(esi, Tb$, "[/td][td]")
Let esi="[table][tr][td]"+esi+"[/td][/table]"
Inkey "Put table on clipboard (y)?"
If_ eax=="y" Then SetClip$ esi ; put table on the clipboard
  .else
MsgBox 0, "No text on clipboard, sorry", "Hi", MB_OK
  .endif
EndOfCode


Example (see attached SimpleTable.tab):
NameFirst nameStreetCity
FerrellAaliyah2716 Simpson StreetBelyando
OnealAaron2033 Rosales StreetPort Iatta
CooperAbagail1381 Lee StreetPalmers Oaky
DavidAbagail2445 Price StreetPopanyinning
HamptonAbagail35 Boyer StreetRed Range