How to cover the PNG image with another PNG image?

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
lifecat9
Posts: 7
Joined: Fri Aug 29, 2008 12:45 pm

How to cover the PNG image with another PNG image?

Post by lifecat9 »

Image

My Code :

Code: Select all

#include <sdl.h>
#include <sdl_image.h>

void main&#40;&#41;&#123;
  Surf_Display = SDL_SetVideoMode&#40;400,400, 32, SDL_HWSURFACE | SDL_DOUBLEBUF&#41;&#41;;
  SDL_Surface* png1 = IMG_Load&#40;"png1.png"&#41;;
  SDL_Surface* png2 = IMG_Load&#40;"png2.png"&#41;;
  SDL_BlitSurface&#40;png1, NULL, png2,NULL&#41;;
  SDL_BlitSurface&#40;png2, NULL,Surf_Display,NULL&#41;;
  SDL_Flip&#40;Surf_Display&#41;;
  
&#125;
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

You are blitting your image in the pn2 surface!

Code: Select all

#include <sdl.h>
#include <sdl_image.h>

void main&#40;&#41;&#123;
  Surf_Display = SDL_SetVideoMode&#40;400,400, 32, SDL_HWSURFACE | SDL_DOUBLEBUF&#41;&#41;;
  SDL_Surface* png1 = IMG_Load&#40;"png1.png"&#41;;
  SDL_Surface* png2 = IMG_Load&#40;"png2.png"&#41;;
  SDL_BlitSurface&#40;png2, NULL,Surf_Display,NULL&#41;;
  SDL_BlitSurface&#40;png1, NULL, Surf_Display,NULL&#41;;
  SDL_Flip&#40;Surf_Display&#41;;
 
&#125;
Try this...
lifecat9
Posts: 7
Joined: Fri Aug 29, 2008 12:45 pm

Post by lifecat9 »

ne0h wrote:You are blitting your image in the pn2 surface!

Code: Select all

#include <sdl.h>
#include <sdl_image.h>

void main&#40;&#41;&#123;
  Surf_Display = SDL_SetVideoMode&#40;400,400, 32, SDL_HWSURFACE | SDL_DOUBLEBUF&#41;&#41;;
  SDL_Surface* png1 = IMG_Load&#40;"png1.png"&#41;;
  SDL_Surface* png2 = IMG_Load&#40;"png2.png"&#41;;
  SDL_BlitSurface&#40;png2, NULL,Surf_Display,NULL&#41;;
  SDL_BlitSurface&#40;png1, NULL, Surf_Display,NULL&#41;;
  SDL_Flip&#40;Surf_Display&#41;;
 
&#125;
Try this...
That's a good idea,think you!

But the Surf_Display will lost png1 and png2's alpha informats(suppose Surf_Display is transparence).How to save alpha informats?
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

Short answer: you simply can't on PSP
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
lifecat9
Posts: 7
Joined: Fri Aug 29, 2008 12:45 pm

Post by lifecat9 »

Raphael wrote:Short answer: you simply can't on PSP
?????
Yes!I cross out some codes;

this is SDL problem,of course you can use SDL in PSP.
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

OK, a little longer answer to make it clear:
You can't write to alpha on PSP (hardware limitation unless SDL would use a software method for blended blitting which is just slow), hence why you can't save the alpha part of png1 into png2 and then blit that to screen.
You have to do as ne0h suggested and just blit your images to screen directly in the proper order.
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
Post Reply