March 29, 2024, 06:22:11 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Is it possible to load a JPG or BMP file into a DX screen buffer?

Started by plurald, January 18, 2011, 12:47:43 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

plurald

In a standard window you can do a LOADIMAGE/SHOWIMAGE to get a picture file into a window, but how about when using DX 2D programming?  I suppose I could do this using the MAP feature but I just need one screen and one picture.

Thanks.

pistol350

Hello!
From what i've understood,
you just need a dx screen created using the "CreateScreen" command then load your sprite "bmp file" using the "LoadSprite" command.
Then Update your dx screen.

By the way, what are you trying to achieve ? as what you're targetting might not need a directx screen.

PS :
In your "2D samples" folder, you should have a file called "sprite_example_1"
I've modified the code to take out the lines dealing with animation.
/*
/*
Sample from the users guide showing how to animate a sprite
The bitmap file "mouth.bmp" must be located in the same
directory as the compiled executable
Requires EBASIC 1.0 or greater and the 2D command set
*/
Def sprite as POINTER
Def xPos as INT
Def yPos as INT
xPos = 320
yPos = 240

'Create a screen
IF CREATESCREEN( 640, 480, 32) < 0
    MESSAGEBOX 0,"Error creating screen","error"
    END
ENDIF
'Load the sprite
sprite = LoadSprite(GETSTARTPATH + "mouth.bmp",0 ,0 ,3)
IF sprite <> NULL
    'Set the sprites drawing mode to transparent and specify a mask color
    SpriteDrawMode sprite,@TRANS
    SpriteMaskColor sprite,RGB(87,87,87)
    'The main loop
    DO
        FILLSCREEN RGB(0, 0, 255)
        WRITETEXT 0, 0, "Press ESC to close"
        DrawSpriteXY sprite, xPos, Ypos
        FLIP
'continue until ESCape is pressed
    UNTIL KEYDOWN(1)
    FREESPRITE sprite
ENDIF
CLOSESCREEN
END
Regards,

Peter B.

plurald

Thanks for the info. 

I know this is an unusual application, which is: 
   This game program would load a special photo file into either the back or front buffer (I only need one), then play a live-action game within it.  Thus far in my development, using standard window graphics is fast enough on my 3.0 gigihertz pc but I plan on porting it over to a 1.6 GH laptop and I suspect the response time of the finished product there may be too slow.

For now, I plan on developing the whole game without DX but I wanted to know if my idea will even work if I need the DX option.

What do you think about all this?



pistol350

Hi!

If you need speed no doubt developing your game with directx is your best choice instead of the mere window drawing functions.
But once more it depends on what your game is doing.
Regards,

Peter B.