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 / Pointer to an image..?

Author
Message
Dostej
23
Years of Service
User Offline
Joined: 21st Jan 2003
Location: Switzerland
Posted: 1st Sep 2003 12:10
Hi Guys
I know that DBP doesnt support pinters. But I´ve seen (and use) IanM´a array-dll. It uses pointers to arays.
Does any1 knows how to made it? (a function getcoreptr or so...?)

I need a pointer to an image. HOw can I do this...?
(@IanM: can u tell me if its possible and / or how to do this?)


All help is very warmly wellcome

www.dbpro.ionichost.com
AtomR
23
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Portugal
Posted: 1st Sep 2003 12:30
Hmm I was under the impression that DBPro already supported pointers. R you sure of that?

Take care
AtomR
Rob K
Retired Moderator
23
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 1st Sep 2003 12:32
DBP does support pointers in a limited way.

Quote: "
You can use the value of a variable to specify, read and write the contents of an address by using the '*'
indirect symbol. This is useful for obtaining areas of memory you wish to read from or write to and control
the pointer into this memory using a standard variable.

Ptr as DWORD
Ptr=0x00FF8820
*Ptr=42
PRINT *Ptr
The above code simply declares Ptr as a DWORD variable, assigns the variable a random area of memory,
writes the value 42 into that location of memory and then reads the same address back, the contents of
which is to be printed to the screen. You would never use an absolute address to assign a pointer. There
are commands such as GET BACKBUFFER PTR and MAKE MEMORY which return such address values. You
can only use a standard variable with indirection, and array and type variables are not valid. This is an
advanced feature and as such potentially dangerous. Writing into invalid memory can cause unexpected
program behaviour and even crashing. Use caution when employing the indirect symbol.
"


Convert your image to a memblock, then use GET MEMBLOCK PTR to get a pointer to it.

Dostej
23
Years of Service
User Offline
Joined: 21st Jan 2003
Location: Switzerland
Posted: 1st Sep 2003 15:08
Thx RobK. But that is "the long way".
1. Make memblock from image
2. work image
3. make image from memblock

What I want to do is the short way:
1. get pointer to image
2. work image

www.dbpro.ionichost.com
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 1st Sep 2003 15:18
You can't do it directly from DBPro although you could from a DLL using the Interface library.

The data is held in a DirectX texture, which uses a COM interface. DBPro cannot access COM objects directly.

Possibly, you may be able to use a bitmap instead of an image.

Dostej
23
Years of Service
User Offline
Joined: 21st Jan 2003
Location: Switzerland
Posted: 1st Sep 2003 15:24
@IanM
Thx a lot. That the info i was looking for.
I thought that it is not possible to do it from DBP.

Can u help me with the directX stuff (with this I m a completly newby). Where do I find / how to access these textures? (Or are u interested in writing a dll that return the pointer of an image?). In return I´ll try to write a dll that allows to change an image directly, without using paste / get image (toooooo slow).

www.dbpro.ionichost.com
Richard Davey
Retired Moderator
24
Years of Service
User Offline
Joined: 30th Apr 2002
Location: On the Jupiter Probe
Posted: 1st Sep 2003 16:03
Quote: "I´ll try to write a dll that allows to change an image directly, without using paste / get image"


You can already do this. That's what locking the pixels allows. Unless you're going to write a DLL that performs specific effects on the image? (ala Photoshop style filters or something).

Cheers,

Rich

"Gentlemen, we have short-circuited the Universe!"
Dostej
23
Years of Service
User Offline
Joined: 21st Jan 2003
Location: Switzerland
Posted: 1st Sep 2003 16:57 Edited at: 1st Sep 2003 17:00
@rich
Yeah, I know. But as far as i know I can only lock pixels and write to a bitmap. What I want is to write directly to the memory, where the image is located.

Why?

I (try to) write a game with a lot of text output. While using 3D i use sprites to show the text (maybe plains later on). So I put a backgrund-image to a bitmap, then write text to a bitmap and then take the image an make a sprite out of it. For a full screen it take s t about 3 sec. For screen transition a long time in a game. I performed some tests and found out, that mainly get image and paste image (which i use very often) are the time killers. So writing directly to the image-memory will spare a lot of time...
The other thing is loading the background-image, this can be solved unsing a dll to load the pics in the background once.

P.s. the most weakest things in DBP for me are the 2D-system (very slow) and the missing of pointers over wide areas (no pointer to: images, sprites, functions, arrays and UDT (exept IanM´s dll)) with oter words: all the interesting things... (this restrict API calles and TPC´s etc.) a lot.

www.dbpro.ionichost.com
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 1st Sep 2003 20:46 Edited at: 1st Sep 2003 20:46
If you are using Visual studio then you can use the Interface library from my site (I've been trying to get it working using MinGW, but with mixed results).

If you look through the 'include\\DBPro\\Image.hpp' file you can see that there is a function near the end called 'GetImageTexturePtr' that returns a pointer to the texture for the image you request.

As for the speed you are getting (or not ), there are various optimisations you can carry out, like pregenerating your text into images, disabling backsave on sprites etc.
Richard Davey
Retired Moderator
24
Years of Service
User Offline
Joined: 30th Apr 2002
Location: On the Jupiter Probe
Posted: 1st Sep 2003 21:16
I'd be interested to see your code. Get (and especially) Paste Image work extremely fast when used correctly.

Quote: "What I want is to write directly to the memory, where the image is located."


But this is what locking the pixels allows Maybe this will explain better:

1) In your loop (function, whatever) lock the pixels
2) Get the pixels pointer into a variable
3) You now have the direct memory location of the current image (typically screen)
4) Use "copy memory" or whatever you need to do in order to change the image
5) Unlock pixels

This is extremely fast, you can literally copy thousands of pixels around per frame (or blocks of memory, whatever you need). The one thing it doesn't do though which you probably want is to let you specify the image of which you're manipulating. You'd use the above for very fast direct display (screen) modifications.

Cheers,

Rich

"Gentlemen, we have short-circuited the Universe!"
Dostej
23
Years of Service
User Offline
Joined: 21st Jan 2003
Location: Switzerland
Posted: 2nd Sep 2003 12:21
@rich
Yepp, that right. If I locked a bitmap, the operations in this bitmap are really fast. And also `get image` is faster. But i want to have access to the data of the image, not to the bitmap. I think this is not possible with lock pixels (or is it?)

In this code snippet I use a function cutmemimage to extract a piece of an image out of an memblock., add it to a bitmap and merge it with another image.

www.dbpro.ionichost.com
Dostej
23
Years of Service
User Offline
Joined: 21st Jan 2003
Location: Switzerland
Posted: 2nd Sep 2003 12:25
What I want to do is... (pseudo-code)


get image 1, 400, 400, 690, 590, 1
a = get image pointer(1)
for b = 1 to 500
c = a + b * 4
*c = RGB(100, 100, 100)
next b

sprite 1, 10, 10, 1

to access the memory of the image (not a bitmap) directly!
This seems the fastest way to change an image!

www.dbpro.ionichost.com
Dostej
23
Years of Service
User Offline
Joined: 21st Jan 2003
Location: Switzerland
Posted: 2nd Sep 2003 13:01
@IanM
Sorry I dont use Visual Studio. But I´ve looked through these header-files. I think that is what I looking for. So what can I do?

PureBasic (the 2nd lang I use can include libs made in c++ or asm.)
But i have no idea of c(++). For what Do I need the headers (i case using the lib).
Are these a kind of declaration for the language of the functions stored in the lib?

Or in other words: Could you help me getting the image-pointer function running?
For me it would be perfect if you can make a dll or a TPC out of it that return the pointer of an imagenumber given. (But it would be more chilling for me to access the whole lib...)

www.dbpro.ionichost.com
CloseToPerfect
23
Years of Service
User Offline
Joined: 20th Dec 2002
Location: United States
Posted: 2nd Sep 2003 13:14
you can make a memblock from the image change the memory values and then make image from memblock, this will successfully alter the image.

CTP
Dostej
23
Years of Service
User Offline
Joined: 21st Jan 2003
Location: Switzerland
Posted: 2nd Sep 2003 13:24
Yes, I know, but thats a "long way". Want to access the image memory directly

www.dbpro.ionichost.com
Richard Davey
Retired Moderator
24
Years of Service
User Offline
Joined: 30th Apr 2002
Location: On the Jupiter Probe
Posted: 2nd Sep 2003 13:37 Edited at: 2nd Sep 2003 13:37
It's not really a "long" way, it just involves a couple of commands (literally).

Also bear in mind this - you can create a memblock from your image (which can be done in 1 command) and then once the image is in memory - you don't need to turn it back into an image again if you don't want to. For example I have a font-set held in a memblock, during the main loop of my code I copy one of the letters from the font-set (32x32 pixel area) by using the copy memory command direct to the display. There is no messing around turning the memblock into an image again and pasting it, you just copy the memory directly. Same end result, significantly faster.

Cheers,

Rich

"Gentlemen, we have short-circuited the Universe!"
Dostej
23
Years of Service
User Offline
Joined: 21st Jan 2003
Location: Switzerland
Posted: 2nd Sep 2003 14:04
@rich
Yes, definitly.
But I think you´ll agree, that writing directly to the image memory is the fastest way.

MY problem is:
I have a background image (i make it memblock and use copy memory).
I output text to that background and then make a sprite out of it to display the text.
When the sourrounding changes, i alter the text, so I have to use the same background, other text, image, sprite...

It takes at least 3 commands to do so.

In fact (working with memblocks whereever possible) It takes sth around 2 sec. to show a new screen (1024 x 768) completly using sprites with background and text and so on

www.dbpro.ionichost.com

Login to post a reply

Server time is: 2026-07-23 12:56:12
Your offset time is: 2026-07-23 12:56:12