![]() |
| Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact |
| ||||||
This is a discussion on Convert Pixel to Alpha within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; I use graphics.h for this. I do not want to open Jasc Paint Shop Pro every time I need to ...
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 |
![]() |
I use graphics.h for this. I do not want to open Jasc Paint Shop Pro every time I need to make the bg of an image alpha transparent. My question is:
Is there a code I can use that will convert all the pixels of a certain color to the Alpha pixel? |
|
|
|
|
|
#2 |
![]() ![]() Developer
|
Code:
sceGuEnable(GU_COLOR_TEST); sceGuColorFunc(GU_NOTEQUAL,color,0xFFFFFFFF);
__________________
Raphs board rules #31: Excessive use of punctuation is either a sign of a lesser ego or a small mind. Avoid it if you don't want to look like a total moron. Raphs board rules #17: When you need to ask whether you are capable of doing something, you are not. Raphs board rules #2: Exploits aren't found by changing version numbers, blindly merging data into a file or turning your PSP upside down. Raphs board rules #1: If you have no clue how exploits work, don't come up with ideas about them. |
|
|
|
|
|
#3 |
![]() ![]() ...in a dream...
|
In the graphics library that comes with yeldarb's tutorials, no.
You can, however use other graphic libraries to do just that. Old School Library, for example, you do this when loading the image: Code:
oslSetTransparentColor(RGB(255,255,255)); // load image oslDisableTransparentColor();
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) |
|
|
|
|
|
#4 |
![]() |
Or you can just edit graphics.c to incorporate this, I did it when I first started it's pretty obvious. I would however advise against prolonged use of graphic.c as it is very slow.
I made an improved version of graphics.c on psp-programming which includes this function, but as I said it's very slow. |
|
|
|
|
|
#6 |
![]() |
This is how I did it, keep in mind that some of the member variables of the struct are named differently to the graphics.c as I did a full edit, also Raphael's method is much better if you know how to implement it.
Code:
void imageReplaceColor(Color inReplace, Color inColor, Image* inImage) {
int i, j;
for(j = 0; j < inImage->imageHeight; j++) {
for(i = 0; i < inImage->imageWidth; i++) {
if((inImage->imageData[(j * inImage->imageTextureWidth) + i] & 0x00FFFFFF) == (inReplace & 0x00FFFFFF))
inImage->imageData[(j * inImage->imageTextureWidth) + i] = inColor;
}
}
}
|
|
|
|
|
|
#8 | |
![]() ![]() Developer
|
Quote:
@pspballer7: Try adding my two lines after a guStart() and before drawing an image with blitAlphaImageToScreen(). You can use the GU_COLOR() or equivalent macro to set the source color. If you want to disable color-keying, just call sceGuDisable(GU_COLOR_TES T);
__________________
Raphs board rules #31: Excessive use of punctuation is either a sign of a lesser ego or a small mind. Avoid it if you don't want to look like a total moron. Raphs board rules #17: When you need to ask whether you are capable of doing something, you are not. Raphs board rules #2: Exploits aren't found by changing version numbers, blindly merging data into a file or turning your PSP upside down. Raphs board rules #1: If you have no clue how exploits work, don't come up with ideas about them. |
|
|
|
|
|
|
#10 |
![]() |
GU_RGBA(r, g, b, a)
__________________
YEAH! [center][COLOR="DimGray"][SIZE="2"][FONT="Times New Roman"]Julius Parishy [[URL="http://jparishy.com"]Homepage[/URL]][/FONT][/COLOR] Affiliates: [url=http://xfacter.jparishy.com/]Xfacter[/url] | [url=http://flatmush.jparishy.com/]Flatmush[/url] | [url=http://yaustar.jparishy.com/]Yaustar[/url] [url=http://jparishy.com/wp/source-code/]Soure Code[/url] [/center] [/size] |
|
|
|
|
|
#12 |
![]() |
Fully visible red.
Code:
GU_RGBA(255, 0, 0, 255) Code:
GU_RGBA(255, 0, 0, 130)
__________________
YEAH! [center][COLOR="DimGray"][SIZE="2"][FONT="Times New Roman"]Julius Parishy [[URL="http://jparishy.com"]Homepage[/URL]][/FONT][/COLOR] Affiliates: [url=http://xfacter.jparishy.com/]Xfacter[/url] | [url=http://flatmush.jparishy.com/]Flatmush[/url] | [url=http://yaustar.jparishy.com/]Yaustar[/url] [url=http://jparishy.com/wp/source-code/]Soure Code[/url] [/center] [/size] |
|
|
|
|
|
#13 |
![]() ![]() Developer
|
The alpha component doesn't matter, since the color test only tests the RGB channels. So you can set it to 0 or 255.
__________________
Raphs board rules #31: Excessive use of punctuation is either a sign of a lesser ego or a small mind. Avoid it if you don't want to look like a total moron. Raphs board rules #17: When you need to ask whether you are capable of doing something, you are not. Raphs board rules #2: Exploits aren't found by changing version numbers, blindly merging data into a file or turning your PSP upside down. Raphs board rules #1: If you have no clue how exploits work, don't come up with ideas about them. |
|
|
|
![]() |
| Tags |
| alpha , convert , pixel |
| Thread Tools | |
|
|