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.

Code Snippets / [DBP] Memblock Image Manipulation Library

Author
Message
Syncaidius
19
Years of Service
User Offline
Joined: 22nd Mar 2005
Location: United Kingdom
Posted: 30th Jun 2010 20:43 Edited at: 1st Sep 2010 14:17
I spent some time figuring out memblocks for image editing a while ago and came up with some pretty cool stuff.

I've started working on a library of code that allows you to create and edit DBP images/textures through the use of memblocks, without actually having to understand memblocks to use it. This hasn't been tested in DBC yet, only DBP.

Library Code:


So far the library can do the following on a memblock texture:
Create an empty texture filled with the given colour
Draw circle
Draw lines
Flip images
Tint and Greyscale
Edit single pixels (aka draw dots)
Draw circle outlines (and the thickness can be adjusted)
Draw part-circles and part-circle outlines (e.g. a 90 degree piece of a circle or whatever)
copy a DBP or memblock image and paste it into another image
copy part of one image into another image

This is still a work in progress and I still have a lot of things I want to add to it before I can say its complete. A few of these things are:
Image Resizing
Drawing polygons onto a texture (e.g. a hexagon, octogon or other random shape)
Drawing triangles
Gradient boxes, rectangles, triangles, circles and lines
Texture rotation
Text on textures

I've included four examples of what the library can do so far. You don't need any external plugins to use the code.

Here is a few screenshots for those who like pretty pictures:






You are free to use the code as you wish, whether that be for personal or commercial use.

Attachments

Login to view attachments
Syncaidius
19
Years of Service
User Offline
Joined: 22nd Mar 2005
Location: United Kingdom
Posted: 1st Aug 2010 20:50
If there is any interest in this, I might add a few more things soon.

Devonps
15
Years of Service
User Offline
Joined: 5th Nov 2009
Location: Nottingham
Posted: 3rd Aug 2010 15:05
This seems a really good idea, keep up the good work.

Marriage is a circle of rings....
Engagement ring, Wedding ring, Suffering!
gwheycs62egydws
15
Years of Service
User Offline
Joined: 17th Aug 2009
Location: The World
Posted: 22nd Aug 2010 16:50 Edited at: 22nd Aug 2010 17:08
hi the following command dose not seem to exist

d3d_rgba

I've got version 7.4 of DBP with other tweaks added to it

can you please provide me the missing command

I know it should look something like this

function d3d_rgba(a,b,c,d)

endfunction

but as for the inner workings the 4th in the list I would
not know

Resourceful@shaw.ca

If a thought is Just a thought ~ so whats the main thought ?
Guido Italy
18
Years of Service
User Offline
Joined: 25th Dec 2005
Location:
Posted: 22nd Aug 2010 18:26
Crate/Drawing splines into texture ?

Is possible ??
Syncaidius
19
Years of Service
User Offline
Joined: 22nd Mar 2005
Location: United Kingdom
Posted: 23rd Aug 2010 22:29 Edited at: 23rd Aug 2010 22:38
I've made a few changes to the library:


The updated code and attached examples are in the original post.

@Resourceful:
Your problem should be fixed with the new updated version. I forgot that D3D_RGBA is from cloggy's Direct3D plugin. I've added IMG_RGBA which does exactly the same as D3D_RGBA, but won't need the plugin to use.

@Guido Italy:
Drawing splines might be possible, but I've never looked into that sort of think with memblocks/images, so I have no idea how that would be done. I might have a shot at it in the near future.

gwheycs62egydws
15
Years of Service
User Offline
Joined: 17th Aug 2009
Location: The World
Posted: 23rd Aug 2010 22:39 Edited at: 23rd Aug 2010 22:59
perfect


thanks ;o)


umm Example - Flips Outlines and Tints
it dose not work because It dose not understand line 27

how about the link to "cloggy's Direct3D plugin" please ? ;o)

Resourceful@shaw.ca

If a thought is Just a thought ~ so whats the main thought ?
Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 24th Aug 2010 05:43
http://www.dbdepot.co.uk/

supa fast line commands because it calls directx functions directly. Also support for 3d dots, lines, and some other stuff, but i mainly use it for the line function.


Is't life, I ask, is't even prudence, to bore thyself and bore thy students?
Syncaidius
19
Years of Service
User Offline
Joined: 22nd Mar 2005
Location: United Kingdom
Posted: 24th Aug 2010 12:53 Edited at: 24th Aug 2010 12:54
@Resourceful:
Heh, No wonder, IMG_DRAW_RECTANGLE_OUTLINE was actually called IMAGE_DRAW_RECTANGLE_OUTLINE in the library. Fixed now (and updated).

@Neuro Fuzzy:
Not so fast for drawing directly to a texture. But yeah, It does have extremely fast 2D and 3D line drawing.

gwheycs62egydws
15
Years of Service
User Offline
Joined: 17th Aug 2009
Location: The World
Posted: 24th Aug 2010 20:14
well we got a bit ferther

new error with Example - Flips Outlines and Tints
runtime error 5101 - memblock rang is illegal at line 231

cloggy's Direct3D defiantly give me some idea's
I can't remember exactly but I had found code some ware else
in the forums that tuned text into 3d

but Cloggy's gives even more option , even anther twist to
the idea for the 3d menu

I'm on my 5th dvd of code that I have found for Dark Basic Pro

so much info and trying to find a way to put it all together

Resourceful@shaw.ca

If a thought is Just a thought ~ so whats the main thought ?
Syncaidius
19
Years of Service
User Offline
Joined: 22nd Mar 2005
Location: United Kingdom
Posted: 24th Aug 2010 21:20
That'll teach me to test before posting updated code heh. Fixed the typo that caused that, and I tested it so it definitly works this time. Sorry about that.

As for Cloggy's Plugin, if its 3D menu kind of stuff your after, his plugin is pretty much made for it.

gwheycs62egydws
15
Years of Service
User Offline
Joined: 17th Aug 2009
Location: The World
Posted: 24th Aug 2010 23:27 Edited at: 24th Aug 2010 23:35
hick up happens that's why it's called coding
something has to give up the ghost some ware lol

I know once I start to understand more
I will encounter many bugs to be worked out and it will be the
one tiny mistype or incorrect work that will throw some thing off

you try your best and it go's as it go's

so I take it you re uploaded ?

if it's just some thing tiny then just show the fix here ;o)

ok I see you uploaded a fixed version
works fine ;o)

Resourceful@shaw.ca

If a thought is Just a thought ~ so whats the main thought ?
Frank C
14
Years of Service
User Offline
Joined: 3rd Jul 2010
Location: Houston TX
Posted: 27th Aug 2010 22:31 Edited at: 27th Aug 2010 22:32
I'm using some code that Phaelax wrote to read TST files and pull out the individual tiles, I am trying to take some of these individual tile images and write them back and save to a single image file for use. Below is a snippet of what I tried to do, it makes a blank image of the correct size, was thinking of trying to use your Library instead but cannot fathom which functions will do this correctly. Any suggestions would be appreciated.

[EDIT} Here's link to Phaelax's code: http://forum.thegamecreators.com/?m=forum_view&t=173334&b=4

Syncaidius
19
Years of Service
User Offline
Joined: 22nd Mar 2005
Location: United Kingdom
Posted: 28th Aug 2010 00:00 Edited at: 28th Aug 2010 00:23
I knocked this up for you a few minutes ago, hope it helps:



I used a 16x16 tile image from my own tileset just to test it saves the created tileset out properly. I've also included another function for extracting tiles back out of a saved tileset image, just in case.

gwheycs62egydws
15
Years of Service
User Offline
Joined: 17th Aug 2009
Location: The World
Posted: 28th Aug 2010 09:44
hi

ya it works one you make a .dbpro file and tell it to
attach the MemblockImageLibrary.dba

the only thing that would have been nice is the testtile.png

I used test image.png

it sort of work

I added some color lines to the example and the save file
was completely black

I used PSP 2x to adds the lines

Resourceful@shaw.ca

If a thought is Just a thought ~ so whats the main thought ?

Attachments

Login to view attachments
gwheycs62egydws
15
Years of Service
User Offline
Joined: 17th Aug 2009
Location: The World
Posted: 28th Aug 2010 10:00
umm never mind it seemed to correct it's self more or less

Resourceful@shaw.ca

If a thought is Just a thought ~ so whats the main thought ?

Attachments

Login to view attachments
Frank C
14
Years of Service
User Offline
Joined: 3rd Jul 2010
Location: Houston TX
Posted: 30th Aug 2010 18:42
Thanks Syncaidius I will try this with some of the TST files I got from RPGToolkit site, this will greatly help me with my maps.
Dared1111
18
Years of Service
User Offline
Joined: 25th Oct 2006
Location:
Posted: 2nd Sep 2010 13:07
I am curious if with memblocks, or otherwise it is possible to take a greyscale image (representative of a glow) and add colours to it, in order to generate many colour glows with only one source.

Signature? There is no signature!
Quel
15
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 30th Sep 2010 09:13
Any chance you add a blur function? I've been experimenting with it, and on paper it seems so easy, but just won't work in action.
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 30th Sep 2010 23:35 Edited at: 30th Sep 2010 23:35
Hi Quel,

Here's some code for gaussian and average blur (box blur). The code is split in a horizontal and a vertical pass as an optimization, and the average blur also "moves" along with the iteration instead of calculating the kernel for each pixel as an optimization.



Cheers!
Sven B

Login to post a reply

Server time is: 2024-11-24 13:15:32
Your offset time is: 2024-11-24 13:15:32