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.

Newcomers AppGameKit Corner / Anyone got examples with this command - CreateImageColor( imageID, red, green, blue, alpha )

Author
Message
SpecTre
Developer
16
Years of Service
User Offline
Joined: 24th Feb 2003
Location: UK
Posted: 16th Jan 2015 18:25
Hi all,

I have been looking at the CreateImageColor command and there doesn't seem to be much in the line of documentation about it.
If you have seen one of my previous posts I am in the process of making a colouring book style game which will be using a flood fill method I have started.
In DBPro there is a command called - point ( x, y ) this will draw a single pixel to the screen using any colour you decide.

The docs for AppGameKit say the CreateImageColor command creates an image 1 x 1 pixel of your chosen colour to use to fill in sprites etc re textures.

I was wondering if this could be used somehow to colour the screen, either the back buffer or a render image?

Any ideas?

Thanks

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
Pharoseer
12
Years of Service
User Offline
Joined: 21st Feb 2007
Location: Right behind you
Posted: 19th Jan 2015 04:53 Edited at: 19th Jan 2015 04:57
I agree that the documentation is lacking (simple examples showcasing usage would be great), but the name is fairly intuitive. These are the two ways you can call the function:



The imageID referenced in the first variant and the integer returned by the function in the second variant are the number you would use when referencing the image in various function calls (to create a sprite from it, draw it, etc.).

What you may be looking for are the drawing commands. These are a bit limited it seems and dot(x, y) doesn't seem to exist at the moment. However, you could utilize the DrawLine() function. If you look in the documentation it is located under the Commands -> Core section.

The function looks like the following:



To draw a single pixel, I had to call it like so:



This would imply that I'm trying to draw 2 pixels (x, y) and (x+1, y+1), but that doesn't seem to be the case. In my experiments yesterday it seemed that the function wouldn't draw anything unless I added at least one to either x or y. I also noticed some black lines at the edges of my generated textures unless I chose to add one to both x and y. Since I want only one color I pass that as both color arguments and I have a single dot.

If you want to clear the screen to a solid color you would probably want the SetClearColor() function along with EnableClearColor(). The functions look like the following:



and you would call them like so:



However, if you're trying to fill in a render image instead you would need to first create the image with CreateRenderImage() and then use the DrawBox() command to draw it in the color(s) that you want. Here's an example of that:



Hopefully I answered this in a way that helps. If you need clarification of anything let me know. I just got AppGameKit yesterday, but spent a lot of time with DB Classic and DBPro a few years ago so learning this is going pretty quickly.

[Edit] Just as a heads up I've noticed some odd behavior with this when trying to animate textures. I'm probably missing something, but SetRenderToScreen() seems to not properly switch back to the screen until the second Sync() call.
SpecTre
Developer
16
Years of Service
User Offline
Joined: 24th Feb 2003
Location: UK
Posted: 19th Jan 2015 11:37
Hi,

Thanks for the reply.
I have already seen the draw line and box commands however they are quite slow and the fill has a delay when the same routine in DBPro is instant using the point and lock pixel commands.
See code for what I have so far:



This is why I was looking at the CreateImageColor command as it creates a 1x1 pixel image of any colour and the docs sort of imply from what I can see that it can be used to texture a sprite etc?

I understand how to use the command to create the 1x1 pixel image but then how would you utilise this to fill or texture a sprite or screen?
The docs only show you how to make the image.

Do you have to create a sprite from the 1x1 pixel image and paste it as a dot on the screen??

Any ideas?

Thanks in advance.

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
BatVink
Moderator
16
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 19th Jan 2015 12:47
You already have your image in a memblock. I haven't done this in AppGameKit, but my DBPro experience tells me it will be quicker for you to do your pixel editing in the memblock, and then create an image from it. I think it's the only way to get around the issue of not having the LOCKPIXELS command.

Quidquid latine dictum sit, altum sonatur
SpecTre
Developer
16
Years of Service
User Offline
Joined: 24th Feb 2003
Location: UK
Posted: 19th Jan 2015 14:08
Hey BatVink,

never thought of that

I will have a look at that later when I get on the computer, opens up quite a few possibilities.
Just shows how good these forums are, you get stuck and blinkered into a way of trying to solve a problem and then someone on here sparks an idea in your head and on to the next problem lol

I guess when I have had a look I will be updating with the next problem haha.

Will update later when I have had a look at the problem to see if this works.


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
BatVink
Moderator
16
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 19th Jan 2015 14:41
Here's 2 tutorials I wrote back in 2005 for DBPro, on using memblocks to manipulate images. It won't teach you anything new, but there might be a couple of shortcuts in there for you.

http://www.thegamecreators.com/pages/newsletters/newsletter_issue_32.html#9

http://www.thegamecreators.com/pages/newsletters/newsletter_issue_33.html#12

Quidquid latine dictum sit, altum sonatur
SpecTre
Developer
16
Years of Service
User Offline
Joined: 24th Feb 2003
Location: UK
Posted: 19th Jan 2015 16:23
Cheers for that, will check them out later

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
16
Years of Service
User Offline
Joined: 24th Feb 2003
Location: UK
Posted: 19th Jan 2015 17:58


BatVink,

well cheers for the pointer in the right direction, just had a quick mess with it, code is scruffy so not showing yet but wanted to check theory and I am glad to say it works 100% and is super fast!!!

Cheers again and once more shows how friendly and helpful the TGC community is!

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
16
Years of Service
User Offline
Joined: 24th Feb 2003
Location: UK
Posted: 19th Jan 2015 18:26
Here's the test code working, although still scruffy, not quite as before but just in case anyone wants to have a look and try it.
Put the PIC4.png saved on this post in the media folder.

Check out this post:
http://forum.thegamecreators.com/?m=forum_view&t=213305&b=48
for future updates and a tutorial explaining the code soon.



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
16
Years of Service
User Offline
Joined: 24th Feb 2003
Location: UK
Posted: 19th Jan 2015 21:59
Here is a working update using the pointer and random colours to fill areas in.
Check the WIP post in showcase for further updates and tutorials.

Thanks again BatVink for the idea.



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
BatVink
Moderator
16
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 20th Jan 2015 13:12
Glad you got it working, and so quickly

Quidquid latine dictum sit, altum sonatur
SpecTre
Developer
16
Years of Service
User Offline
Joined: 24th Feb 2003
Location: UK
Posted: 29th Jan 2015 22:21
Well I finally had use for this command, CreateImageColor which was the reason why I opened this post, however I did not use it for the reason I opened the post.


I created an image using the CreateImageColor which was 1x1 pixel and used it as a Sprite which was invisible in order to detect buttons being pressed with the pointer.

So there you go

If you want to see the code working with it check:

http://forum.thegamecreators.com/?m=forum_view&t=213305&b=48

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: 2019-08-25 23:31:41
Your offset time is: 2019-08-25 23:31:41