News:

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

Main Menu

Binary image app to test.

Started by hutch--, May 07, 2020, 05:59:28 PM

Previous topic - Next topic

hutch--

I have only posted the binary as I have not caught up with distributing the library yet, I will get that done when I have everything else done.

This app is close to a working application, it will open a number of different image file formats but will save a normal RGB bitmap, an RGBA bitmap and JPG files. With all types it will scale the image by percentage to smaller or larger sizes and with JPG files a quality setting that ranges from 100 down to 0.

With this combination you can get very good quality smaller images as the size reduction effectively sharpens the image and with the JPG quality setting, you can experiment to see how much lower you can go before JPG artifacts start to show up.

I have the documentation done, when I catch up with the libraries I will post the source.

Vortex

Hi Hutch,

Nice work :thumbsup: Tested on Windows 10 64-bit.

Siekmanski

Works on Win8.1, doesn't save with the filename extension.
Creative coders use backward thinking techniques as a strategy.

hutch--

 I use the standard file dialog where you must type in the file extension as well.

Vortex

Hi Hutch,

Like MS Paint, your application could automatically add the extensions.

hutch--

Here is a version that fixes invalid extensions or no extension at all. I don't personally like the technique and if this was release commercial software, I would loop back with an error message if there was an invalid or missing extension. The technique used is to test if there is a valid extension and simply add one if it has not. This is the safest way but you can end up with double extension file names.

flename.bmp.jpg

To back analyse alternatives is a very unreliable way to perform this task.
This is the algo used.

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

fixext proc pname:QWORD,extt:QWORD
  ; -----------------------------------
  ; note that the buffer address is
  ; reused each time the proc is called
  ; -----------------------------------
    LOCAL pbuf  :QWORD
    LOCAL pst1  :QWORD
    LOCAL str1[32]:BYTE

    .data?
      Buff@@$$@@ db 260 dup (?)             ; buffer with mangled name
    .code

    mov pst1, ptr$(str1)                    ; get both pointers
    mov pbuf, ptr$(Buff@@$$@@)

    rcall szCopy,pname,pbuf                 ; copy file name to Buff@@$$@@
    rcall szRight,pbuf,pst1,4               ; get the right 4 characters

    mov pst1, lcase$(pst1)                  ; convert both strings to lower case
    mov extt, lcase$(extt)
    rcall szCmp,pst1,extt                   ; test if they are the same

    .If rax eq 0
      rcall szCatStr,pbuf,extt              ; append the extension if invalid
      mov rax, pbuf                         ; return address of modified buffer
      ret
    .Else
      mov rax, pbuf                         ; just return the buffer address
      ret
    .EndIf

fixext endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

Vortex

Hi Hutch,

Thanks for this version supporting automatic extensions. :thumbsup:

nidud

#7
deleted

hutch--

nidud,

Its a good design but you run into people who use periods within their file names "file.name.ext" and this would truncate the name of the file. You could scan it backwards from the end but its not without its problems. On any serious release software a loop back if there is an extension error is probably the safest way to do it.

nidud

#9
deleted

hutch--

That looks like useful code but the task I have addressed is the file name that is typed into a file dialog box that does not have the drive and path attached to it. I do a bit more work than you have done to avoid a number of problems, I copy the original string to a 260 byte buffer then check if the extension matches, if it does it is passed back to the caller, if it does not match the extension is added to it then returned back to the caller.

I like simple solutions but the simplest solution is for the user to enter the correct file name with the correct extension and then the programmer does not have to make multiple assumptions on how to fix the manually typed entry.