• Print

Author Topic: TextImage and Color32  (Read 395 times)

SMcNeill

  • Hero Member
  • *****
  • Posts: 2414
    • Email
TextImage and Color32
« on: July 22, 2012, 09:23:51 AM »
A collection of all the text routines from this topic: http://www.qb64.net/forum/index.php?topic=6628.0   in one place and one BM file for easy download and use.

Also collected all the RGB32 Color Constants from this topic: http://www.qb64.net/forum/index.php?topic=6676.0 and placed them into a Color32 BI file for quick use and downloading.  Just plug an 'INCLUDE:'Color32.BU' into the front of your code and use Color Red, White from now on instead of Color _RGB32(255,255,255), _RGB32(255,0,0).   Makes typing things much faster, and much more readable.

Routines inside the TextImage.BM are the following:
ScaleImage -- scale on the X or Y axis.  Make things taller, shorter, wider, narrower, larger, smaller.
Box -- creates a box/button with text for quick display on the screen.  Useful for making a quick mouse click area.
BoxImage& -- a function that makes a box, but gives it an image handle.  Can do anything would want with it after that like any other image.
RainbowImage -- a routine to place a nice rainbow pattern to our text (or another image).  Can also use to custom blend from one color to another.  (Red to Blue)
SaveBackground& -- a function to save our current screen as a background image.
UpdateBackground -- updates the backimage with whatever is now on the screen.
RestoreBackground -- takes our background and restores it back to the screen.
Reverse_RGB32 -- takes a _RGB32 unsigned long number and breaks it back down to give us the red, green, blue values of it.
TextToImage -- converts text into an image file.  Can print it forwards, backwards, up, or down.
DisplayImage -- takes an image handle and displays the image on the screen.  Can use this to rotate the image as much as we'd wish.  Display it on center, or any of the 4 image corners at X,Y coordinates.
SafeLoadFont -- (What I consider to be one of the most useful, and a default way QB64 should handle loading fonts...)  Lets you load a font and doesn't lose your print location doing it.  No more resetting to the top left corner every time you load a font.
MonoPrint -- prints any text in a monoprint state, no matter which font is used.
CenterText -- a quick way to center text at a predefined area on the screen.  Centers both horizontally and vertically.

There's no demo to show the use of any of these files, so refer back to the other posts for now if you haven't followed the topic and don't have a clue what they all can do.  :D  These are just all the routines compiled in one area for quick reference, download, and use.

(And YES, Clippy, I know this isn't a DLL library.  I still feel that it has enough functions and use to be a viable QB64 library and wished to share it here.  If Galleon doesn't want BI and BM libraries here, then he has my full blessings to move it to wherever IS the appropriate place for them.  Maybe someday we'll have an area of the forums dedicated to QB64 libraries and collections alone.)

http://bit.ly/Color32 <--- Color 32.BI
http://bit.ly/TextImage  <--  TextImage.BM
http://bit.ly/TextImage -- Library of QB64 code to manipulate text and images, as a BM library.
http://bit.ly/Color32 -- A set of color CONST for use in 32 bit mode, as a BI library.

http://bit.ly/DataToDrive - A set of routines to quickly and easily get data to and from the disk.  BI and BM files

Clippy

  • Hero Member
  • *****
  • Posts: 16440
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
    • Email
Re: TextImage and Color32
« Reply #1 on: July 22, 2012, 09:39:28 AM »
Never tell your problems to anyone.  80% don't care, and the other 20% are glad you have them!!
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 DLL files in a ZIP: Program64.zip

SMcNeill

  • Hero Member
  • *****
  • Posts: 2414
    • Email
Re: TextImage and Color32
« Reply #2 on: August 02, 2012, 04:55:24 AM »
Update 1 to library:

Added a few new useful routines as follows:

TextArrayToImage -- lets you turn multiple lines of text into an image to manipulate at will.
UpdateBackgroundPart -- to update only part of a background.  Can be much faster than updating the whole thing.
RestoreBackgroundPart -- to restore part of the background to the foreground.  As before - can have some nice speed improvements.
PLtoXY -- Gives your current print location as X,Y coordinates.
PLtoLOC -- Gives your current print location as LOCATE coordinates.
XYtoLOC -- a way to convert X,Y coordinates to a LOCATE coordinate.
LOCtoXY -- a way to convert LOCATE coordinates to X,Y coordinates.

I decided not to write a standard way to display partial images with scroll bars.  They're not hard to do, but the way they display really should be dependent to each program they're ran under.  One thing I always liked about QBasic was that it didn't trap everyone into using the SAME design look.  (Like windows.. all have a red X in the top right corner.. -- WHY?  Why not at the top left for some things, or a blue X, or some other custom design?) 

Note:  There's no demo for any of these available, but they're simple enough to figure out.  Just be careful of your screen mode when using.  Screen 0 will bugger out a lot of the commands (but since these are mainly graphic commands, and SCREEN 0 is non-graphic, that shouldn't be much of a problem honestly.)
http://bit.ly/TextImage -- Library of QB64 code to manipulate text and images, as a BM library.
http://bit.ly/Color32 -- A set of color CONST for use in 32 bit mode, as a BI library.

http://bit.ly/DataToDrive - A set of routines to quickly and easily get data to and from the disk.  BI and BM files

  • Print