Gimp plugin
Gimp plugin
http://perso.orange.fr/franck.charlet/PSPTex.zip
PSPTex is a save plugin for GIMP 2.2.x allowing to create textures for the PlayStation Portable.
It can save raw RGBA (5650, 5551, 4444 or 8888) & indexed (T4, T8) textures (with 5650, 5551, 4444 or 8888 palette modes support) as well as DXTC (DXT1, DXT3, DXT5) compresssed ones, it supports the PSP textures swizzle mode and can generate mipmaps, it also have a color key feature to handle transparency and can convert grayscale pictures into alpha channel only textures.
(Note: if the plugin doesn't work under windows you'll need to copy the gimp dlls into the system directory).
PSPTex is a save plugin for GIMP 2.2.x allowing to create textures for the PlayStation Portable.
It can save raw RGBA (5650, 5551, 4444 or 8888) & indexed (T4, T8) textures (with 5650, 5551, 4444 or 8888 palette modes support) as well as DXTC (DXT1, DXT3, DXT5) compresssed ones, it supports the PSP textures swizzle mode and can generate mipmaps, it also have a color key feature to handle transparency and can convert grayscale pictures into alpha channel only textures.
(Note: if the plugin doesn't work under windows you'll need to copy the gimp dlls into the system directory).
Last edited by hitchhikr on Fri Sep 15, 2006 3:57 am, edited 6 times in total.
-
- Posts: 60
- Joined: Wed Jul 06, 2005 7:03 pm
-
- Posts: 60
- Joined: Wed Jul 06, 2005 7:03 pm
I've hacked it up a bit and have gotten it running on the linux version of gimp (developer version 2.3.8)
I've ran into a couple problems though...
The image is upside down (height-(y+1) used instead of y) I know this is often done in windows bmp files, but I don't think this is a good thing for the psp? ... was this intentional or is it a bug?
It seems it's supposed to automatically resize the image to a power of 2 width, however it does not appear to be working... I don't have time to look into why right now unfortunatly.
Also, do you have any intentions of adding support for saving the alpha channel?
I've ran into a couple problems though...
The image is upside down (height-(y+1) used instead of y) I know this is often done in windows bmp files, but I don't think this is a good thing for the psp? ... was this intentional or is it a bug?
It seems it's supposed to automatically resize the image to a power of 2 width, however it does not appear to be working... I don't have time to look into why right now unfortunatly.
Also, do you have any intentions of adding support for saving the alpha channel?
Shoot Pixels Not People!
Makeshift Development
Makeshift Development
I'm copying the texture from top to bottom, maybe your uv coordinates are upside down ? In the worst case, flip it vertically within gimp :DThe image is upside down (height-(y+1) used instead of y) I know this is often done in windows bmp files, but I don't think this is a good thing for the psp? ... was this intentional or is it a bug?
If it's really a problem, i may add an option to allow reverting the textures for saving them, eventually.
No it's not, there's no reason why it should do that, the pow stuff is only used to generate the xxx_TEXTURE_WIDTH constant which is compliant with the textures sizes passed to the psp, the xxx_TEXTURE_REAL_WIDTH contains the real pixels width (as implied), both are to be passed to sceGuTexImage(). The plugin generates a .h file beside the .psptex as an helper.It seems it's supposed to automatically resize the image to a power of 2 width, however it does not appear to be working... I don't have time to look into why right now unfortunatly.
There's full support for alpha channel already (unless i screwed something up somewhere).Also, do you have any intentions of adding support for saving the alpha channel?
So it's just my imagination that line 275 is the following? ;)hitchhikr wrote: I'm copying the texture from top to bottom, maybe your uv coordinates are upside down ? In the worst case, flip it vertically within gimp :D
If it's really a problem, i may add an option to allow reverting the textures for saving them, eventually.
Code: Select all
offset = (((height - (y + 1)) * width) + x);
Erm.. don't you need the buffer width to be a factor of 2?No it's not, there's no reason why it should do that, the pow stuff is only used to generate the xxx_TEXTURE_WIDTH constant which is compliant with the textures sizes passed to the psp, the xxx_TEXTURE_REAL_WIDTH contains the real pixels width (as implied), both are to be passed to sceGuTexImage(). The plugin generates a .h file beside the .psptex as an helper.
Even if you do, not neccisarily saying it's something it should do for you, just mentioning ;)
Doesn't seem to work for me... which could be anything from me screwying up to a change in gimp, to you screwying up ;) ... One way or another I'll look into it more after the compo.There's full support for alpha channel already (unless i screwed something up somewhere).
Shoot Pixels Not People!
Makeshift Development
Makeshift Development
Damn you're right :DSo it's just my imagination that line 275 is the following? ;)
Code:Code: Select all
offset = (((height - (y + 1)) * width) + x);
I must have used this for a test purpose but i can't remember which one now, i'll modify that.
Nope, you can do such stuff:Erm.. don't you need the buffer width to be a factor of 2?
Code: Select all
TEST_TEXTURE_WIDTH 512
TEST_TEXTURE_HEIGHT 256
TEST_TEXTURE_REAL_WIDTH 480
sceGuTexImage(0, TEST_TEXTURE_WIDTH, TEST_TEXTURE_HEIGHT, TEST_TEXTURE_REAL_WIDTH, &Bytes);
I'll be interested to know what picture and what mode you used to test it. Notice that in order for the alpha channel to be active you'll need to use something like that in your code:Doesn't seem to work for me... which could be anything from me screwying up to a change in gimp, to you screwying up ;) ... One way or another I'll look into it more after the compo.
Code: Select all
sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
sceGuEnable(GU_BLEND);
That line was for indexed images I believe, you have the same line somewhere else for RGB images I think.. so make sure you catch both (I had to recompile earlier as I missed the indexed one yesterday ;) )hitchhikr wrote:Damn you're right :DSo it's just my imagination that line 275 is the following? ;)
Code:Code: Select all
offset = (((height - (y + 1)) * width) + x);
I must have used this for a test purpose but i can't remember which one now, i'll modify that.
Hrm... Well I think I was doing things right earlier, but I'll try to play with it more today and see what is going on, as it would be nice to have alpha channels in some of my graphics I'm converting. ;)I'll be interested to know what picture and what mode you used to test it. Notice that in order for the alpha channel to be active you'll need to use something like that in your code:
Code: Select all
sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0); sceGuEnable(GU_BLEND);
Shoot Pixels Not People!
Makeshift Development
Makeshift Development
I forgot to mention, make sure you're using this too:
The default is GU_TCC_RGB i think.
Code: Select all
sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
Last edited by hitchhikr on Mon Jun 19, 2006 2:07 am, edited 1 time in total.
Okay, more bugs...
In the event of of an alpha channel you are reading gimp's data as ABGR, but it seems to be BGRA... and you are using 0xff - A for alpha...
changing those two things I now how correctly working alpha :)
In the event of of an alpha channel you are reading gimp's data as ABGR, but it seems to be BGRA... and you are using 0xff - A for alpha...
changing those two things I now how correctly working alpha :)
Shoot Pixels Not People!
Makeshift Development
Makeshift Development
Ok, i made a test with this and a texture called test and it worked flawlessly as expected:
Code: Select all
sceGuClearColor(0xffffffff);
sceGuColor(0xffffffff);
sceGuClutMode(TEST_PALETTE_FORMAT, 0, TEST_PALETTE_MASK, 0);
sceGuClutLoad(TEST_PALETTE_COLORS, &RES_TEXTURE_PALETTE);
sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
sceGuEnable(GU_BLEND);
sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
sceGuTexMode(TEST_TEXTURE_FORMAT, TEST_TEXTURE_MIPMAPS, 0, TEST_TEXTURE_SWIZZLE);
sceGuTexFilter(GU_NEAREST, GU_NEAREST);
sceGuTexImage(0, TEST_TEXTURE_WIDTH, TEST_TEXTURE_HEIGHT, TEST_TEXTURE_REAL_WIDTH, &RES_TEXTURE);
sceGuEnable(GU_TEXTURE_2D);
vertices[0].tu = 0; vertices[0].tv = 0;
vertices[0].x = 0; vertices[0].y = 0; vertices[0].z = 0;
vertices[1].tu = TEST_TEXTURE_REAL_WIDTH; vertices[1].tv = TEST_TEXTURE_REAL_HEIGHT;
vertices[1].x = TEST_TEXTURE_REAL_WIDTH; vertices[1].y = TEST_TEXTURE_REAL_HEIGHT; vertices[1].z = 0;
sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | GU_TRANSFORM_2D, 2, 0, vertices);
sceGuDisable(GU_TEXTURE_2D);
sceGuDisable(GU_BLEND);
Hm... k.
FYI I've been using 8888 textures during these test, not paletted textures; that may make a difference...
I've been doing essentially the same as what you've said (though I've done a bunch of other stuff too...) and the original code does not work, while changing the two things I mentioned fixes the issues.
If yours works for you, and mine works for me, I think gimp may have changed how it does things a bit.. As I mentioned I'm using 2.3.8, which is the second to newest dev release... (I don't think they make windows builds of development versions) They changed a lot, so perhaps some of the problems may be caused by changes they've made.
FYI I've been using 8888 textures during these test, not paletted textures; that may make a difference...
I've been doing essentially the same as what you've said (though I've done a bunch of other stuff too...) and the original code does not work, while changing the two things I mentioned fixes the issues.
If yours works for you, and mine works for me, I think gimp may have changed how it does things a bit.. As I mentioned I'm using 2.3.8, which is the second to newest dev release... (I don't think they make windows builds of development versions) They changed a lot, so perhaps some of the problems may be caused by changes they've made.
Shoot Pixels Not People!
Makeshift Development
Makeshift Development
That's what i was suspecting.If yours works for you, and mine works for me, I think gimp may have changed how it does things a bit.. As I mentioned I'm using 2.3.8, which is the second to newest dev release... (I don't think they make windows builds of development versions) They changed a lot, so perhaps some of the problems may be caused by changes they've made.
And it wouldn't surprise me as they always screw everything up from one release to another. Actually there's a 2.3.8 release for windows but even the plugins provided with the distrib don't work. I'll stick to the lastest stable release myself.
EDIT: I tested again with a 8888 texture and it still works perfectly.
v1.0 released:
http://perso.orange.fr/franck.charlet/PSPTex.zip
- Fixed GIMP_RGBA_IMAGE, GIMP_GRAYA_IMAGE & GIMP_INDEXEDA_IMAGE inputs.
- Should now compile correctly under linux & co.
http://perso.orange.fr/franck.charlet/PSPTex.zip
- Fixed GIMP_RGBA_IMAGE, GIMP_GRAYA_IMAGE & GIMP_INDEXEDA_IMAGE inputs.
- Should now compile correctly under linux & co.
-
- Site Admin
- Posts: 347
- Joined: Sat Jan 17, 2004 9:49 am
- Location: Melbourne, Australia
- Contact:
Just to let you know, I've put a mirror up at:
http://ps2dev.org/psp/Tools/PSPTex
I'll post info to news too.
Oobles.
http://ps2dev.org/psp/Tools/PSPTex
I'll post info to news too.
Oobles.
I released a 1.01 version (http://registry.gimp.org/plugin?id=7855).
Also i think you should link it to http://perso.orange.fr/franck.charlet/PSPTex.zip instead of mirroring it.
Also i think you should link it to http://perso.orange.fr/franck.charlet/PSPTex.zip instead of mirroring it.
I'm also under linux, how can i get it running on the linux version of the gimp?Drakonite wrote:I've hacked it up a bit and have gotten it running on the linux version of gimp (developer version 2.3.8)
I've ran into a couple problems though...
The image is upside down (height-(y+1) used instead of y) I know this is often done in windows bmp files, but I don't think this is a good thing for the psp? ... was this intentional or is it a bug?
It seems it's supposed to automatically resize the image to a power of 2 width, however it does not appear to be working... I don't have time to look into why right now unfortunatly.
Also, do you have any intentions of adding support for saving the alpha channel?