PNG Palette Replacement
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   madan_mohan
Posted On:   Monday, May 15, 2006 12:30 PM

Hi, I need to replace PNG Palette colors in the png images. 1. I need some references to divide the png to Data and PAL Files. 2. Code For replacing/merging data and pal files. I have tried some code references. It works with Nokia S60 and SonyEricsson Phones. But Doesnt work on S40 High end devices and Motorola Phones. //========================================== Code which is working for S60 and Sony Ericsson //========================================== public Image changePal(String imgPath, String palPath) { Image decodedImg = null; try { InputStrea   More>>

Hi,


I need to replace PNG Palette colors in the png images.



1. I need some references to divide the png to Data and PAL Files.


2. Code For replacing/merging data and pal files.



I have tried some code references.
It works with Nokia S60 and SonyEricsson Phones.
But Doesnt work on S40 High end devices and Motorola Phones.




//==========================================


Code which is working for S60 and Sony Ericsson

//==========================================


			

public Image changePal(String imgPath, String palPath) {
Image decodedImg = null;
try {
InputStream is = getClass().getResourceAsStream(imgPath);
byte [] img = new byte[is.available() + 1024];
int imgSize=is.read(img);
if (imgSize > 0){
is = getClass().getResourceAsStream(palPath);
byte [] pal = new byte[is.available() + 1024];
int palSize=is.read(pal);
if (palSize > 0) {
int palStart;
for (palStart=0;palStart
//palStart+=4;
System.arraycopy(pal, 0, img, palStart, palSize);
}
System.out.println("Img Length = "+img.length);
decodedImg = Image.createImage(img,0,imgSize);
}
} catch (Exception e) {
System.err.println("Can`t load the image " + imgPath + ": " + e.toString());
}finally{
return decodedImg;
}

//=====================================



Please help me in resolving this issue.


Thanks in Advance

Madan KN    <<Less
About | Sitemap | Contact