We are about to switch to a new forum software. Until then we have removed the registration on this forum.
i have a PImage that i load on an intiation and that i need to draw at the end of my draw loop so it could be above all other drawings and without transparency, despite the previous code how do i ensure this?
i mean 'init' 'arbitrary code' loadImage 'arbitrary code' '/init'
'draw' 'arbitrary code'image(img,x,y)'/draw'
I tried all of:
<init>
....
father.tint(255,255,255);
father.fill(255,255,255);
father.alpha(father.color(255, 255));
img=father.loadImage("name\\"+name+".jpg");
....
< /init>
<draw>
....
father.tint(255,255,255);
father.fill(255,255,255);
father.alpha(father.color(255, 255));
father.image(img, posX+xd-img.width, posY+yd);
< /draw>
but i can still se lines behind the image.
Answers
The PImage has some pixels transparent ?
You can check every pixel with
pixels[i] == 0x0
and then replace it with your color.cameyo
@JDev -- re:
@cameyo's method of manually stripping transparency from
img
is one approach that would work. Here are some other things you can do.your
father
is a PGraphics, yourimg
is a PImage -- please don't post incomplete code without data types, it makes your descriptions potentially misleading. Instead, post a minimal sketch that demonstrates the problemIn general, you should use
pushStyle()
andpopStyle()
to isolate the style changes in your previous code so that you aren't unsure of what they are later and unclear on how to undo them. https://processing.org/reference/pushStyle_.htmlPGraphics.alpha()
doesn't set anything -- it "Extracts the alpha value from a color" (like.red()
) You are then throwing that value away. http://processing.github.io/processing-javadocs/core/processing/core/PGraphics.html#alpha-int-PGraphics.fill()
sets the color used for drawing -- it doesn't actually change pixels the way thatPGraphics.background()
does. If you want to set the background of father, callfather.background(255)
https://processing.org/reference/PGraphics.html.If you don't want to cover all of
father
in white, but you do want only the area behind your transparent image to be white, then either draw a white rect behind your image:...or, more simply, change your
father.blendMode()
before drawing the transparent image in order to alter the way it handles merging transparency onto the PGraphics canvas. https://processing.org/reference/blendMode_.htmlfather.blendMode(REPLACE); did work, how do i set it back to what it was before i tried pushStyle(); father.blendMode(REPLACE);; popStyle(); but something is now different in other blendings. father.blendMode(BLEND) didnt work either
To push and pop style on a PGraphics, use the PGraphics.pushStyle(): http://processing.github.io/processing-javadocs/core/processing/core/PGraphics.html#pushStyle--
Or, set blendMode back to the default manually. As per the documentation:
yep, sorry if i havent expressed myself clearly but thats what i wrote(or wantend to write) im now using the akward transform(0,0,1) and (0,0,-1) later with some degree of success, it works but i get a little offset.