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.

Work in Progress / Image Kit - Manipulate your images in-game!

Author
Message
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 6th Oct 2009 20:54 Edited at: 9th Jul 2010 12:04
Hi everyone!

After a lot of research and coding, I'm happy to announce that Image Kit is finally in a state where it can be released for use.

Description
Image Kit is a plug-in that allows you to manipulate an image. It can access an image data without conversion to memblocks which makes it several times faster. There are a lot of applications for this plug-in. Below are some screen shots to give but a few.

Commands
A list of commands:



I did not include help files yet. I would like to wait until I'm sure the plug-in is stable and the commands will not be changed.

Examples
People like to see screen shots (at least I do), so I decided to make a few examples that make use of this plug-in.

Bullet hole example



An FPS example. You can shoot the plain that can be repositioned using space.
What does this plug-in add? You can see through the wall where you shot them by using some clever pasting and manipulating alpha. It does require some math to figure out the UV data though.

Fade out example



A very small example that shows a very easy fade-out effect for an image.
What does this plug-in add? You can directly manipulate the alpha channel. Also the blur effect was done by this plug-in.

Blend image example



Probably the first thing that even comes to mind when using an image manipulation plug-in. This example loads layer images and a mask image and transforms everything to a blended image.
What does this plug-in add? It then uses the red, green and blue channel of the mask image to manipulate the alpha channel of each layer. Then it pastes the layers directly to an image.

Note:
The example programs have been removed from the download. Of course it should still be possible to reproduce them, but since the plug-in is in a state where it could undergo significant changes, I have decided to wait until I start on the help files.

History
6/10/2009: v1.0 released
7/10/2009: v1.0b released (bug fix, did not work)
8/10/2009: v1.0c released (bug fix, to be tested)
25/10/2009: v1.01 released
2/11/2009: v1.01b released (bug fix)
14/11/2009: v1.02 released
14/12/2009: v1.03 released
20/01/2010: v1.10 released
14/05/2010: v1.10b released (added reset image kit)
23/05/2010: v1.11 released
8/06/2010: v1.20 released

Sven B
Please report any bugs.

Attachments

Login to view attachments
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 7th Oct 2009 00:15
Hmm Blend Image might work for my 10.000 planet problem. Thanks!

TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 7th Oct 2009 01:12
Will this work in DBC too?

TheComet


Make the paths of your enemies easier with WaypointPro!
Drew Cameron
20
Years of Service
User Offline
Joined: 30th Jan 2004
Location: Scotland
Posted: 7th Oct 2009 01:21
Looks great man - don't need it right now but I'm sure I can think of a reason in future!

QuothTheRaven
22
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: United States
Posted: 7th Oct 2009 06:42
Could you post a version with some compiled EXEs for quick viewing before I decide if I want to install it? That bullethole example looks quite interesting, makes me wonder how applicable it would be as a decal shader of some sort.

Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 7th Oct 2009 14:08
Great, will give this a try tonight.

It's a great idea for a plugin, there's so many things that will be possible, that were too slow for DBPro before.

Thanks for taking the time and effort to make this, now to put it to work!.


Health, Ammo, and bacon and eggs!
zzz
19
Years of Service
User Offline
Joined: 13th Nov 2005
Location: Sweden
Posted: 7th Oct 2009 16:26 Edited at: 7th Oct 2009 16:27
Wow, I should've had this when I was working on my Worms clone.

Alfa x
18
Years of Service
User Offline
Joined: 1st Jul 2006
Location: Colombia
Posted: 7th Oct 2009 17:03
Very Nice. Congrats.
Demon000
17
Years of Service
User Offline
Joined: 21st Aug 2007
Location:
Posted: 7th Oct 2009 17:59
I have a problem, I copied the Compiler and Editor folders, so the dll file is in the right place but when I try to run your examples I get this error: "Failed to load DLL (2:ImageKit.dll)"

This looks like a nice plug-in, nice work!
Booma
15
Years of Service
User Offline
Joined: 29th Mar 2009
Location:
Posted: 7th Oct 2009 19:43 Edited at: 8th Oct 2009 07:18
Sven B fantastic work!!! dbpro load images as IDirect3DTexture9 in MANAGED_POOL not in DEFAULT_POOL(may be i am wrong) so you can't use Device->UpdateRect... do you use IDirect3DSurface9::LockRect and after that per pixel copy surface to surface? And in your plugin you copy all surfaces or only 0?
Thank's for this work.
Dreamsenshi
15
Years of Service
User Offline
Joined: 4th Sep 2009
Location: USA
Posted: 7th Oct 2009 20:56
Cool! I also will try to squeeze in time to play with this a little later this week. =^--^=



Your error is my treasure. =^--^=
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 7th Oct 2009 22:53
Quote: "Will this work in DBC too?"


I'm afraid it won't. Sorry.

Quote: "Could you post a version with some compiled EXEs for quick viewing before I decide if I want to install it? That bullethole example looks quite interesting, makes me wonder how applicable it would be as a decal shader of some sort."


I attached the BulletHole example executable and media in this post.

Quote: "I have a problem, I copied the Compiler and Editor folders, so the dll file is in the right place but when I try to run your examples I get this error: "Failed to load DLL (2:ImageKit.dll)""


I think I know what went wrong. Could you please download again in the first post in a moment? I updated the DLL.
If it doesn't work, I know who I have to ask to make it work but it will take a little longer in that case.

Quote: "Van B, fantastic work!!! dbpro load images as IDirect3DTexture9 in MANAGED_POOL not in DEFAULT_POOL(may be i am wrong) so you can't use Device->UpdateRect... do you use IDirect3DSurface9::LockRect and after that per pixel copy surface to surface? And in your plugin you copy all surfaces or only 0?
Thank's for this work."


Go Van B! Our hero!
It's true, DBP doesn't load them in DEFAULT_POOL so I can't use the device to update the image (I tried it, just to make sure, but it doesn't work). So the only option I had was retrieving the data by locking the surface. Then using that pointer to edit every pixel individually. Of course I do use some tricks to optimize it for CPU processing, though it's probably far from fully optimized.
It's also a little more processing than just "copying" a pixel, but I guess you could see it that way.

Cheers!
Sven B

Attachments

Login to view attachments
Demon000
17
Years of Service
User Offline
Joined: 21st Aug 2007
Location:
Posted: 8th Oct 2009 00:50
Quote: "
I think I know what went wrong. Could you please download again in the first post in a moment? I updated the DLL.
If it doesn't work, I know who I have to ask to make it work but it will take a little longer in that case."


Downloaded again and still get the same error.
Todd Riggins
20
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 8th Oct 2009 04:51
Thanks Sven! This looks like it will be very useful.

QuothTheRaven
22
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: United States
Posted: 8th Oct 2009 07:20
Hmmm, when I run the EXE you attached nothing happens. I don't even get a window pop, just the loading cursor icon for a second or two then nothing. I'm on Windows 7 and I tried running it in compatibility mode as well but no luck. Anyone else get the EXE to work?

Todd Riggins
20
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 8th Oct 2009 09:12
The .exe worked for me... Vista 64-bit here.

Booma
15
Years of Service
User Offline
Joined: 29th Mar 2009
Location:
Posted: 8th Oct 2009 09:39
Sven B excuse me for my error, new members can't edit messages at once. I have seen the error but to correct it it is possible only in some hours(
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 8th Oct 2009 13:44
Wow Sven B This looks incredibly helpful, and the speed makes it all the better. Do you believe this plugin would work on camera images created using SET CAMER TO IMAGE?

<-- Spell based team dueling game!
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 8th Oct 2009 14:23
Don't work for me, but I'm thinking it's probably my install of DBPro that's confusing it.

Sixty, even if it can't get at a camera's render image, you could still make a new image and paste the camera image onto it, for modifying it afterwords. I'm thinking it may be an issue because you can't for example, make a memblock image out of a camera render, because the camera render image gets locked by the system. You can always paste the cameras image though.

If it is possible to adjust a camera render on the fly, then this plugin would be able to do so much - like adding interference to a camera render, and making it black and white before texturing it onto a screen. Or imagine you have a news channel logo, or whatever, you could paste that onto a camera render to give it a vibe, like a news program, music TV, volume bar, channel number display - you could really go to town if you wanted to.


Health, Ammo, and bacon and eggs!
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 8th Oct 2009 14:55 Edited at: 8th Oct 2009 15:34
Quote: "Hmmm, when I run the EXE you attached nothing happens. I don't even get a window pop, just the loading cursor icon for a second or two then nothing. I'm on Windows 7 and I tried running it in compatibility mode as well but no luck. Anyone else get the EXE to work?"


I have no idea why it would do that. I also asked around and I guess it can be a lot of things.

Quote: "Downloaded again and still get the same error."


I contacted THE Benjamin, who had the same problem before and fixed it. I hope it's fixed now after following his advise.
Because of the fix, it now has a pretty big size though. It's because it's still a debug version...

Quote: "Sven B excuse me for my error, new members can't edit messages at once. I have seen the error but to correct it it is possible only in some hours("


Don't worry about it. Our names do resemble each other a bit.

Quote: "Wow Sven B This looks incredibly helpful, and the speed makes it all the better. Do you believe this plugin would work on camera images created using SET CAMER TO IMAGE?"


It's not possible. It's a DBP thing... Right now the program will crash if you try it.

And thanks to everyone for your support. Having a compliment in your thread makes you want to continue developing.

Sven B

Demon000
17
Years of Service
User Offline
Joined: 21st Aug 2007
Location:
Posted: 8th Oct 2009 18:23
It works now
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 8th Oct 2009 19:45
Man this looks awesome. Make it for GDK!

"everyone forgets a semi-colon sometimes." - Phaelax
Blobby 101
18
Years of Service
User Offline
Joined: 17th Jun 2006
Location: England, UK
Posted: 8th Oct 2009 23:02
hey, looking pretty good so far, trying to make a worms game (inspired by zzz) and i'm trying to figure out soem of the commands - could you give an overview of what the parameters for the commands actually mean like the "Value" parameter of Set Image Channel is confusing me a bit
thank you.

Your signature has been erased by a mod because it's larger than 600x120
Valle
18
Years of Service
User Offline
Joined: 10th Mar 2006
Location: in your girlfriends bed
Posted: 8th Oct 2009 23:18 Edited at: 8th Oct 2009 23:30
wow, this looks f*in awesome! I always missed the Paste Image on Image command In most other languages it's common that you can draw on any surface

edit: btw, the best thing ever would be a 'paste sprite on image'-command (with scale and rotation, alpha etc.)


Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 8th Oct 2009 23:54 Edited at: 25th Oct 2009 12:14
Quote: "It works now"


Glad to hear

Quote: "hey, looking pretty good so far, trying to make a worms game (inspired by zzz) and i'm trying to figure out soem of the commands - could you give an overview of what the parameters for the commands actually mean like the "Value" parameter of Set Image Channel is confusing me a bit
thank you."


I'll give a quick overview of the less obvious parameters:
Set Blend Mode Blend Mode
Blend Mode is the mode used when using paste image on image. A list of the values can be found in Extra/ImageKitConstants.dba and start with BLEND_.

Set Blend Alpha Alpha Percentage
A float value from 0.0 to 100.0 that expresses the alpha used when pasting an image on an image. 0.0 being fully invisible, 100.0 being the image itself.

Blur Image Image Number, Radius, Iterations, Blur Mode
Radius is the radius of the blur.
Iterations is the number of times the blur is applied. I added this because when repeating an average blur, the result resembles more and more like a gaussian blur (it can be mathematically proven). It's to shorten the code when wanting that. Usually you'll put 1 though. This parameter was removed in v1.01
Blur Mode will determine the algorithm used for blurring. A list of values is in the ImageKitConstants.dba file. Average blur is the fastest. Gaussian IIR is good for large radius (radius-independent), FIR is good for small radius (radius-dependent).

Set Image Brightness Image Number, Red, Green, Blue[, Alpha]
The values are floats that express the brightness of each color comonent. 1.0 is the color itself, 0.5 will halve the color component, 2.0 will double it.

Desaturate Image Image Number, Desaturation Mode
A list of constants can be found in ImageKitConstants.dba.

Modify Image Saturation Image Number, Saturation Percentage
Saturation Percentage is a float value between 0.0 and 100.0. 0.0 is the image itself, 100.0 is a normal desaturation. A value of 50.0 will kind of half desaturate the image. It creates a more obscure version of the image (Perfect for horror games).

Set Image Channel Image Number, Channel, Value
Channel is supposed to be built by the constants starting with CHANNEL_ in ImageKitConstants.dba. You can combine channels by adding them together or using the bitwise OR operator (||).
If you want to set the value of the red and green for example, you should make this: CHANNEL_RED + CHANNEL_GREEN.
Value is the value the channel will receive ranging from 0 to 255. For example putting in 128 with the channel set as the above, you will set all the red and green color component values to 128. (So the color everywhere will be rgb(128, 128, Blue))

Set Image To Image Channel Image Number, Source Image Number, Channel
Will copy a channel from one image to another. Only works for images of the same size.

Copy Image Channel Image Number, Channel, Channel Source
Will copy one channel to another channel withing the same image. I advise you to use only one channel (not combining 2 channels) in the parameter Channel Source.
This is used to copy the red/green/blue components of the mask image in the BlendImage example to the alpha components. Afterwards we can easily copy that channel to another image.

Quote: "edit: btw, the best thing ever would be a 'paste sprite on image'-command (with scale and rotation, alpha etc.)"


I will see into that after I have optimized every command.

I'm currently recoding every command I have now to make it as fast as possible.

Sven B

Yodaman Jer
User Banned
Posted: 9th Oct 2009 17:05
AWESOME!!

I don't own DBPro, but when I do I will most definitely use this plug-in! I really like the look of the bullet-hole example.



-Yodaman Jer.

Demon000
17
Years of Service
User Offline
Joined: 21st Aug 2007
Location:
Posted: 10th Oct 2009 02:38 Edited at: 10th Oct 2009 03:11
@Sven B: Do you know any way to manipulate dtx1 .dds images?
I mean an image loaded in DBPro with that format and compression.
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 10th Oct 2009 10:28 Edited at: 10th Oct 2009 10:51
Quote: "@Sven B: Do you know any way to manipulate dtx1 .dds images?
I mean an image loaded in DBPro with that format and compression."


[edit] It seems to be only working with .bmp, .png and .jpg/jpeg files. When trying the commands with a .dds file, there are very strange results...
I'll look into it after I have optimized the commands.

Sven B

Alfa x
18
Years of Service
User Offline
Joined: 1st Jul 2006
Location: Colombia
Posted: 24th Oct 2009 02:29
Great Plug-in.
We are using it already in various of our projects.

Hope you extend it more.

Thank you so much.

AlfaX.
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 25th Oct 2009 12:07 Edited at: 25th Oct 2009 12:15
Update v1.01

Changes:
- Removed the parameter <Iterations> from BLUR IMAGE
- Optimized most of the filters and image editing commands
- Changed SUBSTRACT to SUBTRACT in ImageKitConstants.dba
Will upload in a moment.

[edit] Oh right, I also did a full benchmark of the plug-in.

@Alpha x,
I'm glad to hear it's already being used!

Sven B

Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 25th Oct 2009 13:52
sweeeeeeeet

The byte chrunchers are coming...
Todd Riggins
20
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 2nd Nov 2009 06:37 Edited at: 2nd Nov 2009 07:19
Hi, I finally got to test out the example code. The Image Blending example doesnt work for me correctly. The only images I see is the mask and grass images. Image is attached...

Attachments

Login to view attachments
Todd Riggins
20
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 2nd Nov 2009 06:46 Edited at: 2nd Nov 2009 07:21
Arg.. sry about the double post...

Here's another screenshot attached showing what happens when I remark out these lines:

Line 43:`copy image channel Mask, CHANNEL_ALPHA, CHANNEL_RED
Line 49:`copy image channel Mask, CHANNEL_ALPHA, CHANNEL_GREEN
Line 55:`copy image channel Mask, CHANNEL_ALPHA, CHANNEL_Blue

I'm using DBPro Version 74
Image Kit v1.01
DirectX - March 2009



Edit:
For me using the optional alpha parameter like this,
Set Image Brightness Image,1.0,0.0,0.0,0.0
Will make the Image disappear

The Red and Blue parameters seem to be backwards for me,
Set Image Brightness Image,1.0,0.0,0.0
Will turn a white image to blue

Set Image Brightness Image,0.0,0.0,1.0
Will turn a white image to red

Attachments

Login to view attachments
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 2nd Nov 2009 11:13
Thank you for testing.

But you're right. After the new update, the example doesn't work anymore. I'm sorry for that, I should have been more thorough.
I'll fix it as fast as possible.

Sven B

Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 2nd Nov 2009 13:29 Edited at: 2nd Nov 2009 13:34
Hi again,

Quote: "Here's another screenshot attached showing what happens when I remark out these lines:

Line 43:`copy image channel Mask, CHANNEL_ALPHA, CHANNEL_RED
Line 49:`copy image channel Mask, CHANNEL_ALPHA, CHANNEL_GREEN
Line 55:`copy image channel Mask, CHANNEL_ALPHA, CHANNEL_Blue"


This is correct behavior (DBP automatically assigns an alpha of 0 to black areas). Meaning the problem lies within the command copy image.
I fixed the copy image channel command. A typo... :-(
The switched blue and red channels should be fixed now too.

I'm sorry for the inconvenience, I only rechecked the commands where I changed the algorithm (not the ones with minor changes). The benchmark program didn't display the result either...

Anyway, I'll upload the new version in a second. Please report any other bugs.

Sven B

[EDIT] Attached is the updated DLL for those who don't want to download all the media again...

Attachments

Login to view attachments
Todd Riggins
20
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 2nd Nov 2009 19:10
No inconvenience I was just trying out it's capabilities for an idea I have and it looks very promising. Thanks for the quick fix! Will try it out again here soon.

Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 11th Nov 2009 11:51 Edited at: 11th Nov 2009 11:54
Update

It seems I wasn't awake when I rewrote the source code for the plug-in.

Again. For those that don't want to download all that media again, I included the DLL.

- Fixed Create Image, Copy Image, Set Color To Alpha
- Updated the examples. (Not the benchmark program)

Sven B

[EDIT] It seems I can't delete the attachment from the first post. I'll try again later...

Attachments

Login to view attachments
Gask
17
Years of Service
User Offline
Joined: 1st Sep 2007
Location:
Posted: 11th Nov 2009 16:04
hi sven , i have done several bench on your plugin and found that copy & resize image were faster than my own fonction , so i planned to use them but i got a glitch i can't reproduce easily out of my project.

Sometimes your resize image command do not work , it depends of the image used but i can't found a way to reproduce it easily.

simple example :



If i do this , your resize image works.

But if i remove the load part :


your resize image do not work , it is always 99 100 and not 10 10.

I have no idea at all why it can't. Because the ID at the start of the function have been created with the same command "load image "tile1.png",2000,1"

I have only put the ID in a structure type , and put the id from the structure in the fonction , in order to use the ID with resize image.

There is a way to debug your resize image function in order to know at which line it failed in the dll ?
Gask
17
Years of Service
User Offline
Joined: 1st Sep 2007
Location:
Posted: 11th Nov 2009 16:23
hmm very interesting :



this do not work.

juste change ima2 = 5 by ima2 = 2000 and it works.

but i test it with this :



and it works.

So i presume your plugin is in conflict with another command and when the other command is used you can't use image from range 0-31 ( yes i have do some more test ;p it works only at 32 )

soooo my first idea is : bitmap ( i create all 32 of them for my project )

I will come back if i am right.
Gask
17
Years of Service
User Offline
Joined: 1st Sep 2007
Location:
Posted: 11th Nov 2009 17:02
ok , i can't found where is the problem , but i got a temporal fix :



imagecalc is a image with id like = 50 000.

Instead of a resize of 4 ms it is one of 6 ms , but in every case it is better than my 30ms resize fonction , so i like it eheh.

ha yes , why i didn't use copy image at the end , well because it do not copy anything at this state if i use it , same problem as resize image i think.
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 11th Nov 2009 21:20
Hi Gask,

I have no idea what might cause your problem. I treat images the same way as in all the other commands. :-(

Sven B

Gask
17
Years of Service
User Offline
Joined: 1st Sep 2007
Location:
Posted: 11th Nov 2009 21:35
If i found exactly what is causing this , i will send you a mail , but for the moment i am happy with the temporal fix.

On the other side , I am a little unhappy about the "Paste Image On Image" command ( your plugin is great don't get me wrong :p )

I was thinking to replace my bitmap layer system by this command so i can get layer pasting with alpha but it is again too slow compare to bitmap to get the same result.

but i think it is strange that it can take 25 ms to just past a image 512x512 in an other image.

When you think that the "paste image" command from dbpro took only 1 ms to paste to the screen for the same size.

When you think about it , the bitmap is an image and the "paste image" command is pasting to this image.

well i gain some fps with some of your fonction , a great thanks to you.

ha if someone can make a copy to bitmap that manage alpha or a colorkey with the same/nearly speed as the internal one , it will be great ^^
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 12th Nov 2009 21:57 Edited at: 12th Nov 2009 22:02
Hi Gask,

When using paste image on image using the normal mode, I can't assume the bottom image has an alpha of 0xFF. A new alpha has to be calculated and this is pretty time-consuming.
Also, I chose for the more accurate & slower algorithm for BLEND_NORMAL.

The screen is a fully opaque background. Because of this, the algorithm to calculate the new color value is simplified to:
new = up * alpha + (1.0 - alpha) * bottom where alpha = alphachannel / 255.0
usually made into
new = (up * alphachannel + (255 - alphachannel) * bottom) >> 8 (/ 256)
for speed (though it has a slight error in that case).
This calculation is simply much easier and faster.

I guess I could introduce a new mode that automatically assumes the background is opaque though. It should be a lot faster than the BLEND_NORMAL mode and I imagine it being used quite often.

Cheers!
Sven B

[edit] I don't have the time for it now due to schoolwork (university takes a lot of my time lately). But I'll look into it this weekend.

Gask
17
Years of Service
User Offline
Joined: 1st Sep 2007
Location:
Posted: 12th Nov 2009 22:25
Quote: "I guess I could introduce a new mode that automatically assumes the background is opaque though"


That would be great

Quote: "I don't have the time for it now due to schoolwork (university takes a lot of my time lately). But I'll look into it this weekend"


no problem , take your time
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 14th Nov 2009 11:53
Update

A new blend mode is introduced: BLEND_FASTNORMAL. I thought it was an important feature, so I gave it a value of 1. Meaning all blend modes are now shifted up by 1.
ImageKitConstants.dba is also updated, so if you're using ImageKitConstants.dba, you just have to include that file again in your project.

The first tests were pretty satisfying. The error is not noticeable, and pasting a 512x512 image to a 512x512 image takes about 3 to 4ms. Of course it's impossible to get the same speed as DirectX as they use the GPU and I'm using the CPU. Still, it's usable.

I will be uploading the new version in a moment on the first post.

Cheers!
Sven B

Gask
17
Years of Service
User Offline
Joined: 1st Sep 2007
Location:
Posted: 15th Nov 2009 19:45
just test it !

pasting 3000 (100*100) image : 600 ms

Paste image command : 30 ms.

hmm maybe it will do it

I will put it in second mode in my project , so i can switch between bitmap and image that manage alpha later.

Just need to see if "slow" paste + alpha is better then fast paste for all upper bitmap layer that have been changed.

in every case thanks for this add.

Ho yes , one little bug , if the target image has in background a color of 0,0,0 the paste image command do not work on it, i load an image of 0,0,1 color and it works.

Not a big bug , but if you want to fix it , you know about it
Gask
17
Years of Service
User Offline
Joined: 1st Sep 2007
Location:
Posted: 15th Nov 2009 20:33
hmm no it is a big bug in fact.

i was silly trying to paste an image 800*600 when the background color is 0,0,1 , because if you paste it with command paste image id,x,y,1 , it will not manage alpha ( it is normal due to the 0,0,1 )

so i can't mixed two 800*600 image and that was the purpose of this command ;p ( for me at least )
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 15th Nov 2009 21:39
Hi Gask,

Quote: "Ho yes , one little bug , if the target image has in background a color of 0,0,0 the paste image command do not work on it, i load an image of 0,0,1 color and it works."


The BLEND_FASTNORMAL mode just leaves the background alpha untouched. Since DBP automatically makes color 0,0,0 completely transparent, those colors will stay transparent after the pasting. Try "set image channel" to set all alpha to 255 of the background image.
It's just my theory, so if it's not that, please tell me.

Cheers!
Sven B

Gask
17
Years of Service
User Offline
Joined: 1st Sep 2007
Location:
Posted: 19th Nov 2009 03:47
Actually we have this :

An image of 800*600 all pixel is color 0,0,0 and alpha = 0
An image of 200*200 , some pixer have color and an alpha different from 0 to show this color.
You paste pixels from the 200*200 image to the 800*600 image only if you find that the pixel on the 200*200 image have an alpha different from 0 , you copy RGB to the 800*600 image and that is all.

desavantage of this : we lost the means of alpha , because even if the 200*200 is correctly paste on the 800*600 image , the image 800*600 is nearly like a bitmap , and lost his alpha management , you can change the alpha to 255 or 0 if you want but you can't have a background with alpha 0 and the image past on it with alpha 255 , and that is a problem.

So for me , the most logic is to do :

An image of 800*600 all pixel is color 0,0,0 and alpha = 0
An image of 200*200 , some pixels have color and an alpha different from 0 to show this color.
You paste pixels from the 200*200 image to the 800*600 image only if you find that the pixel on the 200*200 image have an alpha different from 0 , you copy RGB+alpha to the 800*600 image and that is all.

At end we have a 800x600 image with alpha background mixed with the 200*200 image that can be seen and this image can be paste with alpha management without problem.

maybe add an argument to the paste image command ? like :

paste image on image imasource,imatarget,positionx,positiony,mode

mode = 0 paste image without alpha just color RGB
mode = 1 paste image with alpha so RGB + Alpha

what did you think of this sven ?
Gask
17
Years of Service
User Offline
Joined: 1st Sep 2007
Location:
Posted: 19th Nov 2009 03:57
while i am at it.

I have an little idea for a new command that you can implement with your plugin if you like it :

Change pixel r1,g1,b1,a1,r2,g2,b2,a2

r1 = 0-255 red color of the pixel to find
g1 = 0-255 green color of the pixel to find
b1 = 0-255 blue color of the pixel to find
a1 = 0-255 alpha color of the pixel to find
r2 = 0-255 red color to replace on the pixel that was found
g2 = 0-255 green color to replace on the pixel that was found
b2 = 0-255 blue color to replace on the pixel that was found
a2 = 0-255 alpha color to replace on the pixel that was found

it can be usefull in some way i think

Login to post a reply

Server time is: 2024-11-24 13:23:25
Your offset time is: 2024-11-24 13:23:25