PocketMatrix forums

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

how to render image

akabeer1983 · 02 Feb 2009, 08:02 UTC
Hi,
i am new to EDGElib, i tried to load and render an image using sample code, provided in the topic: " need help to draw png image" in this forum.
____________________________________________

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);

____________________________________________

The simulator is not rendering anything, but is black.
i placed the image in Classes folder, res folder and also in the projec folder, still not getting.
i tried to change the rectangle size, etc.
can anyone help me?
Hi,

Please check the return value of the CreateSurface call, does it return E_OK? Also, make sure that you include the EST_READONLYPATH flag in CreateSurface.
akabeer1983 · 02 Feb 2009, 13:48 UTC
Hi,
Thanks for reply.
I have 2 doubts:
1) i executed the following code:

E2DSurface *image;
image = new E2DSurface();
long result = edisp -> CreateSurface(image, "map.jpg", EST_READONLY);
It runs properly, but the value of result is 7, (not E_OK).

But if i comment out the memory allocation for image //image = new E2DSurface();
and try to execute, iIt displays a big error, a line of which reads as:
Xcode could not locate source file: esurf_2d.cpp (line: 1493)

SHOULD I ALLOCATE MEMORY FOR image?


2) if i provide the absolute path of image "/projects/ImageRender/map.jpg",
then it displays image properly.
WHAT IS THE FORMAT FOR PATH?
Hi,

Yes, you need to allocate memory for the E2DSurface * object. You can also define a non-pointer instance of E2DSurface in your class and pass it to the CreateSurface() call as &image.;

Please try using EST_READONLYPATH instead of EST_READONLY. It should work better.
akabeer1983 · 03 Feb 2009, 08:04 UTC
Hi,
now the image path works with EST_READONLYPATH. I am using only "map/jpg", not the complete path.

Thanks for reply.