Author Topic: Paint Pixels 8 With Right-Click Menu  (Read 4821 times)

0 Members and 1 Guest are viewing this topic.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Paint Pixels 8 With Right-Click Menu
« Reply #30 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.

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: Paint Pixels 8 With Right-Click Menu
« Reply #31 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
« Last Edit: July 04, 2020, 01:27:17 pm by Dav »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Paint Pixels 8 With Right-Click Menu
« Reply #32 on: July 04, 2020, 01:30:21 pm »
Quote
which I admit kind of makes it even more fun.

LOL comedy too!

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Paint Pixels 8 With Right-Click Menu
« Reply #33 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.

Memory Problem with Paint Pixels.jpg
* Memory Problem with Paint Pixels.jpg (Filesize: 462.27 KB, Dimensions: 1481x797, Views: 249)
« Last Edit: July 04, 2020, 05:25:29 pm by SierraKen »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Paint Pixels 8 With Right-Click Menu
« Reply #34 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.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Paint Pixels 8 With Right-Click Menu
« Reply #35 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.
« Last Edit: July 04, 2020, 05:33:19 pm by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: Paint Pixels 8 With Right-Click Menu
« Reply #36 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. ....

« Last Edit: July 04, 2020, 07:19:55 pm by Dav »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Paint Pixels 8 With Right-Click Menu
« Reply #37 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.

Shadow Test.jpg
* Shadow Test.jpg (Filesize: 114.96 KB, Dimensions: 1024x768, Views: 224)
Memory Fix with Paint Pixels.jpg
* Memory Fix with Paint Pixels.jpg (Filesize: 229.66 KB, Dimensions: 1475x625, Views: 234)
« Last Edit: July 04, 2020, 10:54:30 pm by SierraKen »

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: Paint Pixels 8 With Right-Click Menu
« Reply #38 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

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Paint Pixels 8 With Right-Click Menu
« Reply #39 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. :)

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: Paint Pixels 8 With Right-Click Menu
« Reply #40 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

 
pp8.jpg


Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Paint Pixels 8 With Right-Click Menu
« Reply #41 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.





* Paint Pixels 8.zip (Filesize: 331.77 KB, Downloads: 154)

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: Paint Pixels 8 With Right-Click Menu
« Reply #42 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

 
web2.jpg




Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Paint Pixels 8 With Right-Click Menu
« Reply #43 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

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Paint Pixels 8 With Right-Click Menu
« Reply #44 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!!!
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!