PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

need help to draw png image

Hey all,

am developing a small game using EDGELIB. I am almost done with my basics, now i want to draw my png files on the screen. I dnt know what function to use. Can any body share some tips/codes to draw a png file using EDGELIB. Currently am working for windows desktop profile.

Zarina
Moved to edge forum.

Dan East
Hi,
Why my message is moved ? Did I posted it on the wrong forum ?
Where can I see my message now ? Where can I post my queries related to EDGELIB ?

--
Zarina
Hi All,

This is the code that I used to draw my png images.
But the exe is abruptly exiting. I am working on Windows 2005 vc profile.

Code:
SetRect(&rc;, 0, 0, buffer->GetWidth(), 50);
buffer->FillRect(&rc;, E_RGBX(0, 255, 0));
display->CreateSurface(titlebg, "splash.png");
buffer->BltFast(0, 0, titlebg, NULL);


Please let me know whats going wrong here !!
I am using a trial version of EDGELIB.

Thanks in advance,
Zarina
Hi Zarina,

You're code probably crashes because you're using an unallocated pointer variable.

Here is a small sample that should work:
Code:

E2DSurface titlebg;
SetRect(&rc;, 0, 0, buffer->GetWidth(), 50);
buffer->FillRect(&rc;, E_RGBX(0, 255, 0));
display->CreateSurface(&titlebg;, "splash.png");
buffer->BltFast(0, 0, &titlebg;, NULL);


Please note that the above is only a sample. Because it loads the picture every frame, it is very slow.
Thank you for your reply Edge

But that is not the problem. I tried your code as well still its not working :( !!

I am using the trial version of EDGELIB SDK 3.20 and using the edgelib builder (beta 9) to compile and execute my program.
Hi,

This is the code that i am using. My purpose is just to display a png image of size 128*128.

The image.cpp

Code:
#include "edgemain.h"
#include "imagebuffer.h"


/////////////////////////////////////////////////////////////////////
// Class definition //
/////////////////////////////////////////////////////////////////////

//The main class
class ClassMain : public ClassEdge
{
public:


E2DSurface *surface,*buffer;
ClassBuffer hello;

ClassMain(void);
~ClassMain(void);


ERESULT OnNextFrame(ClassEDisplay *display, unsigned long timedelta);

void OnButtonDown(unsigned long bnr, EBUTTONLIST *blist);
void OnStylusDown(POINT pnt);
};


/////////////////////////////////////////////////////////////////////
// ClassMain: public //
/////////////////////////////////////////////////////////////////////

//ClassMain: constructor
ClassMain::ClassMain(void)
{
//hello.i=0;
}

//ClassMain: destructor
ClassMain::~ClassMain(void)
{
}
//Callback: Called every frame
ERESULT ClassMain::OnNextFrame(ClassEDisplay *display, unsigned long timedelta)
{

hello.test(&display-;>buffer,timedelta);


return(E_OK);
}

//Callback: Called when the user pressed a key or button
void ClassMain::OnButtonDown(unsigned long bnr, EBUTTONLIST *blist)
{
//Quit();
}

//Callback: Called when the user points the stylus down or clicks the left mouse button
void ClassMain::OnStylusDown(POINT pnt)
{
Quit();
}


/////////////////////////////////////////////////////////////////////
// The program entry point //
/////////////////////////////////////////////////////////////////////

ClassEdge *EdgeMain(EDGESTARTUP *data){ return(new ClassMain); }






The imagebuffer.cpp

Code:
class ClassBuffer
{

public:
E2DSurface titlebg;
ClassEDisplay *display;
~ClassBuffer(void);
ClassBuffer(void);

void test(E2DSurface *buffer, unsigned long timedelta);
};
ClassBuffer::~ClassBuffer(void) { }

ClassBuffer::ClassBuffer(void){ }


void ClassBuffer:: test(E2DSurface *buffer, unsigned long timedelta)
{
RECT rc;
//green
SetRect(&rc;, 0, 0, buffer->GetWidth(), 50);
buffer->FillRect(&rc;, E_RGBX(0, 255, 0));
display->CreateSurface(&titlebg;, "splash.png");
buffer->BltFast(0, 0, &titlebg;, NULL);
}


can u pls check this code and tell me what is going wrong.?

Thanks in advance.
Zarina
Hi Zarina,

It probably doesn't work because the *display object of your ClassBuffer class doesn't point anywhere. I recommend to simplify things a bit and put my code into OnDisplayInit or OnNextFrame directly.