Author Topic: Text Enlarger  (Read 4814 times)

0 Members and 1 Guest are viewing this topic.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Text Enlarger
« on: November 06, 2019, 01:36:48 pm »
This program lets you choose a font color and background color and lets you change the font size using the arrow keys. This could be used in games and programs for opening screens, etc. This also can be used to make signs or whatever you wish.  I used a couple of lines of math from an old 90's program called Wormhole someone made and put online back then to make this program. You also can save the picture as a .bmp file as well as keep making more of them. The commands are in the Title Bar. After it shows your text, you can use the up and down arrow keys to make it larger or smaller. But don't hold down the keys, there's some bug that skips over my lines that stop it from getting too large if you hold it down. S goes to the Save screen to save as a .BMP, Space Bar lets to start over and make new text, and Esc ends the program.  This does not use any other files, such as fonts, etc (besides the .bmp pictures you save). It uses pure math to change the font size. 

Have fun!

(Note: A better version with mixed colors for the text is after this one.)

Code: QB64: [Select]
  1. 'Feel free to use any of this code in your own programs or games.
  2. 'Thank you to the maker of a 1990's program called Wormhole.bas that was put online back then.
  3. 'Made on November 6, 2019 by Ken G.
  4. start:
  5. _LIMIT 200
  6. bb = 0
  7. sz = 2
  8. SCREEN _NEWIMAGE(800, 600, 256)
  9. PRINT "                     Big Text  - by Ken G."
  10. PRINT "This program will make your small text to a larger text in your choice of colors."
  11. PRINT "Use the up and down arrow keys to make your text larger or smaller."
  12. PRINT "Then you can save it as a .BMP file if you wish."
  13. PRINT "Type a word here or just Enter to quit (23 letters, numbers, symbols, or spaces maximum)."
  14. INPUT "-> "; a$
  15. IF a$ = "" THEN END
  16. PRINT "Color Chart"
  17. FOR cc = 1 TO 15
  18.     COLOR cc
  19.     PRINT "Color Number = "; cc
  20.     more:
  21. NEXT cc
  22. INPUT "Type a color number for the background or just Enter for black:"; bb
  23. INPUT "Type a color number for the text:", cl
  24. go:
  25. LOCATE 1, 27
  26. 'First print the text normally in color 1.
  27. 'Then detect the text above using POINT and draw the large text.
  28. FOR a = 0 TO 800 STEP 1 / sz
  29.     FOR b = 0 TO 20 STEP 1 / sz
  30.         IF POINT(a, b) > 0 THEN LINE ((a - 196) * sz, b * sz + 50)-((a - 196) * sz + 2, b * sz + 52), cl, BF
  31.     NEXT b
  32. 'Erase the original small text using the background color you chose.
  33. LINE (0, 0)-(800, 20), bb, BF
  34. IF bb = 0 THEN GOTO skipthis:
  35. 'Paint the rest of the screen white if you chose that.
  36. FOR x = 0 TO 800
  37.     FOR y = 0 TO 600
  38.         IF POINT(x, y) <> 0 THEN GOTO nex:
  39.         PSET (x, y), bb
  40.         nex:
  41.     NEXT y
  42. skipthis:
  43. _TITLE "(S)ave Image, Up and Down Arrow Keys to make text bigger or smaller, Space Bar for a new one, Esc to Quit."
  44. 'Make a loop here so people can choose to save, make more, or quit.
  45.     _LIMIT 200
  46.     t$ = INKEY$
  47.     IF t$ = CHR$(0) + CHR$(72) THEN sz = sz + .5: GOTO go:
  48.     IF t$ = CHR$(0) + CHR$(80) THEN sz = sz - .5: GOTO go:
  49.     IF sz < 2 THEN sz = 2
  50.     IF sz > 15 THEN sz = 15
  51.     IF t$ = "s" OR t$ = "S" THEN GOTO saving:
  52.     IF t$ = " " THEN GOTO start:
  53.     IF t$ = CHR$(27) THEN END
  54.  
  55. 'The rest of this program is the saving code to save as a .bmp picture.
  56. saving:
  57. 'Now we call up the SUB to save the image to BMP.
  58. SaveImage 0, "temp.bmp"
  59. _DELAY .25
  60. PRINT "                   Saving"
  61. PRINT "     Your BMP file will be saved in the"
  62. PRINT "     same directory as this program is."
  63. PRINT "     It can be used with almost any"
  64. PRINT "     other graphics program or website."
  65. PRINT "     It is saved using:"
  66. PRINT "     width: 800  height: 600 pixels."
  67. PRINT "     Type a name to save your picture"
  68. PRINT "     and press the Enter key. Do not"
  69. PRINT "     add .bmp at the end, the program"
  70. PRINT "     will do it automatically."
  71. PRINT "     Also do not use the name temp"
  72. PRINT "     because the program uses that name"
  73. PRINT "     and it would be erased the next time"
  74. PRINT "     you save a picture."
  75. PRINT "     Example: MyPic"
  76. PRINT "     Quit and Enter key ends program."
  77. INPUT "->"; nm$
  78. IF nm$ = "Quit" OR nm$ = "quit" OR nm$ = "QUIT" THEN END
  79. nm$ = nm$ + ".bmp"
  80. 'Checking to see if the file already exists on your computer.
  81. theFileExists = _FILEEXISTS(nm$)
  82. IF theFileExists = -1 THEN
  83.     PRINT "     File Already Exists"
  84.     PRINT "     Saving will delete your old"
  85.     PRINT "     bmp picture."
  86.     PRINT "     Would you like to still do it?"
  87.     PRINT "     (Y/N). Esc ends program."
  88.     llloop:
  89.     _LIMIT 10
  90.     ag2$ = INKEY$
  91.     IF ag2$ = "" THEN GOTO llloop:
  92.     IF ag2$ = "y" OR ag$ = "Y" THEN GOTO saving2:
  93.     IF ag2$ = CHR$(27) THEN END
  94.     GOTO saving:
  95. saving2:
  96. NAME "temp.bmp" AS nm$
  97.  
  98. nm$ = ""
  99. FOR snd = 100 TO 700 STEP 100
  100.     SOUND snd, 2
  101. NEXT snd
  102. GOTO start:
  103.  
  104. 'Here is the SUB needed to save the image to BMP.
  105. 'It also can be used for BMP pictures on your own program.
  106. SUB SaveImage (image AS LONG, filename AS STRING)
  107.     bytesperpixel& = _PIXELSIZE(image&)
  108.     IF bytesperpixel& = 0 THEN PRINT "Text modes unsupported!": END
  109.     IF bytesperpixel& = 1 THEN bpp& = 8 ELSE bpp& = 24
  110.     x& = _WIDTH(image&)
  111.     y& = _HEIGHT(image&)
  112.     b$ = "BM????QB64????" + MKL$(40) + MKL$(x&) + MKL$(y&) + MKI$(1) + MKI$(bpp&) + MKL$(0) + "????" + STRING$(16, 0) 'partial BMP header info(???? to be filled later)
  113.     IF bytesperpixel& = 1 THEN
  114.         FOR c& = 0 TO 255 ' read BGR color settings from JPG image + 1 byte spacer(CHR$(0))
  115.             cv& = _PALETTECOLOR(c&, image&) ' color attribute to read.
  116.             b$ = b$ + CHR$(_BLUE32(cv&)) + CHR$(_GREEN32(cv&)) + CHR$(_RED32(cv&)) + CHR$(0) 'spacer byte
  117.         NEXT
  118.     END IF
  119.     MID$(b$, 11, 4) = MKL$(LEN(b$)) ' image pixel data offset(BMP header)
  120.     lastsource& = _SOURCE
  121.     _SOURCE image&
  122.     IF ((x& * 3) MOD 4) THEN padder$ = STRING$(4 - ((x& * 3) MOD 4), 0)
  123.     FOR py& = y& - 1 TO 0 STEP -1 ' read JPG image pixel color data
  124.         r$ = ""
  125.         FOR px& = 0 TO x& - 1
  126.             c& = POINT(px&, py&) 'POINT 32 bit values are large LONG values
  127.             IF bytesperpixel& = 1 THEN r$ = r$ + CHR$(c&) ELSE r$ = r$ + LEFT$(MKL$(c&), 3)
  128.         NEXT px&
  129.         d$ = d$ + r$ + padder$
  130.     NEXT py&
  131.     _SOURCE lastsource&
  132.     MID$(b$, 35, 4) = MKL$(LEN(d$)) ' image size(BMP header)
  133.     b$ = b$ + d$ ' total file data bytes to create file
  134.     MID$(b$, 3, 4) = MKL$(LEN(b$)) ' size of data file(BMP header)
  135.     IF LCASE$(RIGHT$(filename$, 4)) <> ".bmp" THEN ext$ = ".bmp"
  136.     f& = FREEFILE
  137.     OPEN filename$ + ext$ FOR OUTPUT AS #f&: CLOSE #f& ' erases an existing file
  138.     OPEN filename$ + ext$ FOR BINARY AS #f&
  139.     PUT #f&, , b$
  140.     CLOSE #f&
  141.  

« Last Edit: November 06, 2019, 05:08:57 pm by SierraKen »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Text Enlarger
« Reply #1 on: November 06, 2019, 05:08:24 pm »
I added something most paint programs don't have, mixed colors on the text! You select it in the beginning when it asks you.

(Note: Another update is after this one with a much better looking mixed colors of text.)

Code: QB64: [Select]
  1. 'Feel free to use any of this code in your own programs or games.
  2. 'Thank you to the maker of a 1990's program called Wormhole.bas that was put online back then.
  3. 'Made on November 6, 2019 by Ken G.
  4. start:
  5. _LIMIT 200
  6. bb = 0
  7. sz = 2
  8. mm = 0
  9. SCREEN _NEWIMAGE(800, 600, 256)
  10. PRINT "                     Big Text  - by Ken G."
  11. PRINT "This program will make your small text to a larger text in your choice of colors."
  12. PRINT "Use the up and down arrow keys to make your text larger or smaller."
  13. PRINT "Then you can save it as a .BMP file if you wish."
  14. PRINT "Type a word here or just Enter to quit (23 letters, numbers, symbols, or spaces maximum)."
  15. INPUT "-> "; a$
  16. IF a$ = "" THEN END
  17. PRINT "Color Chart"
  18. FOR cc = 1 TO 15
  19.     COLOR cc
  20.     PRINT "Color Number = "; cc
  21.     more:
  22. NEXT cc
  23. INPUT "Type a color number for the background or just Enter for black:"; bb
  24. INPUT "Do you want mixed colors (Y/N):"; m$
  25. IF LEFT$(m$, 1) = "y" OR LEFT$(m$, 1) = "Y" THEN mm = 1: GOTO go:
  26. INPUT "Type a color number for the text:", cl
  27. go:
  28. LOCATE 1, 27
  29. 'First print the text normally in color 1.
  30. 'Then detect the text above using POINT and draw the large text.
  31. FOR a = 0 TO 800 STEP 1 / sz
  32.     FOR b = 0 TO 20 STEP 1 / sz
  33.         IF mm = 1 THEN
  34.             cl = cl + 1 / sz
  35.             IF cl > 15 THEN cl = 1
  36.         END IF
  37.         IF POINT(a, b) > 0 THEN LINE ((a - 196) * sz, b * sz + 50)-((a - 196) * sz + 2, b * sz + 52), cl, BF
  38.     NEXT b
  39.     IF mm = 1 THEN cl = 1
  40. 'Erase the original small text using the background color you chose.
  41. LINE (0, 0)-(800, 20), bb, BF
  42. IF bb = 0 THEN GOTO skipthis:
  43. 'Paint the rest of the screen white if you chose that.
  44. FOR x = 0 TO 800
  45.     FOR y = 0 TO 600
  46.         IF POINT(x, y) <> 0 THEN GOTO nex:
  47.         PSET (x, y), bb
  48.         nex:
  49.     NEXT y
  50. skipthis:
  51. _TITLE "(S)ave Image, Up and Down Arrow Keys to make text bigger or smaller, Space Bar for a new one, Esc to Quit."
  52. 'Make a loop here so people can choose to save, make more, or quit.
  53.     _LIMIT 200
  54.     t$ = INKEY$
  55.     IF t$ = CHR$(0) + CHR$(72) THEN
  56.         sz = sz + .5
  57.         IF mm = 1 THEN cl = 1
  58.         GOTO go:
  59.     END IF
  60.     IF t$ = CHR$(0) + CHR$(80) THEN
  61.         sz = sz - .5
  62.         IF mm = 1 THEN cl = 1
  63.         GOTO go:
  64.     END IF
  65.     IF sz < 2 THEN sz = 2
  66.     IF sz > 15 THEN sz = 15
  67.     IF t$ = "s" OR t$ = "S" THEN GOTO saving:
  68.     IF t$ = " " THEN GOTO start:
  69.     IF t$ = CHR$(27) THEN END
  70.  
  71. 'The rest of this program is the saving code to save as a .bmp picture.
  72. saving:
  73. 'Now we call up the SUB to save the image to BMP.
  74. SaveImage 0, "temp.bmp"
  75. _DELAY .25
  76. PRINT "                   Saving"
  77. PRINT "     Your BMP file will be saved in the"
  78. PRINT "     same directory as this program is."
  79. PRINT "     It can be used with almost any"
  80. PRINT "     other graphics program or website."
  81. PRINT "     It is saved using:"
  82. PRINT "     width: 800  height: 600 pixels."
  83. PRINT "     Type a name to save your picture"
  84. PRINT "     and press the Enter key. Do not"
  85. PRINT "     add .bmp at the end, the program"
  86. PRINT "     will do it automatically."
  87. PRINT "     Also do not use the name temp"
  88. PRINT "     because the program uses that name"
  89. PRINT "     and it would be erased the next time"
  90. PRINT "     you save a picture."
  91. PRINT "     Example: MyPic"
  92. PRINT "     Quit and Enter key ends program."
  93. INPUT "->"; nm$
  94. IF nm$ = "Quit" OR nm$ = "quit" OR nm$ = "QUIT" THEN END
  95. nm$ = nm$ + ".bmp"
  96. 'Checking to see if the file already exists on your computer.
  97. theFileExists = _FILEEXISTS(nm$)
  98. IF theFileExists = -1 THEN
  99.     PRINT "     File Already Exists"
  100.     PRINT "     Saving will delete your old"
  101.     PRINT "     bmp picture."
  102.     PRINT "     Would you like to still do it?"
  103.     PRINT "     (Y/N). Esc ends program."
  104.     llloop:
  105.     _LIMIT 10
  106.     ag2$ = INKEY$
  107.     IF ag2$ = "" THEN GOTO llloop:
  108.     IF ag2$ = "y" OR ag$ = "Y" THEN GOTO saving2:
  109.     IF ag2$ = CHR$(27) THEN END
  110.     GOTO saving:
  111. saving2:
  112. NAME "temp.bmp" AS nm$
  113.  
  114. nm$ = ""
  115. FOR snd = 100 TO 700 STEP 100
  116.     SOUND snd, 2
  117. NEXT snd
  118. GOTO start:
  119.  
  120. 'Here is the SUB needed to save the image to BMP.
  121. 'It also can be used for BMP pictures on your own program.
  122. SUB SaveImage (image AS LONG, filename AS STRING)
  123.     bytesperpixel& = _PIXELSIZE(image&)
  124.     IF bytesperpixel& = 0 THEN PRINT "Text modes unsupported!": END
  125.     IF bytesperpixel& = 1 THEN bpp& = 8 ELSE bpp& = 24
  126.     x& = _WIDTH(image&)
  127.     y& = _HEIGHT(image&)
  128.     b$ = "BM????QB64????" + MKL$(40) + MKL$(x&) + MKL$(y&) + MKI$(1) + MKI$(bpp&) + MKL$(0) + "????" + STRING$(16, 0) 'partial BMP header info(???? to be filled later)
  129.     IF bytesperpixel& = 1 THEN
  130.         FOR c& = 0 TO 255 ' read BGR color settings from JPG image + 1 byte spacer(CHR$(0))
  131.             cv& = _PALETTECOLOR(c&, image&) ' color attribute to read.
  132.             b$ = b$ + CHR$(_BLUE32(cv&)) + CHR$(_GREEN32(cv&)) + CHR$(_RED32(cv&)) + CHR$(0) 'spacer byte
  133.         NEXT
  134.     END IF
  135.     MID$(b$, 11, 4) = MKL$(LEN(b$)) ' image pixel data offset(BMP header)
  136.     lastsource& = _SOURCE
  137.     _SOURCE image&
  138.     IF ((x& * 3) MOD 4) THEN padder$ = STRING$(4 - ((x& * 3) MOD 4), 0)
  139.     FOR py& = y& - 1 TO 0 STEP -1 ' read JPG image pixel color data
  140.         r$ = ""
  141.         FOR px& = 0 TO x& - 1
  142.             c& = POINT(px&, py&) 'POINT 32 bit values are large LONG values
  143.             IF bytesperpixel& = 1 THEN r$ = r$ + CHR$(c&) ELSE r$ = r$ + LEFT$(MKL$(c&), 3)
  144.         NEXT px&
  145.         d$ = d$ + r$ + padder$
  146.     NEXT py&
  147.     _SOURCE lastsource&
  148.     MID$(b$, 35, 4) = MKL$(LEN(d$)) ' image size(BMP header)
  149.     b$ = b$ + d$ ' total file data bytes to create file
  150.     MID$(b$, 3, 4) = MKL$(LEN(b$)) ' size of data file(BMP header)
  151.     IF LCASE$(RIGHT$(filename$, 4)) <> ".bmp" THEN ext$ = ".bmp"
  152.     f& = FREEFILE
  153.     OPEN filename$ + ext$ FOR OUTPUT AS #f&: CLOSE #f& ' erases an existing file
  154.     OPEN filename$ + ext$ FOR BINARY AS #f&
  155.     PUT #f&, , b$
  156.     CLOSE #f&
  157.  
« Last Edit: November 06, 2019, 05:20:38 pm by SierraKen »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Text Enlarger
« Reply #2 on: November 06, 2019, 05:19:50 pm »
I should have done this before, but here is a much better looking mixed colors of text.

Code: QB64: [Select]
  1. 'Feel free to use any of this code in your own programs or games.
  2. 'Thank you to the maker of a 1990's program called Wormhole.bas that was put online back then.
  3. 'Made on November 6, 2019 by Ken G.
  4. start:
  5. _LIMIT 200
  6. bb = 0
  7. sz = 2
  8. mm = 0
  9. SCREEN _NEWIMAGE(800, 600, 256)
  10. PRINT "                     Big Text  - by Ken G."
  11. PRINT "This program will make your small text to a larger text in your choice of colors."
  12. PRINT "Use the up and down arrow keys to make your text larger or smaller."
  13. PRINT "Then you can save it as a .BMP file if you wish."
  14. PRINT "Type a word here or just Enter to quit (23 letters, numbers, symbols, or spaces maximum)."
  15. INPUT "-> "; a$
  16. IF a$ = "" THEN END
  17. PRINT "Color Chart"
  18. FOR cc = 1 TO 15
  19.     COLOR cc
  20.     PRINT "Color Number = "; cc
  21.     more:
  22. NEXT cc
  23. INPUT "Type a color number for the background or just Enter for black:"; bb
  24. INPUT "Do you want mixed colors (Y/N):"; m$
  25. IF LEFT$(m$, 1) = "y" OR LEFT$(m$, 1) = "Y" THEN mm = 1: cl = 30: GOTO go:
  26. INPUT "Type a color number for the text:", cl
  27. go:
  28. LOCATE 1, 27
  29. 'First print the text normally in color 1.
  30. 'Then detect the text above using POINT and draw the large text.
  31. FOR a = 0 TO 800 STEP 1 / sz
  32.     FOR b = 0 TO 20 STEP 1 / sz
  33.         IF mm = 1 THEN
  34.             cl = cl + 1 / sz
  35.             IF cl > 45 THEN cl = 30
  36.         END IF
  37.         IF POINT(a, b) > 0 THEN LINE ((a - 196) * sz, b * sz + 50)-((a - 196) * sz + 2, b * sz + 52), cl, BF
  38.     NEXT b
  39.     IF mm = 1 THEN cl = 30
  40. 'Erase the original small text using the background color you chose.
  41. LINE (0, 0)-(800, 20), bb, BF
  42. IF bb = 0 THEN GOTO skipthis:
  43. 'Paint the rest of the screen white if you chose that.
  44. FOR x = 0 TO 800
  45.     FOR y = 0 TO 600
  46.         IF POINT(x, y) <> 0 THEN GOTO nex:
  47.         PSET (x, y), bb
  48.         nex:
  49.     NEXT y
  50. skipthis:
  51. _TITLE "(S)ave Image, Up and Down Arrow Keys to make text bigger or smaller, Space Bar for a new one, Esc to Quit."
  52. 'Make a loop here so people can choose to save, make more, or quit.
  53.     _LIMIT 200
  54.     t$ = INKEY$
  55.     IF t$ = CHR$(0) + CHR$(72) THEN
  56.         sz = sz + .5
  57.         IF mm = 1 THEN cl = 30
  58.         GOTO go:
  59.     END IF
  60.     IF t$ = CHR$(0) + CHR$(80) THEN
  61.         sz = sz - .5
  62.         IF mm = 1 THEN cl = 30
  63.         GOTO go:
  64.     END IF
  65.     IF sz < 2 THEN sz = 2
  66.     IF sz > 15 THEN sz = 15
  67.     IF t$ = "s" OR t$ = "S" THEN GOTO saving:
  68.     IF t$ = " " THEN GOTO start:
  69.     IF t$ = CHR$(27) THEN END
  70.  
  71. 'The rest of this program is the saving code to save as a .bmp picture.
  72. saving:
  73. 'Now we call up the SUB to save the image to BMP.
  74. SaveImage 0, "temp.bmp"
  75. _DELAY .25
  76. PRINT "                   Saving"
  77. PRINT "     Your BMP file will be saved in the"
  78. PRINT "     same directory as this program is."
  79. PRINT "     It can be used with almost any"
  80. PRINT "     other graphics program or website."
  81. PRINT "     It is saved using:"
  82. PRINT "     width: 800  height: 600 pixels."
  83. PRINT "     Type a name to save your picture"
  84. PRINT "     and press the Enter key. Do not"
  85. PRINT "     add .bmp at the end, the program"
  86. PRINT "     will do it automatically."
  87. PRINT "     Also do not use the name temp"
  88. PRINT "     because the program uses that name"
  89. PRINT "     and it would be erased the next time"
  90. PRINT "     you save a picture."
  91. PRINT "     Example: MyPic"
  92. PRINT "     Quit and Enter key ends program."
  93. INPUT "->"; nm$
  94. IF nm$ = "Quit" OR nm$ = "quit" OR nm$ = "QUIT" THEN END
  95. nm$ = nm$ + ".bmp"
  96. 'Checking to see if the file already exists on your computer.
  97. theFileExists = _FILEEXISTS(nm$)
  98. IF theFileExists = -1 THEN
  99.     PRINT "     File Already Exists"
  100.     PRINT "     Saving will delete your old"
  101.     PRINT "     bmp picture."
  102.     PRINT "     Would you like to still do it?"
  103.     PRINT "     (Y/N). Esc ends program."
  104.     llloop:
  105.     _LIMIT 10
  106.     ag2$ = INKEY$
  107.     IF ag2$ = "" THEN GOTO llloop:
  108.     IF ag2$ = "y" OR ag$ = "Y" THEN GOTO saving2:
  109.     IF ag2$ = CHR$(27) THEN END
  110.     GOTO saving:
  111. saving2:
  112. NAME "temp.bmp" AS nm$
  113.  
  114. nm$ = ""
  115. FOR snd = 100 TO 700 STEP 100
  116.     SOUND snd, 2
  117. NEXT snd
  118. GOTO start:
  119.  
  120. 'Here is the SUB needed to save the image to BMP.
  121. 'It also can be used for BMP pictures on your own program.
  122. SUB SaveImage (image AS LONG, filename AS STRING)
  123.     bytesperpixel& = _PIXELSIZE(image&)
  124.     IF bytesperpixel& = 0 THEN PRINT "Text modes unsupported!": END
  125.     IF bytesperpixel& = 1 THEN bpp& = 8 ELSE bpp& = 24
  126.     x& = _WIDTH(image&)
  127.     y& = _HEIGHT(image&)
  128.     b$ = "BM????QB64????" + MKL$(40) + MKL$(x&) + MKL$(y&) + MKI$(1) + MKI$(bpp&) + MKL$(0) + "????" + STRING$(16, 0) 'partial BMP header info(???? to be filled later)
  129.     IF bytesperpixel& = 1 THEN
  130.         FOR c& = 0 TO 255 ' read BGR color settings from JPG image + 1 byte spacer(CHR$(0))
  131.             cv& = _PALETTECOLOR(c&, image&) ' color attribute to read.
  132.             b$ = b$ + CHR$(_BLUE32(cv&)) + CHR$(_GREEN32(cv&)) + CHR$(_RED32(cv&)) + CHR$(0) 'spacer byte
  133.         NEXT
  134.     END IF
  135.     MID$(b$, 11, 4) = MKL$(LEN(b$)) ' image pixel data offset(BMP header)
  136.     lastsource& = _SOURCE
  137.     _SOURCE image&
  138.     IF ((x& * 3) MOD 4) THEN padder$ = STRING$(4 - ((x& * 3) MOD 4), 0)
  139.     FOR py& = y& - 1 TO 0 STEP -1 ' read JPG image pixel color data
  140.         r$ = ""
  141.         FOR px& = 0 TO x& - 1
  142.             c& = POINT(px&, py&) 'POINT 32 bit values are large LONG values
  143.             IF bytesperpixel& = 1 THEN r$ = r$ + CHR$(c&) ELSE r$ = r$ + LEFT$(MKL$(c&), 3)
  144.         NEXT px&
  145.         d$ = d$ + r$ + padder$
  146.     NEXT py&
  147.     _SOURCE lastsource&
  148.     MID$(b$, 35, 4) = MKL$(LEN(d$)) ' image size(BMP header)
  149.     b$ = b$ + d$ ' total file data bytes to create file
  150.     MID$(b$, 3, 4) = MKL$(LEN(b$)) ' size of data file(BMP header)
  151.     IF LCASE$(RIGHT$(filename$, 4)) <> ".bmp" THEN ext$ = ".bmp"
  152.     f& = FREEFILE
  153.     OPEN filename$ + ext$ FOR OUTPUT AS #f&: CLOSE #f& ' erases an existing file
  154.     OPEN filename$ + ext$ FOR BINARY AS #f&
  155.     PUT #f&, , b$
  156.     CLOSE #f&
  157.  

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Text Enlarger
« Reply #3 on: November 07, 2019, 09:15:52 pm »
You are welcome Ron! And thanks for the picture made with it! :)

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Text Enlarger
« Reply #4 on: November 08, 2019, 12:19:27 pm »
Here's an example of the Mixed Colors. I made the text pretty big this time.

Kenneth-in-colors.bmp
* Kenneth-in-colors.bmp (Filesize: 469.8 KB, Dimensions: 800x600, Views: 247)

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Text Enlarger
« Reply #5 on: November 08, 2019, 05:06:01 pm »
I've got a little set of routines which I use to do something similar to this, which might interest you a bit:

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(800, 600, 32)
  2. text = TextToImage("Steve is Awesome!", 16, &HFFFF0000, &HFFFFFF00, 0)
  3. text2h = ScaleImage(text, 2, 1) 'twice as high
  4. text2w = ScaleImage(text, 1, 2) 'twice as wide
  5. text4 = ScaleImage(text, 4, 4) 'four times normal size
  6.  
  7.     angle = (angle + 1) MOD 360
  8.     CLS
  9.     DisplayImage text, 50, 50, 0, 1
  10.     DisplayImage text2h, 50, 100, 0, 1
  11.     DisplayImage text2w, 50, 150, 0, 1
  12.     DisplayImage text4, 400, 300, angle, 0
  13.     _LIMIT 60
  14.     _DISPLAY
  15.  
  16. SUB DisplayImage (Image AS LONG, x AS INTEGER, y AS INTEGER, angle AS SINGLE, mode AS _BYTE)
  17.     'Image is the image handle which we use to reference our image.
  18.     'x,y is the X/Y coordinates where we want the image to be at on the screen.
  19.     'angle is the angle which we wish to rotate the image.
  20.     'mode determines HOW we place the image at point X,Y.
  21.     'Mode 0 we center the image at point X,Y
  22.     'Mode 1 we place the Top Left corner of oour image at point X,Y
  23.     'Mode 2 is Bottom Left
  24.     'Mode 3 is Top Right
  25.     'Mode 4 is Bottom Right
  26.  
  27.  
  28.     DIM px(3) AS INTEGER, py(3) AS INTEGER, w AS INTEGER, h AS INTEGER
  29.     DIM sinr AS SINGLE, cosr AS SINGLE, i AS _BYTE
  30.     w = _WIDTH(Image): h = _HEIGHT(Image)
  31.     SELECT CASE mode
  32.         CASE 0 'center
  33.             px(0) = -w \ 2: py(0) = -h \ 2: px(3) = w \ 2: py(3) = -h \ 2
  34.             px(1) = -w \ 2: py(1) = h \ 2: px(2) = w \ 2: py(2) = h \ 2
  35.         CASE 1 'top left
  36.             px(0) = 0: py(0) = 0: px(3) = w: py(3) = 0
  37.             px(1) = 0: py(1) = h: px(2) = w: py(2) = h
  38.         CASE 2 'bottom left
  39.             px(0) = 0: py(0) = -h: px(3) = w: py(3) = -h
  40.             px(1) = 0: py(1) = 0: px(2) = w: py(2) = 0
  41.         CASE 3 'top right
  42.             px(0) = -w: py(0) = 0: px(3) = 0: py(3) = 0
  43.             px(1) = -w: py(1) = h: px(2) = 0: py(2) = h
  44.         CASE 4 'bottom right
  45.             px(0) = -w: py(0) = -h: px(3) = 0: py(3) = -h
  46.             px(1) = -w: py(1) = 0: px(2) = 0: py(2) = 0
  47.     END SELECT
  48.     sinr = SIN(angle / 57.2957795131): cosr = COS(angle / 57.2957795131)
  49.     FOR i = 0 TO 3
  50.         x2 = (px(i) * cosr + sinr * py(i)) + x: y2 = (py(i) * cosr - px(i) * sinr) + y
  51.         px(i) = x2: py(i) = y2
  52.     NEXT
  53.     _MAPTRIANGLE (0, 0)-(0, h - 1)-(w - 1, h - 1), Image TO(px(0), py(0))-(px(1), py(1))-(px(2), py(2))
  54.     _MAPTRIANGLE (0, 0)-(w - 1, 0)-(w - 1, h - 1), Image TO(px(0), py(0))-(px(3), py(3))-(px(2), py(2))
  55.  
  56. FUNCTION TextToImage& (text$, font&, fc&, bfc&, mode AS _BYTE)
  57.     'text$ is the text that we wish to transform into an image.
  58.     'font& is the handle of the font we want to use.
  59.     'fc& is the color of the font we want to use.
  60.     'bfc& is the background color of the font.
  61.  
  62.     'Mode 1 is print forwards
  63.     'Mode 2 is print backwards
  64.     'Mode 3 is print from top to bottom
  65.     'Mode 4 is print from bottom up
  66.     'Mode 0 got lost somewhere, but it's OK.  We check to see if our mode is < 1 or > 4 and compensate automatically if it is to make it one (default).
  67.  
  68.     IF mode < 1 OR mode > 4 THEN mode = 1
  69.     dc& = _DEFAULTCOLOR: bgc& = _BACKGROUNDCOLOR
  70.     D = _DEST
  71.     F = _FONT
  72.     IF font& <> 0 THEN _FONT font&
  73.     IF mode < 3 THEN
  74.         'print the text lengthwise
  75.         w& = _PRINTWIDTH(text$): h& = _FONTHEIGHT
  76.     ELSE
  77.         'print the text vertically
  78.         FOR i = 1 TO LEN(text$)
  79.             IF w& < _PRINTWIDTH(MID$(text$, i, 1)) THEN w& = _PRINTWIDTH(MID$(text$, i, 1))
  80.         NEXT
  81.         h& = _FONTHEIGHT * (LEN(text$))
  82.     END IF
  83.  
  84.     TextToImage& = _NEWIMAGE(w&, h&, 32)
  85.     _DEST TextToImage&
  86.     IF font& <> 0 THEN _FONT font&
  87.     COLOR fc&, bfc&
  88.  
  89.     SELECT CASE mode
  90.         CASE 1
  91.             'Print text forward
  92.             _PRINTSTRING (0, 0), text$
  93.         CASE 2
  94.             'Print text backwards
  95.             temp$ = ""
  96.             FOR i = 0 TO LEN(text$) - 1
  97.                 temp$ = temp$ + MID$(text$, LEN(text$) - i, 1)
  98.             NEXT
  99.             _PRINTSTRING (0, 0), temp$
  100.         CASE 3
  101.             'Print text upwards
  102.             'first lets reverse the text, so it's easy to place
  103.             temp$ = ""
  104.             FOR i = 0 TO LEN(text$) - 1
  105.                 temp$ = temp$ + MID$(text$, LEN(text$) - i, 1)
  106.             NEXT
  107.             'then put it where it belongs
  108.             FOR i = 1 TO LEN(text$)
  109.                 fx = (w& - _PRINTWIDTH(MID$(temp$, i, 1))) / 2 + .99 'This is to center any non-monospaced letters so they look better
  110.                 _PRINTSTRING (fx, _FONTHEIGHT * (i - 1)), MID$(temp$, i, 1)
  111.             NEXT
  112.         CASE 4
  113.             'Print text downwards
  114.             FOR i = 1 TO LEN(text$)
  115.                 fx = (w& - _PRINTWIDTH(MID$(text$, i, 1))) / 2 + .99 'This is to center any non-monospaced letters so they look better
  116.                 _PRINTSTRING (fx, _FONTHEIGHT * (i - 1)), MID$(text$, i, 1)
  117.             NEXT
  118.     END SELECT
  119.     _DEST D
  120.     COLOR dc&, bgc&
  121.     _FONT F
  122.  
  123. FUNCTION ScaleImage& (Image AS LONG, xscale AS SINGLE, yscale AS SINGLE)
  124.     w = _WIDTH(Image): h = _HEIGHT(Image)
  125.     w2 = w * xscale: h2 = h * yscale
  126.     NewImage& = _NEWIMAGE(w2, h2, 32)
  127.     _PUTIMAGE , Image&, NewImage&
  128.     ScaleImage& = NewImage&
  129.  
  130.  

One routine to convert text to an image. Another to scale an image to whatever proportions I want it to have, and another routine to display the image somewhere on the screen, at whatever angle I want it to have on the screen.  ;)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Text Enlarger
« Reply #6 on: November 08, 2019, 05:22:32 pm »
That's pretty cool SMcNeill!