Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Problem with memBlock

Author
Message
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 26th Feb 2015 11:30
Here we go: PaintBook version 2.1

You can now do colouring or jigsaws! To make a jigsaw, first select the shapes picture, then a real picture, then press Scan. Instead of blank sprite images you now have chopped up jigsaw pieces. The real picture is saved into the zip as well, called picture.png. This keeps your code the same for all "levels". It occured to me that when the picture is complete you can go "Tada!" and load the picture without the cracks.

Examples following...

Onwards and sometimes upwards

Attachments

Login to view attachments
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 26th Feb 2015 11:31
One piece of jigsaw attached. Me glugging vino on Corfu!

Onwards and sometimes upwards

Attachments

Login to view attachments
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 26th Feb 2015 11:35
Example output attached:

Next time round I'll add some intelligent analysis of what colours are NOT used in the image, and make the transparent colour one of those. Full black may well cause nasty artifacts.

Onwards and sometimes upwards

Attachments

Login to view attachments
SpecTre
Developer
21
Years of Service
User Offline
Joined: 24th Feb 2003
Location: UK
Posted: 26th Feb 2015 14:35
You managed that quick, wasn't expecting anything for a while
From the image it looks like it works great, will have a mess with it when get back from work
Fantastic and good it is in one package/tool.
Ideas swimming around my head now for the next project

Programming - AMOS on the AMIGA! / DBPro / Python / A bit of C C++ / now also AGK2! - Graphics - Deluxe Paint on the Amiga / Paintshop Pro / Photoshop / Lightroom / Grafx2
Previously worked for Prisma Software producing childrens educational software on the Amiga - Titles - Pepe's Garden - Paint Pot / Kids Academy range - Paint Pot II / Shopping Basket / Which Where What? / Blobs / Alvin's Puzzles
SpecTre
Developer
21
Years of Service
User Offline
Joined: 24th Feb 2003
Location: UK
Posted: 26th Feb 2015 15:06
Good point about the transparent colour, I didn't think about that.
How about a simpler method which would be very useful of when clicking the button to scan, a box appears asking for the RGB value of the transparent colour you want to use. The program could then use this as the checking colour when reaching the line.

Eg,

SCAN, then enter RGB, box where 3 values can be entered

[0][0][0]
[255][0][255]

this would make it much more flexible as I could then change the colour of the lines to suite, eg jigsaw black and white or purple and white etc.

Two boxs could be used for this, one for the transparent colour and one for the white fill colour instead of reading the top left pixel.

EG:

SCAN
Enter transparent colour : [0][0][0]
Enter fill colour : [255][255][255]

This would open the program up considerably with a minor change.

What do you think?

Programming - AMOS on the AMIGA! / DBPro / Python / A bit of C C++ / now also AGK2! - Graphics - Deluxe Paint on the Amiga / Paintshop Pro / Photoshop / Lightroom / Grafx2
Previously worked for Prisma Software producing childrens educational software on the Amiga - Titles - Pepe's Garden - Paint Pot / Kids Academy range - Paint Pot II / Shopping Basket / Which Where What? / Blobs / Alvin's Puzzles
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 26th Feb 2015 15:38 Edited at: 26th Feb 2015 15:45
The transparent colour is only a problem for a real picture. The mask is generated for the segment-slicer automatically. It's probably better if the program scans all the pixels in the real image and ensures it's using one that's not there. It's sometime hard to spot transparent pixels in an image!

It didn't take long because Delphi is great for doing things like this, and all I had to do was another bitmap and blit the real picture into, then select either to use white (no jigsaw) or the matching pixel from the "real" image into the output bitmap.

You could get a nice effect when the puzzle's complete by loading the "real" picture as a background, then reduce the opacity. That could be pretty, since you have faint but data-rich jigsaw edges.

Onwards and sometimes upwards
SpecTre
Developer
21
Years of Service
User Offline
Joined: 24th Feb 2003
Location: UK
Posted: 26th Feb 2015 15:41
Quote: "It's sometime hard to spot transparent pixels in an image!"


Hmm that's right, it took me a while to find the pixel in the dog picture thinking about it lol

Programming - AMOS on the AMIGA! / DBPro / Python / A bit of C C++ / now also AGK2! - Graphics - Deluxe Paint on the Amiga / Paintshop Pro / Photoshop / Lightroom / Grafx2
Previously worked for Prisma Software producing childrens educational software on the Amiga - Titles - Pepe's Garden - Paint Pot / Kids Academy range - Paint Pot II / Shopping Basket / Which Where What? / Blobs / Alvin's Puzzles
SpecTre
Developer
21
Years of Service
User Offline
Joined: 24th Feb 2003
Location: UK
Posted: 26th Feb 2015 18:37
Right I am home and have just downloaded, not done any test's yet but can see from the ZIP that you have got everything sorted with whats saved in the folder.

Superb!! and a virtual glass of wine

I take it that the program will accept any black and white jigsaw image with any thickness of lines whether it be the one tested or 1 pixel?

Great work

Programming - AMOS on the AMIGA! / DBPro / Python / A bit of C C++ / now also AGK2! - Graphics - Deluxe Paint on the Amiga / Paintshop Pro / Photoshop / Lightroom / Grafx2
Previously worked for Prisma Software producing childrens educational software on the Amiga - Titles - Pepe's Garden - Paint Pot / Kids Academy range - Paint Pot II / Shopping Basket / Which Where What? / Blobs / Alvin's Puzzles
SpecTre
Developer
21
Years of Service
User Offline
Joined: 24th Feb 2003
Location: UK
Posted: 26th Feb 2015 20:00
Jim, well it works great!

Have a look at the example zip, I have added a couple of files to show you what I did to the zip.

Created a new picture for the jigsaw pieces instead of thick lines.

Downloaded picture as texture from internet to test.

This test texture picture though I loaded into Photoshop and created on another layer the jigsaw template. I then created the 3D shading effect directly on the texture picture using the jigsaw template as a guide. I then saved the test texture picture with the shading and used this as the picture to put into the PaintBook program.

When I put this through the PaintBook program the pieces it produces now look 3D Fantastic and works perfectly!

I see what you mean with regards to the transparent colour though because you wouldn't know if any of the pixels are transparent or not.

Picture to follow with result of pieces put together

Programming - AMOS on the AMIGA! / DBPro / Python / A bit of C C++ / now also AGK2! - Graphics - Deluxe Paint on the Amiga / Paintshop Pro / Photoshop / Lightroom / Grafx2
Previously worked for Prisma Software producing childrens educational software on the Amiga - Titles - Pepe's Garden - Paint Pot / Kids Academy range - Paint Pot II / Shopping Basket / Which Where What? / Blobs / Alvin's Puzzles

Attachments

Login to view attachments
SpecTre
Developer
21
Years of Service
User Offline
Joined: 24th Feb 2003
Location: UK
Posted: 26th Feb 2015 20:04 Edited at: 26th Feb 2015 20:04
This is the result of the pieces put together

You could actually use this method to produce the original colour book pieces with the anti-aliasing effect around the edges or to give the pieces a 3D effect too.

Will be experimenting further

Top marks Jim, Great!! I think as you said with the testing of the image for transparent this would be perfect!!!



Programming - AMOS on the AMIGA! / DBPro / Python / A bit of C C++ / now also AGK2! - Graphics - Deluxe Paint on the Amiga / Paintshop Pro / Photoshop / Lightroom / Grafx2
Previously worked for Prisma Software producing childrens educational software on the Amiga - Titles - Pepe's Garden - Paint Pot / Kids Academy range - Paint Pot II / Shopping Basket / Which Where What? / Blobs / Alvin's Puzzles

Attachments

Login to view attachments
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 26th Feb 2015 20:52
Just had a rib-eye steak with saute potatoes and curly kale. Took on a bit of fuel, then will add automatic transparency.

The picture looks really great!Glad this little tool is helping.

More later...

Onwards and sometimes upwards
SpecTre
Developer
21
Years of Service
User Offline
Joined: 24th Feb 2003
Location: UK
Posted: 26th Feb 2015 20:58
Quote: "More later..."


Cheers Jim, could do some great things with this because it only took me half an hour with the other picture 3D jigsaw effect, so great things to come with this I think!!!

Quote: "Just had a rib-eye steak with saute potatoes and curly kale."


Just got hungry

Programming - AMOS on the AMIGA! / DBPro / Python / A bit of C C++ / now also AGK2! - Graphics - Deluxe Paint on the Amiga / Paintshop Pro / Photoshop / Lightroom / Grafx2
Previously worked for Prisma Software producing childrens educational software on the Amiga - Titles - Pepe's Garden - Paint Pot / Kids Academy range - Paint Pot II / Shopping Basket / Which Where What? / Blobs / Alvin's Puzzles
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 26th Feb 2015 22:38
Here is V2.2

This now has automatic colour scanning of a jigsaw picture. It's a brute-force algorithm: make an array of [0..0xFFFFFF) booleans. Set them all to false. Scan the pixels in the image and get their colour. Masking out any alpha bits, make the colour array entry for this colour true.

Starting with zero, scan the array and return a result when you hit a false value. Use that value for the transparent colour.

The default transparent colour when you are not using jigsaws by painting is full red.

Interestingly, scanning the picture of me glugging some nice Corfiot wine revealed that it did indeed have pixels that were black or near black. The first available colour was 3 - which equates to very dark red.

Reading the canvas.pixels[x,y] value is fairly fast. Writing is slow. But to scan the colours there's no need to write, so I'd class this simple algorithm as NWO (Not Worth Optimising).



Enjoy! I've just poured a glass of vino, unfortunately not in Greece until late June.

Onwards and sometimes upwards

Attachments

Login to view attachments
SpecTre
Developer
21
Years of Service
User Offline
Joined: 24th Feb 2003
Location: UK
Posted: 27th Feb 2015 00:45
Well Jim,

I have plenty to go on here Will test this later, just poured a glass myself and watching an episode of Homeland on Netflix

This program is really good and I have thought of at least 5 APP's to use it on so far!
Going to release the colouring book soon so keep an eye out for that!

Printed this bit of code out with the other you posted and will be looking through it all, picking up a lot of tips to follow through into my code, cheers again

Will update when go through this version later.

Going to start to learn Pascal when I can too, got a book on the internet to look through.

Hey forgot to say I was in Hull a few weeks ago as my daughter has got an offer at Hull University. Very impressed there and she likes it better than the other 3 universities around the country we looked at. Very friendly. Took my lad along too, he is not old enough yet as he is 15 but we had a look around the computer department and he has not shut up about programming since

Programming - AMOS on the AMIGA! / DBPro / Python / A bit of C C++ / now also AGK2! - Graphics - Deluxe Paint on the Amiga / Paintshop Pro / Photoshop / Lightroom / Grafx2
Previously worked for Prisma Software producing childrens educational software on the Amiga - Titles - Pepe's Garden - Paint Pot / Kids Academy range - Paint Pot II / Shopping Basket / Which Where What? / Blobs / Alvin's Puzzles
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 27th Feb 2015 10:57
Unfortunately, we've stopped development of AppGameKit for Pascal for the foreseeable future. Reasons are explained in the Pascal conference on here. Also unfortunately, Delphi is very expensive: for a new user about £1,500 with the mobile add-on pack.

Hull scores consistently high on the student satisfaction ranks. It's a relatively cheap place to live, has a lively music and cafe scene etc. I'm a part-time lecturer at the uni. So if your daughter comes here, she'll be welcome for Sunday lunch from time to time, and any help she needs whilst finding her feet. We live about 5 minutes by bus from the campus.

Onwards and sometimes upwards
SpecTre
Developer
21
Years of Service
User Offline
Joined: 24th Feb 2003
Location: UK
Posted: 27th Feb 2015 11:18 Edited at: 27th Feb 2015 11:20
Quote: "I'm a part-time lecturer at the uni."


Its a small world!
Like I said we were very impressed with Hull and the university.

Quote: "she'll be welcome for Sunday lunch from time to time, and any help she needs whilst finding her feet."


Better not tell her that, you won't be able to get rid of her lol.

Quote: "Unfortunately, we've stopped development of AppGameKit for Pascal for the foreseeable future. Reasons are explained in the Pascal conference on here. Also unfortunately, Delphi is very expensive: for a new user about £1,500 with the mobile add-on pack."


Yes saw the other post and completely agree with you decision. Still going to have a look with the free version as always good to try new things


Paintbook tool working exceptionally well! Cheers.

Programming - AMOS on the AMIGA! / DBPro / Python / A bit of C C++ / now also AGK2! - Graphics - Deluxe Paint on the Amiga / Paintshop Pro / Photoshop / Lightroom / Grafx2
Previously worked for Prisma Software producing childrens educational software on the Amiga - Titles - Pepe's Garden - Paint Pot / Kids Academy range - Paint Pot II / Shopping Basket / Which Where What? / Blobs / Alvin's Puzzles
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 27th Feb 2015 12:04 Edited at: 27th Feb 2015 12:06
The fun and good stuff in programming is, in my view, algorithms. It's like doing crossword puzzles. I'd be interested to see if anybody can come up with a more efficient algorithm for finding unused colours in an image.

The problem is that from the first to the last pixel in an image there is an arbitrary colour value. You can't use maxima and minima because the value which not used will probably fall with these bounds, unless you're lucky. But we can't afford to rely upon luck. A boolean value in Delphi occupies 1 byte. Our array is therefore 16.7 million bytes, because a range from zero to 0xFFFFFFF.

What if every colour was used - unlikely but possible. What should we do then? Perhaps do a new scan with an array of integers rather than booleans, and when hit a colour we increase the colour count. Finally, we choose the least used colour. This method used 4x the memory of the first.

For the original we could use Pascal's extraordinarily powerful SETs. The range of set is 0..255. But by creating a large set type would could reduce the memory cost by a factor of eight, at the cost of some processor time - a TLargeSet would be an array of sets such that you can divide the largest number you want in the set inclusion by 256 and have that many elements in the array. Using that technique would reduce the memory cost by eight. So to include an index in the set the operator TBigSet.include(number) becomes:

Procedure TBigSet.Inlude(number: integer);
begin
if (number> fMaximum) or (number<0) then exit;
include(fsetArray[number div 256], number mod 256);
end;

We could use a tree method. For smaller cases that might work. But for large numbers of colours, the tree size might be larger than the memory cost and simplicity of an array.

Off you go!

Onwards and sometimes upwards
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 27th Feb 2015 12:09
Paul, what's your daughter going to read at university?

Onwards and sometimes upwards
SpecTre
Developer
21
Years of Service
User Offline
Joined: 24th Feb 2003
Location: UK
Posted: 27th Feb 2015 12:49
Quote: "Perhaps do a new scan with an array of integers rather than booleans, and when hit a colour we increase the colour count. Finally, we choose the least used colour. This method used 4x the memory of the first."


This would have been the way I would have looked at it and in AppGameKit using a memblock to read the integer colour values.

Shes doing biology, shes like a mad professor with all the biology and chemistry homework she has lol.

Programming - AMOS on the AMIGA! / DBPro / Python / A bit of C C++ / now also AGK2! - Graphics - Deluxe Paint on the Amiga / Paintshop Pro / Photoshop / Lightroom / Grafx2
Previously worked for Prisma Software producing childrens educational software on the Amiga - Titles - Pepe's Garden - Paint Pot / Kids Academy range - Paint Pot II / Shopping Basket / Which Where What? / Blobs / Alvin's Puzzles
SpecTre
Developer
21
Years of Service
User Offline
Joined: 24th Feb 2003
Location: UK
Posted: 27th Feb 2015 14:32
Just released the free Lite version of Paint Pot, the colouring book on the Google Play store to see if it gets a bit of interest and then will update once fiinished a load of pictures for the full version

You are mentioned in the, with thanks area.

Programming - AMOS on the AMIGA! / DBPro / Python / A bit of C C++ / now also AGK2! - Graphics - Deluxe Paint on the Amiga / Paintshop Pro / Photoshop / Lightroom / Grafx2
Previously worked for Prisma Software producing childrens educational software on the Amiga - Titles - Pepe's Garden - Paint Pot / Kids Academy range - Paint Pot II / Shopping Basket / Which Where What? / Blobs / Alvin's Puzzles
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 27th Feb 2015 18:02
Well done! I'll look later...

Onwards and sometimes upwards
SpecTre
Developer
21
Years of Service
User Offline
Joined: 24th Feb 2003
Location: UK
Posted: 27th Feb 2015 18:18
Link here

https://play.google.com/store/apps/details?id=com.leap.paintpotlite_app

Programming - AMOS on the AMIGA! / DBPro / Python / A bit of C C++ / now also AGK2! - Graphics - Deluxe Paint on the Amiga / Paintshop Pro / Photoshop / Lightroom / Grafx2
Previously worked for Prisma Software producing childrens educational software on the Amiga - Titles - Pepe's Garden - Paint Pot / Kids Academy range - Paint Pot II / Shopping Basket / Which Where What? / Blobs / Alvin's Puzzles

Login to post a reply

Server time is: 2024-11-25 20:42:06
Your offset time is: 2024-11-25 20:42:06