Author Topic: Basic FORM Filler  (Read 3672 times)

0 Members and 1 Guest are viewing this topic.

Offline NOVARSEG

  • Forum Resident
  • Posts: 509
    • View Profile
Basic FORM Filler
« on: March 31, 2021, 10:33:10 pm »
So here is a programming project.

The essential is to move some text around with arrow keys on top of a BMP background
1 pixel at a time. up/down/left/right

The mouse is used for coarse locating of the text and then arrow keys to fine tune the text position

Then print out both text and BMP background

An additional tweak would be to change font size  (maybe with scroll wheel?)

Another essential is to be able to save to a file

The idea is to scan a FORM and save it as a BMP. Most scanners will do a fine job at 300DPI. 
then add the text and save or print.

if this gets any interest then it can be moved to programming section.


****
other ideas

I know that text can be saved as a BMP using Microsoft paint (raster stuff).  QB64 has _CLEARCOLOR.  We know how to make a 32 bit BMP.   Need a background form image and a foreground text image and somehow save the 2 layers as one layer.


Attached file has a green background but it is 24 bit . That's OK _LOADIMAGE converts it to 32 bit.
The trick is to move this small BMP 1 pixel at a time in any direction.
Use _CLEARCOLOR to make the green background transparent.
« Last Edit: April 01, 2021, 12:35:19 am by NOVARSEG »

Offline NOVARSEG

  • Forum Resident
  • Posts: 509
    • View Profile
Re: Basic FORM Filler
« Reply #1 on: April 01, 2021, 02:15:56 am »
Some code by DAV that might help


Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(600, 600, 32)
  2. pic = BASIMAGE1&
  3.  
  4.  
  5. _PUTIMAGE (100, 100), pic
  6.  
  7.  
  8.  
  9. FUNCTION BASIMAGE1& 'hello world.bmp
  10.     v& = _NEWIMAGE(140, 38, 32)
  11.     DIM m AS _MEM: m = _MEMIMAGE(v&)
  12.     A$ = ""
  13.     A$ = A$ + "haIkHfHS32335>[0c0[0k0S#WQK5j6`6`6d9XC0;0;#g0fQkJT`RG=a9Q`MG"
  14.     A$ = A$ + "EDOjCA85bOfnUP9^_M42Q#842Q#842Q#842Qlk#ocRK]dWAmO2<0f^k0m3kc"
  15.     A$ = A$ + "dodJM:ce:fVQC<OD_\7ZG\QjUm#mR=D_\7ZG\QjUml9ZGlSc5X=]?;Om\\XJ"
  16.     A$ = A$ + "GYjUKZfhFW_kIJWhJkJ4K37?<>>2e_\n^>hm=[fkLPiFKKc[n79>WB_Xm]RO"
  17.     A$ = A$ + "]Fe;gD_7;=^Ge<UXGn:bh;n_D<J<nJk7eBhJjQKC[diR_N^YVKLLjFm9HL>V"
  18.     A$ = A$ + "NabgZm9_;mB>U1Snkgc8k_#O06??ZNAk;c=6YiQZmFS?>gBL]eHM6[l8cn4C"
  19.     A$ = A$ + "_\hNEK5[D;j5lLBM<3?SYDm2j_lk=Uh`3g[kckb`FKQf;jjNXoHl2?_Gdkc:"
  20.     A$ = A$ + "o0nmf9eJejL:lM;^]_]5B_<ZZO4jG]NnB^joBd;jh3^WecMSi`2d7;JK<6Rn"
  21.     A$ = A$ + "Nd_8idPa_f0S?>6FfFXnIYGdi\PD[i_T[6;V^`ZnD[]LGk2Xnj:dOikXhnH<"
  22.     A$ = A$ + "6:WQPe5:WL[gW:GN;m2f_#oSA][GBU3A<OG>jUcNn2^W\g]5WTm^bIUGLKk]"
  23.     A$ = A$ + "a_cQaeB?OYDmRnl5MnHeRN1]9_o6oOdiEkLbXm7=oUNWMn;GbdNkDS7Zc5=B"
  24.     A$ = A$ + ";d>dFeOOd[?\bO1ookBe;GEe;[C]]GCjUHo;M8Ki_joSbeOQa09oGA3Zc_<d"
  25.     A$ = A$ + "hVco7UkM8TB_4;gBMNSeRNaCZk7i<jU5GjHdA^_I]mf6iM=1j?NGKFaAmM8F"
  26.     A$ = A$ + "ZN9V_E[][9mR7[kO=fMGMVkg]IMl;a?Q[AMN1jeO82Mo^bmI[ca:7K;emk>h"
  27.     A$ = A$ + "fdXnWbgjN7j52Q#842Q#842Q#842Q#84b73o04eL%%h1"
  28.     btemp$ = ""
  29.     FOR i& = 1 TO LEN(A$) STEP 4: B$ = MID$(A$, i&, 4)
  30.         IF INSTR(1, B$, "%") THEN
  31.             FOR C% = 1 TO LEN(B$): F$ = MID$(B$, C%, 1)
  32.                 IF F$ <> "%" THEN C$ = C$ + F$
  33.             NEXT: B$ = C$: END IF: FOR j = 1 TO LEN(B$)
  34.             IF MID$(B$, j, 1) = "#" THEN
  35.         MID$(B$, j) = "@": END IF: NEXT
  36.         FOR t% = LEN(B$) TO 1 STEP -1
  37.             B& = B& * 64 + ASC(MID$(B$, t%)) - 48
  38.             NEXT: X$ = "": FOR t% = 1 TO LEN(B$) - 1
  39.             X$ = X$ + CHR$(B& AND 255): B& = B& \ 256
  40.     NEXT: btemp$ = btemp$ + X$: NEXT
  41.     btemp$ = _INFLATE$(btemp$)
  42.     _MEMPUT m, m.OFFSET, btemp$: _MEMFREE m
  43.     BASIMAGE1& = _COPYIMAGE(v&): _FREEIMAGE v&

moving text. need to update the green background properly.

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(600, 600, 32)
  2. pic = BASIMAGE1&
  3.  
  4. ' _PUTIMAGE (0, 0), pic&
  5.  
  6. FOR x = 1 TO 100
  7.  
  8.     _PUTIMAGE (100 + x, 100), pic
  9.     _DELAY .3
  10.  
  11.  
  12.  
  13.  
  14. FUNCTION BASIMAGE1& 'hello world.bmp
  15.     v& = _NEWIMAGE(140, 38, 32)
  16.     DIM m AS _MEM: m = _MEMIMAGE(v&)
  17.     A$ = ""
  18.     A$ = A$ + "haIkHfHS32335>[0c0[0k0S#WQK5j6`6`6d9XC0;0;#g0fQkJT`RG=a9Q`MG"
  19.     A$ = A$ + "EDOjCA85bOfnUP9^_M42Q#842Q#842Q#842Qlk#ocRK]dWAmO2<0f^k0m3kc"
  20.     A$ = A$ + "dodJM:ce:fVQC<OD_\7ZG\QjUm#mR=D_\7ZG\QjUml9ZGlSc5X=]?;Om\\XJ"
  21.     A$ = A$ + "GYjUKZfhFW_kIJWhJkJ4K37?<>>2e_\n^>hm=[fkLPiFKKc[n79>WB_Xm]RO"
  22.     A$ = A$ + "]Fe;gD_7;=^Ge<UXGn:bh;n_D<J<nJk7eBhJjQKC[diR_N^YVKLLjFm9HL>V"
  23.     A$ = A$ + "NabgZm9_;mB>U1Snkgc8k_#O06??ZNAk;c=6YiQZmFS?>gBL]eHM6[l8cn4C"
  24.     A$ = A$ + "_\hNEK5[D;j5lLBM<3?SYDm2j_lk=Uh`3g[kckb`FKQf;jjNXoHl2?_Gdkc:"
  25.     A$ = A$ + "o0nmf9eJejL:lM;^]_]5B_<ZZO4jG]NnB^joBd;jh3^WecMSi`2d7;JK<6Rn"
  26.     A$ = A$ + "Nd_8idPa_f0S?>6FfFXnIYGdi\PD[i_T[6;V^`ZnD[]LGk2Xnj:dOikXhnH<"
  27.     A$ = A$ + "6:WQPe5:WL[gW:GN;m2f_#oSA][GBU3A<OG>jUcNn2^W\g]5WTm^bIUGLKk]"
  28.     A$ = A$ + "a_cQaeB?OYDmRnl5MnHeRN1]9_o6oOdiEkLbXm7=oUNWMn;GbdNkDS7Zc5=B"
  29.     A$ = A$ + ";d>dFeOOd[?\bO1ookBe;GEe;[C]]GCjUHo;M8Ki_joSbeOQa09oGA3Zc_<d"
  30.     A$ = A$ + "hVco7UkM8TB_4;gBMNSeRNaCZk7i<jU5GjHdA^_I]mf6iM=1j?NGKFaAmM8F"
  31.     A$ = A$ + "ZN9V_E[][9mR7[kO=fMGMVkg]IMl;a?Q[AMN1jeO82Mo^bmI[ca:7K;emk>h"
  32.     A$ = A$ + "fdXnWbgjN7j52Q#842Q#842Q#842Q#84b73o04eL%%h1"
  33.     btemp$ = ""
  34.     FOR i& = 1 TO LEN(A$) STEP 4: B$ = MID$(A$, i&, 4)
  35.         IF INSTR(1, B$, "%") THEN
  36.             FOR C% = 1 TO LEN(B$): F$ = MID$(B$, C%, 1)
  37.                 IF F$ <> "%" THEN C$ = C$ + F$
  38.             NEXT: B$ = C$: END IF: FOR j = 1 TO LEN(B$)
  39.             IF MID$(B$, j, 1) = "#" THEN
  40.         MID$(B$, j) = "@": END IF: NEXT
  41.         FOR t% = LEN(B$) TO 1 STEP -1
  42.             B& = B& * 64 + ASC(MID$(B$, t%)) - 48
  43.             NEXT: X$ = "": FOR t% = 1 TO LEN(B$) - 1
  44.             X$ = X$ + CHR$(B& AND 255): B& = B& \ 256
  45.     NEXT: btemp$ = btemp$ + X$: NEXT
  46.     btemp$ = _INFLATE$(btemp$)
  47.     _MEMPUT m, m.OFFSET, btemp$: _MEMFREE m
  48.     BASIMAGE1& = _COPYIMAGE(v&): _FREEIMAGE v&
  49.  

« Last Edit: April 01, 2021, 02:30:12 am by NOVARSEG »

Offline NOVARSEG

  • Forum Resident
  • Posts: 509
    • View Profile
Re: Basic FORM Filler
« Reply #2 on: April 01, 2021, 03:15:18 am »
From the WIKI I got this text to move a pixel at a time

This is definite graphics based text

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(1024, 768, 32)
  2.  
  3. h& = _NEWIMAGE(1024, 768, 32)
  4.  
  5. FOR x = 1 TO 100
  6.     _PRINTSTRING (10 + x, 10), "This _PUTIMAGE used no parameters!"
  7.  
  8.     _DELAY .1
  9.  
  10.  
  11.     _SOURCE h&
  12.     _DEST 0
  13.  
  14.     _PUTIMAGE
  15.  
« Last Edit: April 01, 2021, 03:17:15 am by NOVARSEG »

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Basic FORM Filler
« Reply #3 on: April 01, 2021, 07:30:51 am »
Good luck with this!
Shuwatch!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Basic FORM Filler
« Reply #4 on: April 01, 2021, 11:21:15 am »
What is purpose of moving a pixel at a time? Some sort of game?

Why wouldn't you just want to print text directly over image?

And for that matter, why not do everything with less time and space with text?

Are we really just filling out a form or making up a bunch of work for yourself?

Offline NOVARSEG

  • Forum Resident
  • Posts: 509
    • View Profile
Re: Basic FORM Filler
« Reply #5 on: April 01, 2021, 07:19:24 pm »

Quote
What is purpose of moving a pixel at a time? Some sort of game?

Moving a pixel at a time is for fine positioning of text.  It would take much more programming
to auto position text.

Quote
Why wouldn't you just want to print text directly over image?

Thats what Im trying to do.

Quote
And for that matter, why not do everything with less time and space with text?

easier for sure with text.

Quote
Are we really just filling out a form or making up a bunch of work for yourself?

Form fillers are challenging. I'm not trying to make the best.


Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Basic FORM Filler
« Reply #6 on: April 01, 2021, 07:23:37 pm »

Form fillers are challenging. I'm not trying to make the best.
I had an AIAG standard label making program from a year or two ago. I could make a label that used a template and filled in data dynamically. I don't think I have it anymore. Even if I did, I'd rather you take a crack at it yourself.
« Last Edit: April 01, 2021, 07:24:49 pm by SpriggsySpriggs »
Shuwatch!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Basic FORM Filler
« Reply #7 on: April 01, 2021, 08:01:58 pm »
Quote
Moving a pixel at a time is for fine positioning of text.  It would take much more programming
to auto position text.

Quote
Why wouldn't you just want to print text directly over image?

Thats what Im trying to do.

@NOVARSEG

Do you know about _PRINTSTRING(xPixel, yPixel), textLabel$ that starts printing at the precise pixel of x, y for upper left corner of a box the could enclose the print (textLabel$) perfectly. And a box for your label can be calculated from text with _PRINTWIDTH(text$) which takes into account the font you have active. So it wouldn't be hard to use a mouse to drop a box right where you want a label to go and then as you say use image saver code like Dav's.
« Last Edit: April 01, 2021, 08:10:12 pm by bplus »

Offline 191Brian

  • Newbie
  • Posts: 91
    • View Profile
    • My Itch page
Re: Basic FORM Filler
« Reply #8 on: April 02, 2021, 04:52:40 am »
Mmm
Sounds like an interesting challenge.

As Bplus said I would use _printstring with a _printmode option have and array of a user defined type for the form box text, its x,y pos and the font used (assuming you would need different size fonts to fit the text in the boxes).
I would then have loop display the form as an image _putimage display any text already added then the user could click on the form box type in there text which would be _printstringed on the box and stored in the array then allow the user to use the cursor keys to nudge the text into the correct position. Keep looping till the user pressed an F key to save the completed form.

Note I would avoid using bit map for the form image as it produces very large files I would scan to jpg or png.
Brian ...

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Basic FORM Filler
« Reply #9 on: April 02, 2021, 05:40:59 am »
Form = _LOADIMAGE(yourimage)
INPUT “your text); text$

DO
    _PUTIMAGE , Form
    K = _KEYHIT
    SELECT CASE K
        CASE directions: alter X, Y
        CASE enter: print image: System
     END SELECT
     _PRINTSTRING (x, y), text$
LOOP


Isn’t this basically all you’re doing?
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline NOVARSEG

  • Forum Resident
  • Posts: 509
    • View Profile
Re: Basic FORM Filler
« Reply #10 on: April 02, 2021, 09:44:57 pm »
@SMcNeill

Yes essentially it is.   Is it necessary to putimage every time a printstring is used?

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Basic FORM Filler
« Reply #11 on: April 02, 2021, 09:57:56 pm »
@SMcNeill

Yes essentially it is.   Is it necessary to putimage every time a printstring is used?

I’m just using the putimage above basically like a CLS to restore my background as you move the text across it.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!