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.

DarkBASIC Professional Discussion / Something faster than GET IMAGE?

Author
Message
Agent
19
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 21st Sep 2009 11:38
Hey all,

GET IMAGE sucks. It's way too slow and I'm throwing a tantrum cause I want to call it a dozen times per iteration in my latest project but it reduces my frame rate to stupid lows.

Anyone know of a faster way to do the same thing as GET IMAGE?
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 21st Sep 2009 11:56
What do you want to do with the images? For example, there is a way to make a second camera. Or there are ways to just store the images that you have already grabbed.

Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 21st Sep 2009 12:01
What do you want to GET?

I mean if this is 3D output that you are grabbing, then you could setup a camera, position and rotate the same as the default camera 0, then take that cameras render output and use it, change it, abuse it with shaders etc. This is how refraction works, a live texture is taken then used to texture objects like water plains.

You should give details about what you are actually doing, not just which command is slowing you down - there may well be a faster method but we can't tell with the information you have given.


Health, Ammo, and bacon and eggs!
david w
18
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 21st Sep 2009 13:37
yes what exactly would you like to do?
Colonel_Klink
17
Years of Service
User Offline
Joined: 20th Dec 2006
Location: Within the dark recesses of my mind
Posted: 22nd Sep 2009 00:08 Edited at: 22nd Sep 2009 00:09
One way of reducing the problems you have is to load all the images at startup, assign each image to a unique id with Get Image, then just call them in your program loop with Paste Image.

I have about 120 images for my gui for normal state, mouse over state, and click state. Each one of those is assigned to image ids such as:
normal state - id 1-120
mouse over state - id 1001-1120
click state - id 2001 -2120

For my purposes each button image id relates like this:
image 1 - relates to ids 1, 1001, 2001
image 2 - relates to ids 2, 1002, 2002
etc

So to recap. Load each image to a unique ID then paste the image using Paste Image during the application loop.

Here's how I call images so that I can keep track of them


Oh my gosh! He's wearing Full Metal Pyjamas!
--------------------------------------------
Agent
19
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 22nd Sep 2009 17:14 Edited at: 22nd Sep 2009 17:35
I am working with two dimensional dynamic imagery, pasting layer upon layer to create a composite image, the contents of which are determined at runtime and are infinitelike in possible combinations. In order to further tweak the final image with alpha, rotate, diffuse and stretch functionality, I am outputting the composite to an undrawn offscreen bitmap (just using CREATE/CURRENT BITMAP here) and using GET IMAGE to grab it and feed it into DBP's sprite commands. I then want to PASTE SPRITE to output my final result to the drawn onscreen bitmap, but my bottleneck is obviously the GET IMAGE command, as such:



This code functions perfectly, and exactly as I want it to, but as I call this code dozens of times per iteration it's just too slow on account of the overhead for GET IMAGE.

Now, what I want to do is to replace GET IMAGE with something that performs an identical function (and it only has one), such as an external DLL or a custom-written function somebody has made for this purpose.

I could also use a way to adjust such properties as stretch, rotate, alpha and diffuse in some other way than making the image into a sprite. This won't solve my specific problem as I still need to grab the composite to turn it into a DBP image before I can work with it, but just the same if anybody knows of a viable, fast way to apply such properties to an image (as opposed to a sprite) that would be helpful to me in other ways.

Now, I don't know much about this technique, but it occurs to me that it might be possible to grab the image information straight from memory and somehow slap the data into an image ID. Can this be done using memblocks or a similar technique? I don't want the thread to get bogged down by memblock tutorials, but if someone can confirm that I can use them for this specific purpose I could use a signpost.

I just need a way to bypass GET IMAGE. Who's got an idea I can use?
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 22nd Sep 2009 18:00
Just a thought, have you tried setting the bitmap to a negative image number?

Like if you GET image 100 usually and sprite that, maybe:

SET CURRENT BITMAP -100

I'm sure I read that negative numbers on that command sets the output to the specified image instead, making the GET IMAGE (hopefully) redundant.

Gonna try this now...


Health, Ammo, and bacon and eggs!
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 22nd Sep 2009 18:35
Ok so I got it wrong!

It's actually camera output that gets targetted with negative numbers, however you could make a camera and image, then disable the backdrop and never sync this camera - so you might avoid any performance drain from the camera update, and you'd hijack the output for paste image etc... check this demo:



So it uses a bitmap and draws randomly to it, GET's the screen then pastes that to bitmap 0 - a ungodly ZERO frames per second on my PC. Hold space for ages until no more stars appear, then release, that'll take it to the next test.
Then it uses a camera to provide an image buffer instead of a bitmap, so no need for a GET image - I get over 1000fps with this.

Promising huh!


Health, Ammo, and bacon and eggs!
Agent
19
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 23rd Sep 2009 07:46
Ok let me see if I understand this...

I create a dummy image 100, then a dummy camera 1 that I never intend to sync, attach the camera to the image and never touch camera 1 again, leaving camera 0 active at full screen looking at bitmap 0 as default:



Now I'm initialised and ready. Then when I would normally GET IMAGE, I instead:



Now, image 100 has been altered and now contains my composite. If I now execute PASTE IMAGE 100, 0, 0 and SYNC it, my composite image will be drawn to the displayable screen.

Are we on the same page?
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 23rd Sep 2009 09:34
Yeah, that's it - the camera is only used as a vehicle for the image, but it also leaves you the possibility of using a 3D backdrop as well, like render a 3D scene then paste the composite parts on top.

I was thinking about this yesterday, and one cheap method to get the output right onto the screen would be TEXTURE BACKDROP, this will fill the screen with your composite image and you won't have to keep pasting the image or anything like that.

The other thing I was thinking is that you could have some neat 2D effects just using sprites. For instance you could add a water level sprite, which would just be the same composite image but on an inverted sprite with some blue added as diffuse, kinda like that old Psygnosis game Killing Game Show.

Plus there is nothing stopping you from sending that composite to an objects limb too, like if you made a laptop model with the screen as a seperate limb, just texture that limb with your composite and it would be a like a virtual PC. Would be quite cool to have a little 2D engine that can render as textures, mini games, fake OS's ala Doom3, that sort of thing - imagine Fallout3's terminals but in full 3D, with all the text and stuff being drawn right onto the screen.


Health, Ammo, and bacon and eggs!
Agent
19
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 23rd Sep 2009 23:36 Edited at: 23rd Sep 2009 23:36
Hello again Van,

Some progress. I've been able to dynamically create my composite image, feed it through DBP's sprite commands for visual tweaking and paste it to the drawable screen.

However, transparency information isn't holding - it's being lost as I paste to the special camera. Also, I'm getting black space to the right of and below my composite image; I'm unable to control the size of the final image to crop this black space out. These problems are related; if I can get black to register as fully transparent, that will solve most of my troubles but still won't restore my composite's alpha channel.

I've been playing around with it but can't figure this one out. Any ideas?
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 23rd Sep 2009 23:42
Well apparantly there's an extra flag when setting the camera, if you add a ,2 - like:

SET CAMERA TO IMAGE Cam,image,xres,yres,FLAG

The flag is 2 for alpha enabled mode, but I don't know it that'll do the trick.


You could always use a sprite for the render, then change the UV coordinates of the sprite to exclude the defect - or just resize it but it makes sense to crop it out to save on performance. I noticed some defects too, like the render image remains if you don't clear it out. There is a command to clear the camera view, maybe doing that first would clear up any defects. CLEAR CAMERA VIEW Camno or something like that, probably best to consult the camera section in the help files.


Health, Ammo, and bacon and eggs!
Agent
19
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 24th Sep 2009 00:36
No success with adding the ,2 flag at the end of SET CAMERA IMAGE. Seems to have no effect whatsoever.

I am outputting an alpha channel to the camera image when creating my composite image, but the target image isn't retaining it.

I'm drawing a black box to bitmap -1 each time I begin a new composite, to clear the previous workspace away.

I don't know how to crop the sprite. I can resize it, but that will include the dead black space.

Problem 1: How do I actually crop an image at codelevel?
Problem 2: How do I retain transparency in the target image, since the ,2 flag isn't having any apparent effect?
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 24th Sep 2009 00:53
I'm not sure how you could do it with alpha, but I guess you could do it with single colour transparency, as in wiping the screen with the solid colour you set with SET IMAGE COLORKEY.

You might well be wiping out all alpha with the black box clearing though, try disabling that, or assigning it to a key, so you can leave it without and see if the alpha is retained that way. I'm not sure how the camera knows what is transparent, but I'm thinking it could only be a disabled background on the render camera.

To figure out the sprite UV stuff, you have to know the order of vertexes on the sprite, which I'm not sure of. But...

SET SPRITE TEXTURE COORD Sprite Number, Vertex Index, UValue, VValue

So the vertex index is 0 to 3, and you'd probably want to set an offset to exclude the defect, might take some fiddling around, but it should work.


Health, Ammo, and bacon and eggs!
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 24th Sep 2009 01:03
Hmmm, try this, with any old alpha transparent image as fire.png...



Left click to clear the image, so maybe it would be better to try it without the SYNC MASK, because you are clearing the screen anyway - just position camera 0 somewhere miles from anything, set it's draw range to nothing. If that works, then it should be ideal, as I'm assuming that disabling the backdrop and using the ,2 flag when assigning the camera to the image is what you need to do. Then just with a standard SYNC, it should clear the camera image totally. If that doesn't work, then the left click clearing code should do the trick.


Health, Ammo, and bacon and eggs!
Agent
19
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 24th Sep 2009 01:53 Edited at: 24th Sep 2009 01:58
Actually, I hadn't been using the SYNC MASK in the first place, I'd forgotten all about it. I've not repositioned camera 1 or changed its viewport from anything other than default values. I'm using ,2 and disabling the backdrop, and using a SYNC all by itself.

When I introduce the SYNC MASK at the appropriate place there's no change.

A bit of experimenting though:

When I change my big black box to a big red box, and clear my camera view by pasting that big red box over whatever used to be there, it becomes apparent that while my alpha channel isn't being retained I can still see through the alpha150 parts of the composite image to get a partially red area, and the defect area to the right of and below the final image is now red instead of black (as expected). It looks like whatever is in the background through the alpha150 parts of the composite image as it's being created is going to form part of the final image; transparency information is retained on bitmap 1 itself, but if I paste the final image from the camera it's a bitmap paste, throwing the pixels as already blended to the background of bitmap1. This is interesting, but not what I want, as I want the background on the displayable screen to be additively blended to the composite image, not the background of the alternate bitmap.

Does that makes sense?

The only thing I can think of is to GET IMAGE the appropriate part of bitmap 0 and pasting it to bitmap 1 to clearscreen it!

Which, of course, brings us back to square one. We're outside my usual area of expertise here so I'm not sure what to try next. Any ideas?
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 24th Sep 2009 03:08 Edited at: 24th Sep 2009 03:12
The bitmap probably flattens the image. Can it be done directly to a plain as it has transparent properties. Not sure how you do it though.

Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 24th Sep 2009 03:18
Yeah, you should try using a plain, then set the transparency mode to 2 like the snippet I posted.

Maybe you could post an example of what your doing, I'd be happy to mess around with it, see if I can figure anything out. The principle seems to work, I mean the snippet I posted does have a alpha transparent sphere with a texture that is updated the same way... I'm sure you'll get it working.


Health, Ammo, and bacon and eggs!
Agent
19
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 24th Sep 2009 05:01
What I'm working on is essentially a GUI, and the composite image is the contents of a window, created by graphically engineering a frame, filling it with a background image, then populating it with additional images, representing textboxes, buttons, icons, lists, etc. That final composite window is being pasted to the 'desktop' as one image, that I wish to be able to stretch, rotate, alpha, etc for visual effects. The number of times I've been calling GET IMAGE therefore equates to the number of windows open at any given time. The whole thing is done using the 2D rendering systems in DBP, along with Cloggy's 'D3D Func', and I'm not using anything 3D at all.

I'll post some examples in a few hours when I have time to compose them, I've got something on irl atm. Does the description of what I'm doing with the technique we're discussing give any new ideas in the meantime?
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 24th Sep 2009 14:51 Edited at: 24th Sep 2009 14:53
I know what you are doing, I just don't know why you aren't doing it in 3D? It will look better in the end, and run faster. You can take a snapshot of the final 3D image to make it 2D again.

Agent
19
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 24th Sep 2009 17:00
A snapshot? How do you take a snapshot of a 3D image to make a 2D one at runtime?

I'm not convinced that making an image conversion from 3D to 2D will retain quality - there's no other visual conversion process in the world that does. And adding that conversion process promises a slower mainloop, not a faster one, so I'm a bit confused by what you're saying, Pincho.

On the other hand, I'm not very experienced in quasi-3D programming. Starting with what I already have, as described above, do I create a plain, texture it with my composite, point an additional offscreen camera at it and repeat our new image grab technique to draw it to the screen? Or do I just place the plain directly on the visible screen and texture it with my composite? I'm not sure how to play with plains in a 2D space.

I'm going to prepare some examples of my GUI so I can show people what I'm doing; I want to stick it in WIP anyway. I'll be back with my demo's in an hour.
Agent
19
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 24th Sep 2009 17:16 Edited at: 24th Sep 2009 17:18
Ok, I've had a thought.

Is there a way to clear an image that's already loaded into memory, or to create a null one? There's no CREATE IMAGE or MAKE IMAGE command that I can find, but I want one.

If I can somehow get my hands on a null, empty image that has no information in it whatsoever, I think all my problems will be solved.

Kind of like defining an array but putting nothing in it. I need an image ID to which I can output, without having any pre-existing data therein to worry about. They way, I don't have to specifically "clear" the image by filling it with a black color or similar technique, which results in the loss of my transparency information.

Alternately, is there a way to write directly to the alpha channel of an IMAGE id? Or a way to make DBP recalculate the alpha map of an image that's already loaded?

Perhaps I could save the image to disk and reload it, but that would be slow an inefficient. Ideas?
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 24th Sep 2009 17:16 Edited at: 24th Sep 2009 17:20
You just texture the plain, and it will look like a screen. Use Van B's example, and change the sphere to a plain. the coordinates can be matched to screen coordinates by locking the plain to the screen. Then by changing the texture, you get your animated effects. The reason that I mentioned converting it to 2D was because I didn't realise that you were creating animations. I thought that you were just creating a picture.

EDIT: Posted at the same time..

Agent
19
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 24th Sep 2009 17:37
Yep, saw the sametime post

Any thoughts about what I posted as you did?
Agent
19
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 24th Sep 2009 17:45
Actually... it wouldn't work anyway. There still needs to be *something* in the camera view, or else it'll be filled with random memory gibberish.

Now it looks like I'm back to the need to dynamically crop the image at runtime. I still need a way to make black transparent, through the grabbing process.
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 24th Sep 2009 17:54 Edited at: 24th Sep 2009 18:05
Do you mean black as holes, or black as faded colour? Because Black is tranparent during the grabbing process, I have used it as a cookie cutter to make shadow shapes. It's not alpha shaded though. It was slow anyway. My shadow idea was unusable. But you can grab sprites with a black background to cut them out. I did it on the second screen too, it still worked.

You need a fast way you mean?

You are probably doing something similar to my shadows actually. It was too slow. You are stuck with an attempt at 3D.

Agent
19
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 24th Sep 2009 18:07
Yeah, I mean black as holes, completely transparent. During a GET IMAGE, black is indeed transparent, or whatever color you define using SET IMAGE COLORKEY, but through the grabbing technique Van and I have been working on black is not treated as transparent, but as a solid pixel. I'm looking for a way to change this.
Agent
19
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 24th Sep 2009 19:38
Ok, I've experimented and solved most of my primary problems here by making a new bitmap and a new camera each time I want to create a new composite, and deleting them both at the end. I'm able to crop the resulting image by setting the size of the bitmap and the camera to the size of the window I'm going to build.

This is working, for the most part, and transparency information is being retained.

If I have one single window open, everything works nicely. If I open a second and third window, things still look right. Once I open the fourth window, some of the transparency information in all four windows become corrupted, and any additional windows corrupts transparency even further.

Is there something magical (read: buggy) about the number 4 with respect to cameras or bitmaps?

I also have another problem: Cloggy's D3D text doesn't draw as expected when I'm outputting to bitmap -1; his font sizes and pixel coordinates seem to be scaled to the size of the bitmap I'm outputting to, so the text is far too small and in the wrong position. Native DBP text commands work just fine. Any thoughts on this?
Agent
19
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 24th Sep 2009 20:11 Edited at: 24th Sep 2009 20:11
Heh, more updates... I know I'm moving from one place to another at any given moment in this thread, but I'm discovering stuff quickly at the moment...

I've fixed the transparency corruption, it was my own fault for not clearing the bitmap each time I create it; I didn't realise that deleting a bitmap and creating the same one again retains the information the last one held.

However, I still want the color black to register as completely transparent. How?
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 24th Sep 2009 20:20
I did try and set my own colour key, but sadly I'm sure that when you have alpha transparency on something, the colour key is ignored. So even if you did set the colour key to 0, it probably wouldn't work.

I'll mess around for a bit and see if I can figure something out. There is one option, which is to make a memblock from the image and cut out the black, but that involves a full image scan and might be a bit slow.


Health, Ammo, and bacon and eggs!
pcRaider
16
Years of Service
User Offline
Joined: 30th May 2007
Location:
Posted: 24th Sep 2009 20:35
Lee commits a mistake.
He does not consider an alpha channel.
make_image_from_memblock
SET_CURRENT_BITMAP
We cannot get a correct answer from DBP.

make_image_from_memblock and,
Check Matrix1Util_23 SET ALPHA.
I did not test it.
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 24th Sep 2009 20:39
Ach, the memblock from image idea is a no go D: - because the source image is locked to a camera it can't be converted.


Health, Ammo, and bacon and eggs!
Agent
19
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 24th Sep 2009 21:17
@pcRaider: Pardon?

@Van: Yes. It's known to me that if an image already possesses an alpha channel, the color key is ignored. I'm having difficulty getting it to recognise black as full transparent though; let me explain:

Each time I want to draw a new composite image, I am clearing the bitmap by using DBP's default BOX command to fill the bitmap completely, overwriting what used to be there. As far as I'm aware, there's no transparency information attached to the BOX command, so the entire bitmap should now be full of 'transparency'. Next I start drawing my composite image. Now, if any part of that composite image contains transparency, that alpha information is correctly transferred to the final IMAGE and will be additively blended correctly with the target background when I paste it. If part of the composite being drawn is black, the final IMAGE also treats that as alpha 0, completely transparent, and will result in a 'hole' when I paste to the target site.

However, if I don't draw to a particular pixel at all on the black washboard I started with, that pixel will remain a solid, opaque black and will be pasted as RGB(0, 0, 0) to the target site.

I was trying to work out what the difference is between not pasting anything to an area of the black washboard, and pasting "black" to the black washboard. The answer I came up with was that the 'black' being pasted over the 'black washboard' contains alpha information, because it's part of an image loaded with a colorkey set to black.

The obvious solution here was to paste an opaque black washboard to clear the screen, then paste an alpha 0, completely transparent sheet over the whole lot to add transparency information, but this hasn't worked I'm still getting solid opaque black.
Agent
19
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 24th Sep 2009 21:18
Van, do you use MSN by any chance?
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 24th Sep 2009 21:35 Edited at: 24th Sep 2009 21:37
Nah, I tend not to use MSN. Something I noticed, I use a very very faint texture for that code I posted, and it actually clears the screen with alpha.

Check the screenshot attached...

The purple bits are BOX commands, my attempt at getting color key to work - plus a very faint alpha image - both drawing in random locations. So as you can see, the purple bits are being wiped out by the alpha, but it's fading to full, or at least mostly transparent. There's a cube there with the render going to a plain in front of it, so you can see the alpha does definitely work.

When I run it, I get a cool matrixy sort of thing - I'm not sure if this is of use, but I could post up the media and stuff I'm using so you can experiment a bit. When I paste the image, the transparency is working, but to me it looks like the highest value on the png texture overwrites everything, so a texture like that pasted might be enough to clear out the render before each pass.

Anyhoo, series 4 of Heroes is out, so I'll post up a demo of this in a bit .


Health, Ammo, and bacon and eggs!

Attachments

Login to view attachments
Agent
19
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 24th Sep 2009 22:13 Edited at: 24th Sep 2009 22:16
I'm finding that if I have a solid background image, like a desktop wallpaper, and cover it with an opaque layer, like a solid black box, then I cover that with another black layer at alpha 128, I can now see through the opaque black layer and view a darkened version of the wallpaper, which is a composite additive blend of the wallpaper and the 128 alpha layer.

The further away I get from 128 as an alpha value for the top layer (which is smack in the middle between 0 and 255, 50% alpha), the more opaque the final result becomes, and at 0 or 255 alpha I've got solid black wall again and I can't see the wallpaper anymore.

I can therefore make my corners 50% translucent, but I can't get them any more faint than that. Ideally, I'd like them at 0% alpha, but I can't find any way to do it without skipping the bitmap clear step, which will open the door for visual corruption.
Grog Grueslayer
Valued Member
18
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 24th Sep 2009 22:24
Are you guys using the SET BITMAP FORMAT command to make sure all bitmaps and images retain their transparency?



Agent
19
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 25th Sep 2009 00:00
I hadn't been using it, but it seems to have no effect when I implement it. Looks like retaining alpha information is the default behaviour. Any other ideas?
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 16th Jan 2010 18:46 Edited at: 16th Jan 2010 19:32
I know this is an old thread, but I was searching for faster methods to get images as well. I wondered how much faster it'd be just loading a tilemap into a memblock then building new images from it.

I used a tilemap of 624x504 with 24x24 tiles. To grab every tile using get image was about 6 times slower than using memblocks. However, the more sequential iterations I did over each method the less the speed difference got. After doing 20 iterations on both, get image actually proved to be 1.5 times faster.

So I guess it all depends on your application. If you're simply loading the tile map once, as for the start of a game's level or something, then memblock is the way to go.

Created a function and uploaded to the code snippets here.


"Any sufficiently advanced technology is indistinguishable from magic" ~ Arthur C. Clarke
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 17th Jan 2010 10:01
Might I also refer to my image manipulation plug-in Image Kit.
It's still in WIP, and I will only resume working on it after exams are finished (Jan. 28th), but you might be able to use it.

Note: It doesn't work with DDS files or camera rendered images.

Cheers!
Sven B

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 17th Jan 2010 14:16
Quote: "I know this is an old thread, but I was searching for faster methods to get images as well"

How about creating an image of the required size for your tile (MAKE IMAGE) and simply pasting your tilemap image onto it (DRAW TO IMAGE, PASTE IMAGE) with an appropriate offset to get the tile you require.

Tada! That's it. I don't think you can do it any faster than that.

Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 17th Jan 2010 14:19
Aha Sven, was just coming here to mention ImageKit, I'm using it in a couple of projects now - one of which uses a small camera render then GET PIXEL to calculate the average colour. I did this by adding the ,1 flag when setting the camera image - this apparantly forces it into real video memory or something, then the GET PIXEL at least works.
Another project I'm using it to draw GUI sprite windows. I have a 32x32 icon editor thing that updates itself without GET IMAGE, memblocks, or hidden bitmaps - Direct image editing FTW! .

I'm sure it'll be able to do something for Agent too, it's a very useful plugin especially if you remember the camera to image flag. The only thing on my wish list for it is the ability to paste onto images with rotation, that I think would really open up oppurtunities - like footprints and stains on terrain. Have been thinking about making flat UV maps, so no overlapping polygons on the UV, so each point on the texture is unique - then if I can calculate the texture location of a collision, it can have permanent bullet decals, dents, all sorts of cool stuff like that.

For me it's up there with Sparky's, cloggy's and IanM's Matrix1 as a vital addition to DBPro.


Health, Ammo, and bacon and eggs!
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 17th Jan 2010 16:16
Didn't even know those commands existed Ian. Those could be useful.


"Any sufficiently advanced technology is indistinguishable from magic" ~ Arthur C. Clarke
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 17th Jan 2010 16:49
They were new in the last release of my plug-ins - I was tired of mucking around with cameras to generate images, so I wrapped it all up with a few other bits and pieces into a new plug-in.

RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 17th Jan 2010 17:00 Edited at: 17th Jan 2010 17:07
You might consider using 3D surfaces for your images instead. Drawing your images to 3D surfaces such as plains, gives you the added bennefit of being able to deform these 3D surfaces to get a desired effect. Rotation on the y axis will alter your image's perspective (similar to the perspective tool in photoshop). You still have all of the typical scale / translate / rotate / transparancy capabilities. You've also got the set camera to image command now being able to function.

Something I experimented with a year or so ago was trying to emulate those effects in photobooth that deform your face on a webcam. Not sure if you know what I'm talking about, but it essentially takes the webcam image and bends it to make it look like you have a large stretched head or a squished neck. I figured out that if you use a plain divided up into say, 10 x 10 sections, you can just texture this plain with the image and then move the verticies of each grid section on the plain towards / away from the camera. If done smoothly, you get the exact same effect (like those mirrors in fun houses at carnivals).

Add to that the ability to apply object shaders if you ever want to, and load in actual 3D models as parts of the image (again, photoshop lets you import models and rotate them / move them around over your canvas) and apply shaders to these as well, I think this would be a better system over all.

Hell, if you wanted to incorperate a filter system, this could all be done via shaders as well.

Login to post a reply

Server time is: 2024-05-03 01:36:20
Your offset time is: 2024-05-03 01:36:20