QB64.org Forum

Active Forums => Programs => Topic started by: SierraKen on July 01, 2020, 04:08:55 am

Title: Paint Pixels 8 With Right-Click Menu
Post by: SierraKen on July 01, 2020, 04:08:55 am
Here is an early version of Paint Pixels 8. I stayed up until 1 am tonight putting this together. Thank you Dav for the menu code! Now you can paint away with the mouse and not having to mess with the keyboard while painting. You just right click the paint screen and it brings up a menu for everything! If any of you find bugs, please tell me, thanks. All of the required files are in the zip folder.
This version also has everything version 7 had except for less instructions. I figured that nobody would want to use the keys to change modes now but I kept them in the code just in case. The boxes and circles are only made one at a time and are made where you first click to turn the menu on. The lines also start there but keep going, as before, to keep making attached lines until you right click and use the menu again. Using the version 7 Undo feature in the menu, you can always undo something you just made, including one continuous drawing or erasing. Same with erasing anything else you just did like a box, a circle, lines, and fill-ins. I hope you all enjoy this. If you have any suggestions, feel free to tell me. I may or may not be able to do a lot other things though.

Update: This post's zip file has been removed to fix problems and update many things. Scroll down to the post with the next zip file to get it.
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: SierraKen on July 01, 2020, 08:17:29 pm
I'm almost ready to release another update, which has much better line, box, and circle control with the mouse, but I ran into a bug that I can't seem to find. Can you guys help me? What's happening is after you paint a tiny bit and Save it, then paint some more, and then right click on the screen to open the menu again, it automatically goes to either Save or Open or anything without me choosing something (or even seeing the menu). Then for some strange reason, it's like the mouse left button is stuck down and wherever I move the mouse on the screen, it paints white, which isn't even the paint or erase color that's set on. I don't know if this is a memory leak or what's going on. I know the menu code uses _MEMCOPY and _MEMFREE down at the very bottom of my program. I appreciate the help.


Update: Huge memory issue found, please delete this version if you have it. Code has been removed.
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: Dav on July 02, 2020, 01:52:37 pm
There does appear to be some weirdness going on - it happens to me sometimes, not all the time.    Maybe there's some some variable or mousebutton hangovers that need to be cleared.  I'll play around with it and see what I can find.

- Dav
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: SierraKen on July 02, 2020, 01:56:51 pm
Thanks Dav! I hope we can find out what's going on.
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: Dav on July 02, 2020, 02:35:47 pm
I added something in the menu function that seems to have cleared it up for me.  In the code I added ### in the comments so you can search & find it quick.  Basically I just made sure both mouse buttons are up before exiting the popup menu.  I also played with clearing the a% variable, but I think the mouse thing was causing it, ast lease the error isn't happening for me now.  See if it happens to you with the change.

Something I noticed before in the program, the circles and box routine will sometimes cause the program to crash when moving the mouse pointer a lot.  May want to look into that too.

- Dav 

Code: QB64: [Select]
  1. 'Paint Pixels 8
  2. 'by Sierraken and B+
  3. 'Made on June 30, 2020
  4. 'Technical Notes:
  5. 'First I want to thank all of the people that have helped me so far in this program:
  6. 'B+ for the color picker and help with the circles, boxes and rays and other help.
  7. 'Petr for help with the file opening and saving dialog and saveimage libraries.
  8. 'SpriggySpriggs for his file opening and saving examples that inspired me to keep going.
  9. 'Dav for the Right Click Menu.
  10. 'Thank you also to everyone else who has used and helped me with this!
  11. 'New Additions for Version 8:
  12. 'Right Click Menu to select everything you need to draw with.
  13. 'Fixed Lines, Circles, and Boxes so that you can put them anywhere using the mouse by
  14. 'dragging their sizes with the left mouse button. Also lets you place as many as you want.
  15. 'Made boxes not fill-in anymore because there is already a fill-in option.
  16. '-----------------------------------------------------------------------------------------------
  17. '$include:'saveimage.bi'
  18. '$include:'opensave.bi'
  19. '=== =============DEFINES FOR RIGHT CLICK MENU - CHANGE TO SUIT ==========================
  20. DECLARE FUNCTION RightClickMenu% ()
  21.  
  22. DIM SHARED RightClickItems: RightClickItems = 22 '    <----- Number of items in your menu
  23. DIM SHARED RightClickList$(1 TO RightClickItems)
  24.  
  25. RightClickList$(1) = "New" '     <------------ List all your menu items here
  26. RightClickList$(2) = "Open..."
  27. RightClickList$(3) = "Save As..."
  28. RightClickList$(4) = "---" '   <------------ This means it's a separator (---)
  29. RightClickList$(5) = "Draw"
  30. RightClickList$(6) = "---"
  31. RightClickList$(7) = "Erase"
  32. RightClickList$(8) = "---"
  33. RightClickList$(9) = "Color"
  34. RightClickList$(10) = "Straight Lines"
  35. RightClickList$(11) = "Circles"
  36. RightClickList$(12) = "Boxes"
  37. RightClickList$(13) = "Fill-In"
  38. RightClickList$(14) = "---"
  39. RightClickList$(15) = "Undo"
  40. RightClickList$(16) = "---" '     <------------ (another separator)
  41. RightClickList$(17) = "Print"
  42. RightClickList$(18) = "---"
  43. RightClickList$(19) = "Help"
  44. RightClickList$(20) = "Exit Menu"
  45. RightClickList$(21) = "---"
  46. RightClickList$(22) = "Exit Paint Pixels"
  47.  
  48. '========================================================================================
  49.  
  50.  
  51. _LIMIT 1000
  52. start:
  53. _TITLE "Paint Pixels 8"
  54. WIDTH 40, 43
  55. COLOR 15, 0
  56. PRINT "          Paint Pixels 8"
  57. PRINT "         By Ken G. and B+"
  58. PRINT "          Instructions"
  59. PRINT "  Right-Click on the drawing screen"
  60. PRINT "  with your mouse to see the Menu."
  61. PRINT "  Supports: JPG, PNG, GIF, BMP"
  62. PRINT "Use mouse to paint and also to plot and"
  63. PRINT "change sizes of lines, circles, and"
  64. PRINT "squares holding down the left mouse"
  65. PRINT "button. Release button to keep them."
  66. PRINT "  Press the Space Bar to begin."
  67. PRINT "        Or Esc to quit."
  68. paintpixelsinst:
  69. ecc$ = INKEY$
  70. IF ecc$ = " " THEN GOTO start2:
  71. IF ecc$ = CHR$(27) THEN END
  72. IF ecc$ = "" THEN GOTO paintpixelsinst:
  73. GOTO paintpixelsinst:
  74. start2:
  75. IF ist = 1 THEN ist = 0: GOTO start4:
  76. _TITLE "Paint Pixels 8"
  77. WIDTH 40, 43
  78. COLOR 15, 0
  79. PRINT "            Screen Size"
  80. PRINT "         (1) 640 x 480"
  81. PRINT "         (2) 800 x 600"
  82. PRINT "         (3) 1024 x 768"
  83. PRINT "         (4) 1536 x 1024"
  84. PRINT "         (5) Other"
  85. PRINT "Type number (1-5) here:"
  86. screensize:
  87. screensz = VAL(INKEY$)
  88. IF screensz = 1 THEN screenx = 640: screeny = 480: GOTO nextsc:
  89. IF screensz = 2 THEN screenx = 800: screeny = 600: GOTO nextsc:
  90. IF screensz = 3 THEN screenx = 1024: screeny = 768: GOTO nextsc:
  91. IF screensz = 4 THEN screenx = 1536: screeny = 1024: GOTO nextsc:
  92. IF screensz = 5 THEN
  93.     morescreensz:
  94.     PRINT
  95.     INPUT "Horizontal X (640-1920): ", screenx
  96.     IF screenx < 640 OR screenx > 1920 THEN PRINT "Try again.": GOTO morescreensz:
  97.     INPUT "Vertical   Y (480-1024): ", screeny
  98.     IF screeny < 480 OR screeny > 1024 THEN PRINT "Try again.": GOTO morescreensz:
  99.     GOTO nextsc:
  100. GOTO screensize:
  101.  
  102. 'Choose Background Color.
  103. nextsc:
  104. background& = _NEWIMAGE(800, 600, 32)
  105. begin = 1
  106. bcol = 0
  107. background& = _LOADIMAGE("colorwheelpage.png", 32)
  108. SCREEN background&
  109. mouseLeftButton = 0
  110. colorwheel:
  111. _LIMIT 1000
  112.     mousex = _MOUSEX
  113.     mousey = _MOUSEY
  114.     mouseLeftButton = _MOUSEBUTTON(1)
  115. IF mouseLeftButton = -1 THEN
  116.     back& = POINT(mousex, mousey)
  117.     IF back& = _RGB32(0, 0, 0) THEN bcol = 1
  118.     mouseLeftButton = 0
  119.     mousex = 0: mousey = 0
  120.     GOTO start3:
  121. GOTO colorwheel:
  122. start3:
  123. _LIMIT 1000
  124. undo& = _NEWIMAGE(screenx, screeny, 32)
  125. s& = _NEWIMAGE(screenx, screeny, 32)
  126. picture& = _NEWIMAGE(screenx, screeny, 32)
  127. LINE (0, 0)-(screenx, screeny), back&, BF
  128. _PUTIMAGE , s&, picture&
  129. begin = 1
  130. _TITLE "Choose Your Paint Color Here By Using The 4 Sliders With Your Mouse."
  131. GOSUB chosencolor:
  132. start4:
  133. m = 1
  134. _TITLE "Right Click Mouse To See Menu."
  135. '---------------------------------------------------
  136. 'Here is the main loop of the program when painting.
  137. '---------------------------------------------------
  138.  
  139.     'a% = 0 '### making sure a% is cleared (used by Dav for testing)
  140.  
  141.     _LIMIT 1000
  142.     _PUTIMAGE , picture&, s&
  143.     SCREEN s&
  144.         mousex = _MOUSEX
  145.         mousey = _MOUSEY
  146.         mouseLeftButton = _MOUSEBUTTON(1)
  147.         mouseRightButton = _MOUSEBUTTON(2)
  148.     LOOP
  149.     IF mouseLeftButton = 0 THEN button = 1
  150.     a$ = INKEY$
  151.     a% = RightClickMenu% ' <----- Check for rightclick menu
  152.  
  153.     '=== what did you select?
  154.     IF a% > 0 THEN
  155.         IF a% = 1 THEN a$ = "1"
  156.         IF a% = 2 THEN a$ = "l"
  157.         IF a% = 3 THEN a$ = "s"
  158.         IF a% = 5 THEN a$ = "d"
  159.         IF a% = 7 THEN a$ = "e"
  160.         IF a% = 9 THEN a$ = "c"
  161.         IF a% = 10 THEN a$ = "r": lastx = 0: lasty = 0
  162.         IF a% = 11 THEN a$ = "o": lastx = 0: lasty = 0
  163.         IF a% = 12 THEN a$ = "b": lastx = 0: lasty = 0
  164.         IF a% = 13 THEN a$ = "f"
  165.         IF a% = 15 THEN a$ = "u"
  166.         IF a% = 17 THEN a$ = "p"
  167.         IF a% = 19 THEN a$ = "i"
  168.         IF a% = 20 THEN a% = 0
  169.         IF a% = 22 THEN END
  170.         mouseLeftButton = 0
  171.         a% = 0
  172.     END IF
  173.     'Here is when someone whipes the screen blank with the space bar.
  174.     IF a$ = "1" THEN a$ = "": GOTO start2:
  175.     IF a$ = "s" OR a$ = "S" THEN
  176.         a$ = ""
  177.         GOSUB saving:
  178.     END IF
  179.     IF a$ = "l" OR a$ = "L" THEN
  180.         a$ = ""
  181.         GOSUB loading:
  182.     END IF
  183.     IF a$ = "i" OR a$ = "I" OR a$ = CHR$(27) THEN m = 0: ist = 1: a$ = "": GOTO start:
  184.     'Here is code needed to call up the Windows Color Picker.
  185.     'It also uses the code on top of this program and the Function at the end
  186.     'of this program.
  187.     IF a$ = "c" OR a$ = "C" THEN
  188.         a$ = ""
  189.         chosencolor:
  190.         check$ = colorDialog$
  191.         IF check$ <> "" THEN clr~& = VAL(check$) 'ELSE <<< don't change drawing color
  192.         IF begin = 1 THEN begin = 0: RETURN
  193.     END IF
  194.     IF a$ = "d" OR a$ = "D" THEN
  195.         a$ = ""
  196.         a& = 0
  197.         m = 1
  198.         mm = 1
  199.     END IF
  200.     IF m = 1 THEN
  201.         IF mouseLeftButton THEN
  202.             IF button = 1 THEN lastx = mousex: lasty = mousey: undo& = _COPYIMAGE(0)
  203.             FOR sz = .25 TO 2 STEP .25
  204.                 LINE (mousex, mousey)-(lastx + sz, lasty + sz), clr~&
  205.                 LINE (mousex + sz, mousey + sz)-(lastx + sz, lasty + sz), clr~&
  206.                 LINE (mousex + sz, mousey)-(lastx + sz, lasty), clr~&
  207.                 LINE (mousex, mousey + sz)-(lastx, lasty + sz), clr~&
  208.             NEXT sz
  209.             button = 0
  210.             mm = 0
  211.             lastx = mousex: lasty = mousey
  212.             _PUTIMAGE , s&, picture&
  213.         END IF
  214.     END IF
  215.     IF a$ = "e" OR a$ = "E" THEN
  216.         a$ = ""
  217.         a& = 0
  218.         m = 2
  219.         mm = 2
  220.     END IF
  221.     IF mouseLeftButton = 0 AND mm = 2 THEN undo& = _COPYIMAGE(0)
  222.     IF m = 2 THEN
  223.         IF mouseLeftButton THEN
  224.             IF button = 1 THEN lastx = mousex: lasty = mousey: undo& = _COPYIMAGE(0)
  225.             FOR sz = .25 TO 2 STEP .25
  226.                 LINE (mousex, mousey)-(lastx + sz, lasty + sz), back&
  227.                 LINE (mousex + sz, mousey + sz)-(lastx + sz, lasty + sz), back&
  228.                 LINE (mousex + sz, mousey)-(lastx + sz, lasty), back&
  229.                 LINE (mousex, mousey + sz)-(lastx, lasty + sz), back&
  230.             NEXT sz
  231.             button = 0
  232.             mm = 0
  233.             lastx = mousex: lasty = mousey
  234.             _PUTIMAGE , s&, picture&
  235.         END IF
  236.     END IF
  237.     'Here is the Ray Lines code.
  238.     IF a$ = "r" OR a$ = "R" THEN
  239.         a$ = ""
  240.         a% = 0
  241.         m = 3
  242.         IF mouseLeftButton = 0 THEN undo& = _COPYIMAGE(0)
  243.     END IF
  244.     IF m = 3 THEN
  245.         IF mouseLeftButton THEN
  246.             IF mm = 3 THEN undo& = _COPYIMAGE(0)
  247.             IF mm = 0 THEN lastx = mousex: lasty = mousey
  248.             FOR sz = .25 TO 2 STEP .25
  249.                 LINE (lastx, lasty)-(mousex, mousey), clr~&
  250.                 LINE (lastx + sz, lasty)-(mousex + sz, mousey), clr~&
  251.                 LINE (lastx, lasty + sz)-(mousex, mousey + sz), clr~&
  252.                 LINE (lastx, lasty + sz)-(mousex + sz, mousey), clr~&
  253.             NEXT sz
  254.             mm = 3
  255.         END IF
  256.         IF mouseLeftButton = 0 AND mm = 3 THEN
  257.             FOR sz = .25 TO 2 STEP .25
  258.                 LINE (lastx, lasty)-(mousex, mousey), clr~&
  259.                 LINE (lastx + sz, lasty)-(mousex + sz, mousey), clr~&
  260.                 LINE (lastx, lasty + sz)-(mousex, mousey + sz), clr~&
  261.                 LINE (lastx, lasty + sz)-(mousex + sz, mousey), clr~&
  262.             NEXT sz
  263.             _PUTIMAGE , s&, picture&
  264.             lastx = mousex: lasty = mousey
  265.             mm = 0
  266.         END IF
  267.     END IF
  268.     'Here is the Orbit Circles code.
  269.     IF a$ = "o" OR a$ = "O" THEN
  270.         a$ = ""
  271.         a% = 0
  272.         m = 4
  273.         IF mouseLeftButton = 0 THEN undo& = _COPYIMAGE(0)
  274.     END IF
  275.     IF m = 4 THEN
  276.         IF mouseLeftButton THEN
  277.             IF mm = 4 THEN undo& = _COPYIMAGE(0)
  278.             IF mm = 0 THEN lastx = mousex: lasty = mousey
  279.             IF mousex < lastx THEN size = lastx - mousex
  280.             IF mousex > lastx THEN size = mousex - lastx
  281.             IF mousey < lasty THEN size2 = lasty - mousey
  282.             IF mousey > lasty THEN size2 = mousey - lasty
  283.             one:
  284.             seconds = seconds + .01
  285.             s = (60 - seconds) * 6 + size
  286.             x = INT(SIN(s / 180 * 3.141592) * size) + lastx
  287.             y = INT(COS(s / 180 * 3.141592) * size2) + lasty
  288.             CIRCLE (x, y), 1, clr~&
  289.             IF seconds > 60 THEN
  290.                 seconds = 0
  291.                 GOTO two:
  292.             END IF
  293.             GOTO one:
  294.             two:
  295.             mm = 4
  296.         END IF
  297.         IF mouseLeftButton = 0 AND mm = 4 THEN
  298.             three:
  299.             seconds = seconds + .01
  300.             s = (60 - seconds) * 6 + size
  301.             x = INT(SIN(s / 180 * 3.141592) * size) + lastx
  302.             y = INT(COS(s / 180 * 3.141592) * size2) + lasty
  303.             CIRCLE (x, y), 1, clr~&
  304.             IF seconds > 60 THEN
  305.                 seconds = 0
  306.                 GOTO four:
  307.             END IF
  308.             GOTO three:
  309.             four:
  310.             _PUTIMAGE , s&, picture&
  311.             lastx = mousex: lasty = mousey
  312.             mm = 0
  313.             size = 0: size2 = 0
  314.         END IF
  315.     END IF
  316.     'Here is the Boxes code.
  317.     IF a$ = "b" OR a$ = "B" THEN
  318.         a$ = ""
  319.         a% = 0
  320.         m = 5
  321.         lastx = mousex: lasty = mousey
  322.         IF mouseLeftButton = 0 THEN undo& = _COPYIMAGE(0)
  323.     END IF
  324.     IF m = 5 THEN
  325.         IF mouseLeftButton THEN
  326.             IF mm = 5 THEN undo& = _COPYIMAGE(0)
  327.             IF mm = 0 THEN lastx = mousex: lasty = mousey
  328.             FOR sz = .25 TO 2 STEP .25
  329.                 LINE (lastx - sz, lasty - sz)-(mousex + sz, mousey + sz), clr~&, B
  330.             NEXT sz
  331.             mm = 5
  332.         END IF
  333.         IF mouseLeftButton = 0 AND mm = 5 THEN
  334.             FOR sz = .25 TO 2 STEP .25
  335.                 LINE (lastx - sz, lasty - sz)-(mousex + sz, mousey + sz), clr~&, B
  336.             NEXT sz
  337.             _PUTIMAGE , s&, picture&
  338.             lastx = mousex: lasty = mousey
  339.             mm = 0
  340.         END IF
  341.     END IF
  342.     'Here is Fill-In
  343.     IF a$ = "f" OR a$ = "F" THEN
  344.         a$ = ""
  345.         m = 6
  346.         mouseLeftButton = 0
  347.     END IF
  348.     IF m = 6 THEN
  349.         IF mouseLeftButton THEN undo& = _COPYIMAGE(0)
  350.         IF mouseLeftButton THEN paint3 mousex, mousey, clr~&
  351.         IF mouseLeftButton THEN mouseLeftButton = 0
  352.         _PUTIMAGE , s&, picture&
  353.     END IF
  354.     IF a$ = "u" OR a$ = "U" THEN
  355.         a$ = ""
  356.         SCREEN undo&
  357.         s& = undo&
  358.         _PUTIMAGE , s&, picture&
  359.         mouseLeftButton = 0
  360.     END IF
  361.     'Here is the Printing of the picture.
  362.     IF a$ = "p" OR a$ = "P" THEN
  363.         a$ = ""
  364.         m = 0
  365.         IF bcol <> 1 THEN
  366.             j& = _COPYIMAGE(0)
  367.             _DELAY .25
  368.             INPUT "Print on printer (Y/N)?", i$ 'print screen page on printer
  369.             CLS
  370.             SCREEN j&
  371.             _DELAY .25
  372.             IF LEFT$(i$, 1) = "y" OR LEFT$(i$, 1) = "Y" THEN
  373.                 'printer prep (code copied and pasted from bplus Free Calendar Program)
  374.                 YMAX = _HEIGHT: XMAX = _WIDTH
  375.                 landscape& = _NEWIMAGE(YMAX, XMAX, 32)
  376.                 _MAPTRIANGLE (XMAX, 0)-(0, 0)-(0, YMAX), 0 TO(0, 0)-(0, XMAX)-(YMAX, XMAX), landscape&
  377.                 _MAPTRIANGLE (XMAX, 0)-(XMAX, YMAX)-(0, YMAX), 0 TO(0, 0)-(YMAX, 0)-(YMAX, XMAX), landscape&
  378.                 _PRINTIMAGE landscape&
  379.                 _DELAY 2
  380.                 landscape& = 0
  381.                 s& = j&
  382.             END IF
  383.         END IF
  384.     END IF
  385.  
  386. 'Saving Section
  387. saving:
  388. nm$ = GetSaveFileName("Save Image", ".\", "JPG Image (.jpg)|*.jpg|PNG Image (.png)|*.png|GIF Image (.gif)|*.gif|BMP Image (.bmp)|*.bmp", 1, OFN_OVERWRITEPROMPT + OFN_NOCHANGEDIR, _WINDOWHANDLE)
  389. IF nm$ = "" THEN GOTO skipsave:
  390. Result = SaveImage(nm$, 0, 0, 0, _WIDTH(img), _HEIGHT(img)) 'first zero is your screen, second zero is X start, 3th zero is y start
  391. nm$ = ""
  392. skipsave:
  393. m = 0
  394. a% = 0
  395. a$ = ""
  396. mouseLeftButton = 0
  397. button = 1
  398.  
  399. 'Loading Section
  400. loading:
  401. nm$ = GetOpenFileName$("Open Image", ".\", "JPG Image (.jpg)|*.jpg|PNG Image (.png)|*.png|GIF Image (.gif)|*.gif|BMP Image (.bmp)|*.bmp", 1, OFN_FILEMUSTEXIST + OFN_NOCHANGEDIR + OFN_READONLY, _WINDOWHANDLE)
  402. IF nm$ = "" THEN GOTO skipopen:
  403. l = 0
  404. i& = _LOADIMAGE(nm$, 32)
  405. s& = i&
  406. i& = 0
  407. screenx = _WIDTH
  408. screeny = _HEIGHT
  409. picture& = _NEWIMAGE(screenx, screeny, 32)
  410. back& = _RGB32(255, 255, 255)
  411. nm$ = ""
  412. skipopen:
  413. m = 0
  414. a% = 0
  415. a$ = ""
  416. mouseLeftButton = 0
  417. button = 1
  418.  
  419.  
  420. FUNCTION colorDialog$
  421.  
  422.     'first screen dimensions items to restore at exit
  423.     DIM curRow AS INTEGER, curCol AS INTEGER, autoDisplay AS INTEGER
  424.     DIM curScrn AS LONG, backScrn AS LONG 'some handles
  425.  
  426.     DIM cd AS LONG
  427.     DIM makeConst$, k$
  428.     DIM f AS SINGLE
  429.  
  430.     'save old settings to restore at end ofsub
  431.     curRow = CSRLIN
  432.     curCol = POS(0)
  433.     autoDisplay = _AUTODISPLAY
  434.     sw = _WIDTH
  435.     sh = _HEIGHT
  436.     fg = _DEFAULTCOLOR
  437.     bg = _BACKGROUNDCOLOR
  438.     _KEYCLEAR
  439.     'screen snapshot
  440.     curScrn = _DEST
  441.     backScrn = _NEWIMAGE(sw, sh, 32)
  442.     _PUTIMAGE , curScrn, backScrn
  443.  
  444.     cd = _NEWIMAGE(800, 600, 32)
  445.     SCREEN cd
  446.     r = 128: g = 128: b = 128: a = 128
  447.     COLOR &HFFDDDDDD, 0
  448.     DO
  449.         CLS
  450.         makeConst$ = "&H" + RIGHT$(STRING$(8, "0") + HEX$(_RGBA32(r, g, b, a)), 8)
  451.         slider 16, 10, r, "Red"
  452.         slider 16, 60, g, "Green"
  453.         slider 16, 110, b, "Blue"
  454.         slider 16, 160, a, "Alpha"
  455.         _PRINTSTRING (150, 260), "Press Enter or Spacebar, if you want to use the color: " + makeConst$
  456.         _PRINTSTRING (210, 280), "Press Escape or Q to not use any color, returns 0."
  457.         LINE (90, 300)-(710, 590), , B
  458.         FOR i = 100 TO 700
  459.             f = 255 * (i - 100) / 600
  460.             LINE (i, 310)-STEP(0, 30), _RGB32(f, 0, 0): LINE (i, 310)-STEP(0, 20), VAL(makeConst$)
  461.             LINE (i, 340)-STEP(0, 30), _RGB32(0, f, 0): LINE (i, 340)-STEP(0, 20), VAL(makeConst$)
  462.             LINE (i, 370)-STEP(0, 30), _RGB32(0, 0, f): LINE (i, 370)-STEP(0, 20), VAL(makeConst$)
  463.             LINE (i, 400)-STEP(0, 30), _RGB32(f, f, 0): LINE (i, 400)-STEP(0, 20), VAL(makeConst$)
  464.             LINE (i, 430)-STEP(0, 30), _RGB32(0, f, f): LINE (i, 430)-STEP(0, 20), VAL(makeConst$)
  465.             LINE (i, 460)-STEP(0, 30), _RGB32(f, 0, f): LINE (i, 460)-STEP(0, 20), VAL(makeConst$)
  466.             LINE (i, 490)-STEP(0, 30), _RGB32(f, f, f): LINE (i, 490)-STEP(0, 20), VAL(makeConst$)
  467.             LINE (i, 520)-STEP(0, 30), _RGB32(0, 0, 0): LINE (i, 520)-STEP(0, 20), VAL(makeConst$)
  468.             LINE (i, 550)-STEP(0, 30), _RGB32(255, 255, 255): LINE (i, 550)-STEP(0, 20), VAL(makeConst$)
  469.         NEXT
  470.         WHILE _MOUSEINPUT: WEND
  471.         mb = _MOUSEBUTTON(1)
  472.         IF mb THEN 'clear it
  473.             mx = _MOUSEX: my = _MOUSEY
  474.             IF mx >= 16 AND mx <= 781 THEN
  475.                 IF my >= 10 AND my <= 50 THEN
  476.                     r = INT((mx - 16) / 3)
  477.                 ELSEIF my >= 60 AND my <= 100 THEN
  478.                     g = INT((mx - 16) / 3)
  479.                 ELSEIF my >= 110 AND my <= 150 THEN
  480.                     b = INT((mx - 16) / 3)
  481.                 ELSEIF my >= 160 AND my <= 200 THEN
  482.                     a = INT((mx - 16) / 3)
  483.                 END IF
  484.             END IF
  485.         END IF
  486.         k$ = INKEY$
  487.         IF LEN(k$) THEN
  488.             IF ASC(k$) = 27 OR k$ = "q" THEN EXIT DO
  489.             IF ASC(k$) = 13 OR k$ = " " THEN colorDialog$ = makeConst$: EXIT DO
  490.         END IF
  491.         _DISPLAY
  492.         _LIMIT 60
  493.     LOOP
  494.  
  495.     'put things back
  496.     SCREEN curScrn
  497.     COLOR _RGB32(255, 255, 255), _RGB32(0, 0, 0): CLS
  498.     _PUTIMAGE , backScrn
  499.     _DISPLAY
  500.     COLOR fg, bg
  501.     _FREEIMAGE backScrn
  502.     _FREEIMAGE cd
  503.     IF autoDisplay THEN _AUTODISPLAY
  504.     'clear key presses
  505.     _KEYCLEAR
  506.     'clear mouse clicks
  507.     mb = _MOUSEBUTTON(1)
  508.     IF mb THEN 'clear it
  509.         WHILE mb 'OK!
  510.             IF _MOUSEINPUT THEN mb = _MOUSEBUTTON(1)
  511.             _LIMIT 10
  512.         WEND
  513.     END IF
  514.     LOCATE curRow, curCol
  515.  
  516.  
  517. SUB slider (x, y, value, label$)
  518.     DIM c~&, s$
  519.     SELECT CASE label$
  520.         CASE "Red": c~& = &HFFFF0000
  521.         CASE "Green": c~& = &HFF008800
  522.         CASE "Blue": c~& = &HFF0000FF
  523.         CASE "Alpha": c~& = &H88FFFFFF
  524.     END SELECT
  525.     LINE (x, y)-STEP(765, 40), c~&, B
  526.     LINE (x, y)-STEP(3 * value, 40), c~&, BF
  527.     s2$ = STR$(value)
  528.     s3$ = LTRIM$(RTRIM$(s2$))
  529.     s$ = label$ + " = " + s3$
  530.     _PRINTSTRING (x + 384 - 4 * LEN(s$), y + 12), s$
  531.  
  532. SUB paint3 (x0, y0, fill AS _UNSIGNED LONG) ' needs max, min functions
  533.     DIM fillColor AS _UNSIGNED LONG, W, H, parentF, tick, ystart, ystop, xstart, xstop, x, y
  534.     fillColor = POINT(x0, y0)
  535.     'PRINT fillColor
  536.     W = _WIDTH - 1: H = _HEIGHT - 1
  537.     DIM temp(W, H)
  538.     temp(x0, y0) = 1: parentF = 1
  539.     PSET (x0, y0), fill
  540.     WHILE parentF = 1
  541.         parentF = 0: tick = tick + 1
  542.         ystart = max(y0 - tick, 0): ystop = min(y0 + tick, H)
  543.         y = ystart
  544.         WHILE y <= ystop
  545.             xstart = max(x0 - tick, 0): xstop = min(x0 + tick, W)
  546.             x = xstart
  547.             WHILE x <= xstop
  548.                 IF POINT(x, y) = fillColor AND temp(x, y) = 0 THEN
  549.                     IF temp(max(0, x - 1), y) THEN
  550.                         temp(x, y) = 1: parentF = 1: PSET (x, y), fill
  551.                     ELSEIF temp(min(x + 1, W), y) THEN
  552.                         temp(x, y) = 1: parentF = 1: PSET (x, y), fill
  553.                     ELSEIF temp(x, max(y - 1, 0)) THEN
  554.                         temp(x, y) = 1: parentF = 1: PSET (x, y), fill
  555.                     ELSEIF temp(x, min(y + 1, H)) THEN
  556.                         temp(x, y) = 1: parentF = 1: PSET (x, y), fill
  557.                     END IF
  558.                 END IF
  559.                 x = x + 1
  560.             WEND
  561.             y = y + 1
  562.         WEND
  563.     WEND
  564.  
  565.  
  566. FUNCTION min (n1, n2)
  567.     IF n1 > n2 THEN min = n2 ELSE min = n1
  568.  
  569. FUNCTION max (n1, n2)
  570.     IF n1 < n2 THEN max = n2 ELSE max = n1
  571.  
  572. '================================================================================
  573. '================================================================================
  574. '================================================================================
  575. FUNCTION RightClickMenu% ()
  576.  
  577.     'Returns 0 if nothing selected, else return number of item selected.
  578.     'Requires RightClickList$ array defined.
  579.  
  580.     Cheese = _MOUSEINPUT
  581.  
  582.  
  583.         Row = FIX(_MOUSEY / 16): Col = FIX(_MOUSEX / 8)
  584.  
  585.         x = Col * 8 - 8: y = Row * 16 - 16
  586.  
  587.         '=== Compute BoxWidth based on longest menu item string length
  588.         BoxWidth = 0
  589.         FOR t = 1 TO RightClickItems
  590.             temp = LEN(RightClickList$(t))
  591.             IF LEFT$(RightClickList$(t), 1) = "-" THEN temp = temp - 1
  592.             IF temp > BoxWidth THEN BoxWidth = temp
  593.         NEXT: BoxWidth = BoxWidth * 8
  594.  
  595.         '=== Compute BoxHeight based on num of menu items
  596.         BoxHeight = RightClickItems * 16
  597.  
  598.         '===== Make sure Mouse not too close to edge of screen
  599.         '===== If it is, Adjust x & y position here, move in closer...
  600.         IF _MOUSEX < 20 THEN
  601.             Col = 3: x = Col * 8 - 8:
  602.         END IF
  603.         IF _MOUSEX + BoxWidth + 20 > _WIDTH THEN
  604.             xm = _WIDTH - (BoxWidth + 10)
  605.             Col = FIX(xm / 8): x = Col * 8 - 8:
  606.         END IF
  607.         IF _MOUSEY < 20 THEN
  608.             Row = 2: y = Row * 16 - 16
  609.         END IF
  610.         IF _MOUSEY + BoxHeight + 20 > _HEIGHT THEN
  611.             xy = _HEIGHT - (BoxHeight + 10)
  612.             Row = FIX(xy / 16): y = Row * 16 - 16
  613.         END IF
  614.  
  615.         FirstRow = Row - 1
  616.  
  617.         '=== copy screen using _mem (thanks Steve!)
  618.         DIM m AS _MEM, n AS _MEM
  619.         m = _MEMIMAGE(0)
  620.         n = _MEMNEW(m.SIZE)
  621.         _MEMCOPY m, m.OFFSET, m.SIZE TO n, n.OFFSET
  622.  
  623.         '=== trap until buttons up
  624.         DO
  625.             nibble = _MOUSEINPUT
  626.         LOOP UNTIL NOT _MOUSEBUTTON(2)
  627.  
  628.         '=== Draw Box (10 pix padding)
  629.         LINE (x - 10, y - 10)-(x + 10 + BoxWidth, y + 10 + BoxHeight), _RGB(214, 211, 206), BF
  630.         LINE (x + 10 + BoxWidth, y - 10)-(x + 10 + BoxWidth, y + 10 + BoxHeight), _RGB(66, 65, 66), B
  631.         LINE (x - 10, y + 10 + BoxHeight)-(x + 10 + BoxWidth, y + 10 + BoxHeight), _RGB(66, 65, 66), B
  632.         LINE (x - 9, y - 9)-(x + 9 + BoxWidth, y + 9 + BoxHeight), _RGB(255, 255, 255), B
  633.         LINE (x - 9, y - 9)-(x + 9 + BoxWidth, y + 9 + BoxHeight), _RGB(255, 255, 255), B
  634.         LINE (x + 9 + BoxWidth, y - 9)-(x + 9 + BoxWidth, y + 9 + BoxHeight), _RGB(127, 127, 127), B
  635.         LINE (x - 9, y + 9 + BoxHeight)-(x + 9 + BoxWidth, y + 9 + BoxHeight), _RGB(127, 127, 127), B
  636.  
  637.         DO
  638.             Cheese = _MOUSEINPUT
  639.  
  640.             '=== if in bounds of menu space
  641.             IF _MOUSEX > x AND _MOUSEX < x + BoxWidth AND _MOUSEY > y AND _MOUSEY < y + BoxHeight THEN
  642.  
  643.                 '=== Draw items
  644.                 IF CurRow <> FIX(_MOUSEY / 16) THEN
  645.                     COLOR _RGB(0, 0, 0), _RGB(214, 211, 206)
  646.                     FOR t = 0 TO RightClickItems - 1
  647.                         IF Row + t - FirstRow = FIX(_MOUSEY / 16) - FirstRow + 1 THEN
  648.                             'Draw highlight box...
  649.                             COLOR _RGB(255, 255, 255), _RGB(8, 36, 107)
  650.                         ELSE
  651.                             IF LEFT$(RightClickList$(t + 1), 1) = "-" THEN
  652.                                 COLOR _RGB(130, 130, 130), _RGB(214, 211, 206)
  653.                             ELSE
  654.                                 COLOR _RGB(0, 0, 0), _RGB(214, 211, 206)
  655.                             END IF
  656.                         END IF
  657.                         padme = BoxWidth / 8 - LEN(RightClickList$(t + 1))
  658.                         IF LEFT$(RightClickList$(t + 1), 1) = "-" THEN padme = padme - 1
  659.                         IF padme > 0 THEN pad$ = SPACE$(padme) ELSE pad$ = ""
  660.                         LOCATE Row + t, Col - 1
  661.                         IF RightClickList$(t + 1) = "---" THEN
  662.                             COLOR _RGB(127, 127, 127), _RGB(214, 211, 206)
  663.                             PRINT STRING$((BoxWidth / 8) + 2, 196);
  664.                         ELSE
  665.                             IF LEFT$(RightClickList$(t + 1), 1) = "-" THEN
  666.                                 PRINT " "; RIGHT$(RightClickList$(t + 1), LEN(RightClickList$(t + 1)) - 1); pad$; " ";
  667.                             ELSE
  668.                                 PRINT " "; RightClickList$(t + 1); pad$; " ";
  669.                             END IF
  670.                         END IF
  671.                     NEXT
  672.                 END IF
  673.  
  674.                 IF _MOUSEBUTTON(1) THEN
  675.                     sel = FIX(_MOUSEY / 16) - FirstRow + 1
  676.                     'only select if not a seperator and not disabled
  677.                     IF RightClickList$(sel) <> "---" THEN
  678.                         IF LEFT$(RightClickList$(sel), 1) <> "-" THEN
  679.                             RightClickMenu% = sel: EXIT DO
  680.                         END IF
  681.                     END IF
  682.                 END IF
  683.  
  684.                 IF _MOUSEBUTTON(2) THEN EXIT DO
  685.  
  686.             ELSE
  687.  
  688.                 '=== Draw items
  689.                 IF FIX(_MOUSEY / 16) <> CurRow THEN
  690.                     FOR t = 0 TO RightClickItems - 1
  691.                         padme = BoxWidth / 8 - LEN(RightClickList$(t + 1))
  692.                         IF LEFT$(RightClickList$(t + 1), 1) = "-" THEN padme = padme - 1
  693.                         IF padme > 0 THEN pad$ = SPACE$(padme) ELSE pad$ = ""
  694.                         LOCATE Row + t, Col - 1
  695.                         IF RightClickList$(t + 1) = "---" THEN
  696.                             COLOR _RGB(127, 127, 127), _RGB(214, 211, 206)
  697.                             PRINT STRING$((BoxWidth / 8) + 2, 196);
  698.                         ELSE
  699.  
  700.                             IF LEFT$(RightClickList$(t + 1), 1) = "-" THEN
  701.                                 COLOR _RGB(127, 127, 127), _RGB(214, 211, 206)
  702.                                 PRINT " "; RIGHT$(RightClickList$(t + 1), LEN(RightClickList$(t + 1)) - 1); pad$; " ";
  703.                             ELSE
  704.                                 COLOR _RGB(0, 0, 0), _RGB(214, 211, 206)
  705.                                 PRINT " "; RightClickList$(t + 1); pad$; " ";
  706.                             END IF
  707.  
  708.                         END IF
  709.                     NEXT
  710.                 END IF
  711.  
  712.                 IF _MOUSEBUTTON(1) OR _MOUSEBUTTON(2) THEN EXIT DO
  713.  
  714.             END IF
  715.  
  716.             '=== Mark current row mouse is in
  717.             CurRow = FIX(_MOUSEY / 16)
  718.  
  719.         LOOP
  720.  
  721.         '### Make sure both buttons are up before leaving
  722.         '### Added by Dav for bug testing...
  723.         DO
  724.             nibble = _MOUSEINPUT
  725.             IF _MOUSEBUTTON(1) = 0 AND _MOUSEBUTTON(2) = 0 THEN EXIT DO
  726.         LOOP
  727.  
  728.         '=== restore screen
  729.         _MEMCOPY n, n.OFFSET, n.SIZE TO m, m.OFFSET
  730.         _MEMFREE m: _MEMFREE n
  731.  
  732.     END IF
  733.  
  734. '================================================================================
  735. '================================================================================
  736. '================================================================================
  737.  
  738.  
  739. '$include:'saveimage.bm'
  740. '$include:'opensave.bm'
  741.  
  742.  
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: SierraKen on July 02, 2020, 06:16:53 pm
Thanks Dav, that did the job perfectly. I also fixed the freeze-ups like you were talking about. I added some _WAIT commands and sped up the _LIMIT command to 1500. I also decided to DIM all of the variables and strings I use (but not anyone else's code that's in the program since they may already be dimmed and I don't know anything about Functions). That seems to do the job. I've ran many tests on it and I guess if someone went totally nuts and used their mouse faster than I could possibly go, there COULD be a chance it freezes up still, but even then maybe not. Of course almost all apps on a Windows computer can freeze up if you totally went crazy with it. LOL Oh, I also found out that both you and I are using the same m variable for 2 different things, so I changed mine to mo (which stands for mode). I know you were using yours for memory.

For everyone: Here is the updated ZIP file with all of the files needed to run. I will remove the zip file above so nobody can run into the errors I've fixed. I have decided to removed the paint screen keyboard commands completely (except Esc to go back to the front page). This updated version also has new ways to use Straight Lines, Circles, and Boxes. After selecting what you want to draw with, you click on where you want it to be and then hold down the left mouse button to make the right size and shape. When you release the left mouse button, it puts it there on your picture. You will notice that often it's hard to see the lines, circles, and boxes as you resize them, but it's as good as I can do I believe. I tried them with _DISPLAY but that didn't work. So here it is, this might be the final version for awhile. I've worked so hard on this little program off and on since last August or so. I still remember the first version using X and Y data text files to store the images LOL. Tell me what you think, it's been a labor of love.

Supports: JPG, PNG, GIF, BMP files.

Update: I have deleted this zip file again to make lines, circles, and boxes show up TONS better. Scroll down to the next zip please.
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: SierraKen on July 02, 2020, 09:36:16 pm
I figured out how to make the lines, circles, and boxes show up perfectly when you reshape and resize them with the mouse. _DISPLAY does work, I just had to add it to the right locations and also put _AUTODISPLAY at the end of the modes. :))) Here is the zip file, hopefully the last one for version 8. I hope you enjoy it. And I apologize for so many zip files on this thread, the older ones have been deleted.

Update: Another fixed .zip file is below. Sorry guys!
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: bplus on July 02, 2020, 10:05:00 pm
Man!

@SierraKen you've come a long way! That pop-up is great addition along with background selector, you fixed the box and circle drawing, very impressive!
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: Dav on July 02, 2020, 10:09:16 pm
Good job.  It's working better for me too - no crashes yet.  For some reason though the fill-in stopped working right in the middle of creating my happy little world.  I was planning a hideaway cabin by the lake, but thats ok, as Bob Ross said - we don't make mistakes - we have happy little accidents.

- Dav

 


Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: SierraKen on July 02, 2020, 10:25:12 pm
Thanks B+ and Dav! :)))

Dav, I just fixed it. You had to click twice the first time for Fill to work but it was because I accidentally had 2 different places to make the mouse button 0. So here is the zip file all fixed up and as good as new. :)

"Woops I did it again!"... I removed the zip file again to fix it. Dav is helping me test it out. The fix should be on the next zip.

Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: SierraKen on July 02, 2020, 10:38:34 pm
By the way, that's a great pic you made Dav!
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: Dav on July 02, 2020, 11:21:31 pm
Thanks!  The fill-in is working good now.  However, I still get an occasional crash when drawing circles, and also erasing.  I was going to draw a fly buzzing on the right side of this frog for it to eat, but it crashed out (I saved it first).  Poor Kermit has to go hungry now.  It's not easy being green.

(I kind of copied this character from another frog picture I was looking at, so I didn't invent this frog character)

- Dav

 


Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: SierraKen on July 02, 2020, 11:41:27 pm
LOL GREAT Frog!

I think I fixed it. I upped the _DELAY on the circles a little bit and I found an unnecessary line in the Eraser section that copied the screen one too many times. Please try this one for me. Thanks.

Update: Zip removed again because of newer bug. It is fixed on this forum thread's page 2 (The next one with the zip file).
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: Dav on July 03, 2020, 11:23:31 am
Yes - it's much more stable for me now. The erasing crashes haven't happened again, but circle did only once while making this next image.

There is a problem using boxes & circles after opening an image. Try selecting drawing a box or circle after opening a BMP, it's not working for me after opening something.  However, if you first select draw and then do a box/circle they will work again.   

I have a color picking suggestion - It would be helpful when picking a new color that the currently selected color is set in the selection boxes, instead of going back to default.

- Dav

  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: SierraKen on July 03, 2020, 12:19:02 pm
Cool drawing!
That's really bizarre about your not being able to use boxes or circles without drawing first because it doesn't happen on my computer. Plus it's automatically set on drawing mode when you start the program. So since I can't duplicate the problem, I can't fix it. I did overlook it briefly to see if anything stood out but I can't see anything. I am wondering though, are you using an older computer? I use the 64 bit QB64. If that makes any difference I have no idea. I just know faster computers run things smoother.
And that is an interesting idea for the color picker. B+ would have to do that since that is all his code.
Anyway, thanks for the help Dav. I appreciate it.

Edit: I apologize, I just re-read what you said and wasn't opening a picture first before selecting boxes or circles. I just did it and see what you are talking about. I'll check into it. Thank you.
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: SierraKen on July 03, 2020, 02:07:08 pm
I apologize, I just re-read what you said and I didn't open a file first, now I just did and see what you are talking about. On my computer it is making a bunch of squares or circles and one time. I will look into it. Thanks.
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: SierraKen on July 03, 2020, 02:52:26 pm
LOL I fixed it! After tinkering with it for about 30 minutes, it came to me instantly that I forgot to put a _PUTIMAGE command in the Loading section. I had a SCREEN command to show the loaded image, but I didn't put the brand new image in memory with _PUTIMAGE. That is why when you went directly to circles and boxes, it wouldn't know the last picture you loaded and it just threw circles on the screen without constantly putting the last image in it's place to make the animated resizing with the mouse. Whew! Thank you for pointing that out to me!

Here is the fixed version. Hopefully there's no more bugs. lol Please check though, I want to make sure before I post a final Version 8.

Update: Huge memory issue found, please delete this version if you have it. Zip file has been removed.
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: Dav on July 03, 2020, 05:32:26 pm
Cool - I'll give a good test tonight.

- Dav
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: Dav on July 03, 2020, 07:27:08 pm
Working great, @SierraKen!   I've made a few pics already and without any crashes.  I also tested it on my slower laptop, and it works smoothly on tha too.  Here's an image that used all the drawing tools and had no crashes.  The only thing I noticed is that after you save/load files more than once in the program there starts to appear gibberish on the bottom of the format selection line.  I'll post a small pic of that of what I mean.

Over all - good job!

- Dav

  [ This attachment cannot be displayed inline in 'Print Page' view ]  

  [ This attachment cannot be displayed inline in 'Print Page' view ]  

Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: SMcNeill on July 03, 2020, 07:37:33 pm
In response to Dav's last post:

Seems as if that's an image of a Windows Library call.  If so, the string sent with the variable types (JPG, PNG, gif, bmp...) probably needs to be null terminated.  (CHR$(0))
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: SierraKen on July 03, 2020, 07:42:36 pm
Thanks Dav!!! Yes, I've told other people about that gibberish problem a couple days ago and they pointed out it was because of my _TITLE command, which was a big reason I got rid of changing that command in the main loop. It copied text from it and put it there LOL. About the gibberish, I have no idea why it does that. It must be something in the OPENSAVE or the SaveImage libraries that is missing or something that cannot even be fixed, I have no idea, I didn't many any of the library files. If anyone out there knows of a way to fix it, I would be glad to change it. But it's a very very minor error and the funny thing is that I've seen this same problem before on older programs that weren't even from QB64.
I'll be working on adding windows text to the painted picture soon. I put up an example on a new thread you can check out if you want. Thanks again Dav for all your help.

Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: SierraKen on July 03, 2020, 07:45:46 pm
Steve, would that be fixed in my program or would it be only in the libraries? Because I don't want to touch the libraries myself.
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: SMcNeill on July 03, 2020, 08:02:51 pm
Steve, would that be fixed in my program or would it be only in the libraries? Because I don't want to touch the libraries myself.

It's probably on your side.  Look for the string where you set the acceptable file types, and add a + CHR$(0) to the end of it.  See if that doesn't correct the problem.
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: SierraKen on July 03, 2020, 08:15:33 pm
Awesome, I think I got it! I tested it around 8 times or more and nothing gibberish or different comes up now. This is where I added that CHR$(0) at:

Code: QB64: [Select]
  1. saving:
  2. nm$ = GetSaveFileName("Save Image", ".\", "JPG Image (.jpg)|*.jpg|PNG Image (.png)|*.png|GIF Image (.gif)|*.gif|BMP Image (.bmp)|*.bmp" + CHR$(0), 1, OFN_OVERWRITEPROMPT + OFN_NOCHANGEDIR, _WINDOWHANDLE)
  3.  

and also here (because once I even found the gibberish on the tiny jpg, etc. list LOL):
Code: QB64: [Select]
  1. loading:
  2. nm$ = GetOpenFileName$("Open Image", ".\", "JPG Image (.jpg)|*.jpg|PNG Image (.png)|*.png|GIF Image (.gif)|*.gif|BMP Image (.bmp)|*.bmp" + CHR$(0), 1, OFN_FILEMUSTEXIST + OFN_NOCHANGEDIR + OFN_READONLY, _WINDOWHANDLE)
  3.  

Dav, is it fixed on your end?

Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: SMcNeill on July 03, 2020, 08:32:37 pm
That looks like the proper place to fix the issue to me.  👍
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: SierraKen on July 03, 2020, 10:34:00 pm
OK, I got the Text Mode all finished! Dav or someone else can try it out for me if you wish. I tested it many times myself. It requires Windows to use the Arial Font and lets you select the size from 12 to 72. After you choose Text on the menu, it asks you on the screen what text you want and after pressing Enter, it asks you what size (12-72). Then you left click anywhere on the screen to add it. You can only do one at a time but you just do it over again if you want another one, right click for the menu and choose Text again. I also made certain that Undo works with it too, and Save. Below is an example of what it can do now. Also in the attachments is the new zip file with all the needed files. This time it's not only a new .bas file but also another .png color wheel that I added to choose your text color.



 
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: Dav on July 03, 2020, 11:00:16 pm
That did it, Ken.  Great.  The gibberish is gone.  And good eye, Steve! 

Text is working fine for me here.  It's a nice addition.  Played around with it some.  I have to hit the sack now - I'll pick it up again tomorrow and test it more.

- Dav

  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: SierraKen on July 03, 2020, 11:06:05 pm
Wow, awesome picture! Thanks again for the help!
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: bplus on July 04, 2020, 11:33:43 am
Hey looks like the start of a Icon or Logo for the app! Red Green Blue: PP8

@Dav might be in a position to quit his day job ✨
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: Dav on July 04, 2020, 01:14:10 pm
Lol @bplus. My day job quit me in March thanks to the virus.  But it's starting to come back a little bit, been playing outdoor concerts for places that will let me.

@SierraKen, Looks like there is still some crash issues.  I've been giving PP8 a hard test this morning.  I never have a crash using Draw, Erase, fill-in - but lines, boxes and circles will still occasionally crash when used a lot.   I also encountered a memory error once which terminated the program.   Also, once when using boxes the program just froze up and the mouse pointer turned to the 'waiting' icon.  Had to task kill it to end program.  It seems the crashing starts after a while into the work, not at the beginning of using the program.

- Dav
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: SierraKen on July 04, 2020, 01:23:00 pm
Thanks Dav but I don't even know where to start with fixing that. I'll look into it a little bit but a lot of that could just be the way QB64 is made. BASIC languages are never as rock solid stable as C or other languages that professionals use. This app isn't a professional app and won't be for sale so I'm not too worried about it. Languages that move from top to bottom like BASIC does seem to have a way of jumping away if you try real hard to make it do so. I "could" be wrong about QB64, but I really don't know if there's a way to fix that or not. Also, anyone can break almost any app if they really try super hard. But I appreciate the testing Dav, you have done a lot for me on this program. Like I said, I'll do a few longer tests and see what happens. It also just might be the way I structured the main loop itself along with the circles, lines, and boxes that memory might jump away from. I wouldn't know.
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: Dav on July 04, 2020, 01:24:38 pm
I understand.  Here's something to check that may be an easy fix:

1) Select DRAW, but don't draw anything.
2) Now select LINES and start to draw a line.

The line will always start at the top left corner, and not where the mouse is. 

EDIT: Also, I'm having fun playing with this. So thanks for making it.  It seems it kind of irritate my wife a little who keeps asking why I keep drawing little pics, which I admit kind of makes it even more fun...

- Dav
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: bplus on July 04, 2020, 01:30:21 pm
Quote
which I admit kind of makes it even more fun.

LOL comedy too!
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: SierraKen on July 04, 2020, 05:13:32 pm
I found the problem but haven't fixed it yet and I'm not sure if I can. Every time someone does a Ray, Box, Circle, whatever, it keeps adding to the memory usage of the computer. Look at the picture below I attached and it explains it all. :( This is horrendous to me because if I can't fix it, I will have to dump the whole project. Right now I'm trying to see if _FREEIMAGE will help if I can use it. Maybe someone out there can tell me where to put FREEIMAGE at? I know it won't work if the image is currently on the screen. But I'll play with it and see what happens.
I just can't believe it... 2 GB of memory usage just for a bunch of lines on the screen. I will remove any zip files and code on this thread, for now.
Dav and anyone else that has this app, please delete it. I don't want memory problems to happen to your computer. But keep up with this thread for any fixes.

Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: bplus on July 04, 2020, 05:23:49 pm
Yes _FREEIMAGE sounds like a solution. Are you creating new images in a SUB or FUNCTION, these would have to be cleared (_FREEIMAGE) before exit I think.
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: SMcNeill on July 04, 2020, 05:29:26 pm
You're allocating memory for images and screens, and then you never free them, causing your memory usage to just grow and grow endlessly.

Looking at the code in Dav's code box on the first page of posts, I see a lot of lines like:

       IF mouseLeftButton = 0 THEN undo& = _COPYIMAGE(0)

The above is making a copy of the screen with each mouse click, but I don't see any point where you ever free those images.

Try something along the line of:

       IF mouseLeftButton = 0 THEN
             IF undo& THEN _FREEIMAGE(undo&)
             undo& = _COPYIMAGE(0)
       END IF

Check to see if you need to free an old image, before you overwrite the handle and create a new one.
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: Dav on July 04, 2020, 06:26:32 pm
Yes, I think that is the solution too.  Please don't abandon it, Ken - you've come so far.

- Dav

EDIT: Removed code. ....

Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: SierraKen on July 04, 2020, 07:14:33 pm
Here is the Fixed Version everybody. Please use this copy and toss out any older copies.

You guys just saved a project that I've worked on for a year, I can't believe it! THANK YOU!!!!

Dav, mine works fine, I didn't run your copy, I just went through all your code and added Steve's and your example to mine. I also added it to my Load area and also my Print area. Seems to work fine now. Below is another picture of proof. Earlier today I added something new to it as well: Shadow Text. When you select Text and type in what you say and what size, it then asks you if you want Shadow Text or not. If you say Y (or Yes or Yessserrreeebob... or YEESSSSSSSSSSSSSSESTWERTWERTEWRTRTG) - Gotta love LEFT$. :), then it makes a duplicate text that's a slightly different color than the text you chose, under it and to the side. Try it out! Here is the new Zip File. Oh, I also slowed the whole program down from LIMIT 1500 to LIMIT 500 because I noticed that Windows said it was "VERY HIGH" on the power usage. Now it is just "High". 

Dav, of course feel free to test mine out if you wish and get back to me, thanks!

Update: Scroll down again for the newest zip file. This one has been deleted.

Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: Dav on July 04, 2020, 07:21:19 pm
Great!  I'll grab it an draw something with it.  I will have to test it late though.  Gotta go to a gig tonight now. 

- Dav
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: SierraKen on July 04, 2020, 07:24:18 pm
Woops, I mean the Shadow Text is over it and to the side, but when you click you are actually clicking the top area of where the shadow is. You will see. :)
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: Dav on July 04, 2020, 10:42:09 pm
Hi @SierraKen.  I tried out the latest version.  Much better!  I had to change a couple of things though, and after doing all the errors have gone. 

I was getting Illegal function call errors drawing anything after doing an UNDO first, so I added undo& = _COPYIMAGE(0) at the end of the undo section that corrected it.  On line 556.

Also, I had to comment out a line in the loading section - around line # 610.  For some reason the _FREEIMAGE i& was causing the same illegal errors too.  So I just comment it out and now I get no errors opening or drawing anything.   The memory usage doesn't seem to grow and grow like before, so it's a fairly stable and enjoyable program to use now.

I drew this image 4 times in a row without any errors or crashes (never could have done that before in previous versions).

- Dav

  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: SierraKen on July 04, 2020, 10:53:38 pm
Wow thanks Dav! I just changed it to how you say. Thanks for the help. Below is the newest zip file.





Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: Dav on July 05, 2020, 03:50:11 pm
I think you got it done, @SierraKen!  I've been doodling hours today with the program and have no issues whatsoever.  I'll post one more picture made with PP8 to say thanks - this was just the fun diversion I needed this weekend.

- Dav

  [ This attachment cannot be displayed inline in 'Print Page' view ]  


Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: SierraKen on July 05, 2020, 04:00:21 pm
Awesome!! Thank you Dav! Hey, would you like your name on it as well? I have mine and B+ in the opening screen, I can put yours on it too if you want. I might also make an opening graphic soon and then it will be complete. For now anyway until my mind wanders and thinks of some other wild idea to add to it. LOL
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: SMcNeill on July 05, 2020, 04:25:06 pm
Awesome!! Thank you Dav! Hey, would you like your name on it as well? I have mine and B+ in the opening screen, I can put yours on it too if you want. I might also make an opening graphic soon and then it will be complete. For now anyway until my mind wanders and thinks of some other wild idea to add to it. LOL

And nobody ever puts my name on anything.  /sniffle...

NOT EVEN ME!!  /waaaaaaaahhhhhhh!!!
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: SierraKen on July 05, 2020, 04:37:39 pm
ROFL Steve, sure I will! :)) You helped more than anyone else actually.... :). But really you did help me fix my huge problem yesterday and other problems, so I'll add your name.
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: SMcNeill on July 05, 2020, 04:53:24 pm
No worries.  Nobody ever has to include my name in anything; it's not required, nor expected.   I just like pestering folks for no good reason.  Call it Pete's bad influence.  :D
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: SierraKen on July 05, 2020, 05:07:04 pm
LOL Steve, I did it anyways, because I also included that it was developed at this forum. So I figured why not this time, especially since I've been working on it off and on for a year now lol.? :) I also took it upon me and added Dav's name and his amazing graphic he made the other day as the Title screen. If any of you don't like this, please tell me and I'll edit it. But I like it.
I also fixed the "Shadow Text" by making it more like Dav's Title screen and renamed it "3D Text". Check it out and tell me what you think everyone.

The updated zip file is in attachments. Thank you everyone for the help! Also included below is an example of the 3D Text.

Oh, just so you guys know, the title screen is displayed for 5 seconds and then automatically goes to the older screen.





Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: bplus on July 05, 2020, 08:18:11 pm
@SierraKen

I'd like to congratulate you again but I do not wish to curse you with another round of bugs and glitches. Dang, too much Blackjack! I am getting superstitious. ;-))
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: SierraKen on July 05, 2020, 09:10:53 pm
LOL Thanks :). I might even start up a website again and post this and only my best apps I've made on it. Am thinking about it anyway.
Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: Dav on July 05, 2020, 09:58:16 pm
Hey, thanks Ken.  Wow, now I wish i hadn't hurried making that title screen, lol.    Feel free to use any images I make with your program in any way you want.  Here's one more.  That's all now, I think.  My wife says I'm wasting too much time doodling...

- Dav

  [ This attachment cannot be displayed inline in 'Print Page' view ]  


Title: Re: Paint Pixels 8 With Right-Click Menu
Post by: SierraKen on July 05, 2020, 10:43:38 pm
Cool. :) Well that Title screen is waaaay better than anything I could have made. :) I just copy/pasted the _TITLE bar out of it and saved it as Title.png :).