forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How can I load a PNG?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
_.-noel-._



Joined: 13 Aug 2007
Posts: 49

PostPosted: Wed Aug 15, 2007 2:40 am    Post subject: How can I load a PNG? Reply with quote

Hi...

For my project, I need to load PNGs.

I have paked the code to load PNG in a Header.

My Header: (bg.h)
Code:

#ifdef __cplusplus
extern "C" {
#endif


#include <malloc.h>
#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspdebug.h>
#include <stdio.h>
#include "graphics.h"
#include "framebuffer.h"

void bg(void) {


Image* bg;
bg = loadImage("bg.png");
        while(1)
        {
            blitAlphaImageToScreen(0, 0, 480, 272, bg, 0, 0);
        }
}
#ifdef __cplusplus
}
#endif


and in my main.c I have included the "bg.h" with
Code:

#include "bg.h"


an I loade the function with
Code:

bg();


But when I Start my programm, the LCD is black.

My makefile:
Code:

TARGET = V1.0
OBJS = main.o graphics.o framebuffer.o

INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

LIBDIR =
LDFLAGS =

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = V1.0
LIBS = -lpspgu -lpng -lz -lm -lpspumd -lpspusb -lpspusbstor -lpspctrl
PSPSDK= D:\pspdev\psp\sdk
include $(PSPSDK)\lib\build.mak


I hope anybody can help me...
_________________
Sry for my english
Back to top
View user's profile Send private message
2.6,CRACKED!



Joined: 26 Jul 2007
Posts: 18

PostPosted: Wed Aug 15, 2007 4:00 am    Post subject: Reply with quote

Did you put the file in the folder?

I always forget to do that, and i solve it by making sure if its there or not. Check
Back to top
View user's profile Send private message
_.-noel-._



Joined: 13 Aug 2007
Posts: 49

PostPosted: Wed Aug 15, 2007 6:44 am    Post subject: Reply with quote

yes, i did....

but must the file also stay at the project folder?

and the code is okay, istn't it?
_________________
Sry for my english
Back to top
View user's profile Send private message
Xfacter



Joined: 28 Feb 2007
Posts: 9

PostPosted: Wed Aug 15, 2007 6:57 am    Post subject: Re: How can I load a PNG? Reply with quote

_.-noel-._ wrote:
But when I Start my programm, the LCD is black.


Probably because you have an endless loop that never swaps draw buffers.
Back to top
View user's profile Send private message AIM Address MSN Messenger
2.6,CRACKED!



Joined: 26 Jul 2007
Posts: 18

PostPosted: Wed Aug 15, 2007 7:42 am    Post subject: Reply with quote

make sure when you call the function you have:

sceDisplayWaitVblankStart();
flipScreen();
Back to top
View user's profile Send private message
_.-noel-._



Joined: 13 Aug 2007
Posts: 49

PostPosted: Wed Aug 15, 2007 11:46 pm    Post subject: Reply with quote

yes i have...

okay....now it works, but i have another problem...

The image overwrithe the text...

how can i use the image at background?
_________________
Sry for my english
Back to top
View user's profile Send private message
Xfacter



Joined: 28 Feb 2007
Posts: 9

PostPosted: Thu Aug 16, 2007 2:38 am    Post subject: Reply with quote

You need to draw the image, then print the text. What you are doing now is not the proper way to use a background. What you need to do is load your image, then start a game/display loop. In the loop you process whatever needs to be processed, then draw whatever needs to be drawn in the order it needs to be drawn (lowest to highest). Then swap your buffers (i.e., call flipScreen()).
Back to top
View user's profile Send private message AIM Address MSN Messenger
_.-noel-._



Joined: 13 Aug 2007
Posts: 49

PostPosted: Thu Aug 16, 2007 8:38 pm    Post subject: Reply with quote

ookkayy...

i haven't understand all...
_________________
Sry for my english
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group