No warning to mix screen 0 and screen graphic commands! - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10) +---- Thread: No warning to mix screen 0 and screen graphic commands! (/showthread.php?tid=1752) |
No warning to mix screen 0 and screen graphic commands! - TempodiBasic - 06-14-2023 Help! For all coders like me that are too old to abandon the old Qbasic Keywords vs new QB63pe keywords, it should be a warning AI in the parser! run this code and you can experimenting what I'm saying. Code: (Select All) Dim Shared S1 As Long, S2 As Long At a first time it has been clear to my old mind! Why the part of S2 that brings PRINT output is not under the effect of _setalpha? Yes PRINT is a keyword of SCREEN 0, but I believe that _setalpha should work on the whole S2 and not only to the part that brings a graphic effect. In other words I should get this result if I make output directly to the main screen, while if I copy a screen that has a not full grade of trasparency (alpha < 256) I should get that the whole image shows the trasparency effect. In this case it seems that copying the output of a SCREEN 0 let it at screen 0 level! Like I cannot use screen function with graphic text (using Fonts). RE: No warning to mix screen 0 and screen graphic commands! - mnrvovrfc - 06-14-2023 I'm sure you already tried this: https://qb64phoenix.com/qb64wiki/index.php/PRINTMODE But this could be a (Dolores Derriere in fractured French) if you need to erase the letters to write something else over the same field. RE: No warning to mix screen 0 and screen graphic commands! - DSMan195276 - 06-14-2023 I think you're mixing up the behavior of `_SetAlpha` with `Color`. `_SetAlpha` is a command that changes the Current contents of an image at the time you run the command, it does not change anything about what happens to the image after that point, and each pixel of the image has its own alpha value. Thus doing `_SetAlpha 100, 0, S2` only changes the current black pixels to have 100 alpha, it has no impact on any black pixels created after that point (such as the ones from `Print`) and they are free to have any alpha value they want. When you `Print` on a 32-bit image, the entire RGBA values used for the foreground and background colors come from the current `Color` setting, so any existing alpha value for those pixels will be overridden by those RGBA colors. If you try the below code that adds a `Color` line, I believe you get the behavior you're looking for: Code: (Select All) Dim Shared S1 As Long, S2 As Long Alternatively, like mnrvovrfc mentioned using _PrintMode is generally an easier way to do this, it allows you to just simply turn off the background color of `Print` all together. If you do that then your usage of `_SetAlpha` will work like you were expecting because `Print` just won't touch the existing black pixels that already have 100 alpha due to `_SetAlpha`. RE: No warning to mix screen 0 and screen graphic commands! - TempodiBasic - 06-14-2023 (06-14-2023, 02:37 AM)mnrvovrfc Wrote: I'm sure you already tried this:Thnks for you feedback but PRINTMODE is a good guy but as you can see let you have a text background or a text foreground totally transparent. No a fadeness and no both background and foreground togheter transparent /fading. So its goals are not the same that I'm searching. Moreover there is the issue that you said in french language. RE: No warning to mix screen 0 and screen graphic commands! - TempodiBasic - 06-14-2023 @DSman hi thanks for replying 1. _setalpha works on actual image and not to the future changement of it If this is true I can try to set alpha channel the instant before using _putimage and ths must garantee me to get a half transparent image copied. But this code demonstrates that it is not so. Code: (Select All) Dim Shared S1 As Long, S2 As Long ' declaring pointer variables Yes PRINT works only with alpha set to 255, indipendently from alpha setting of the image (screen) on which it works. So you are right I am mixing too much COLOR with _SETALPHA... I must use _RGBA with COLOR to get this fading effect! Text is indipendent from _alpha settings of image! Run the following code Code: (Select All) Dim Shared S1 As Long, S2 As Long ' declaring pointer variables Here Text and its background are fading! Thanks for your helps, so you suggest me what to do to go on! RE: No warning to mix screen 0 and screen graphic commands! - DSMan195276 - 06-14-2023 (06-14-2023, 12:40 PM)TempodiBasic Wrote: If this is true I can try to set alpha channel the instant before using _putimage and ths must garantee me to get a half transparent image copied. But this code demonstrates that it is not so.Ah, there's one more catch that I missed - the color provided to _SetAlpha also has its own alpha value which must match the existing value. IE. You're using 0 as the color, which is black with an alpha 0. Since none of the black pixels currently have an alpha 0 your _SetAlpha command doesn't end up doing anything. What you really want is this: Code: (Select All) _SetAlpha 100, _RGBA32(0, 0, 0, 0) TO _RGBA32(0, 0, 0, 255), S2 RE: No warning to mix screen 0 and screen graphic commands! - TempodiBasic - 06-16-2023 Hi DSman yes using the range of black color we get black color set to 100 alpha channel But we must do the same work on the foreground color of text ( white color) so the complete command is Code: (Select All) _SetAlpha 100, _RGBA32(0, 0, 0, 0) To _RGBA32(0, 0, 0, 255), S2 '<--- setting the second image grade of transparency (more than half transparent) if _SETALPHA works on all the image why does not do this work when we omit a range of color to say all colors into the picture? RE: No warning to mix screen 0 and screen graphic commands! - DSMan195276 - 06-16-2023 (06-16-2023, 01:51 PM)TempodiBasic Wrote: if _SETALPHA works on all the image why does not do this work when we omit a range of color to say all colors into the picture?Well, you never did that You were doing `_SetAlpha 100, 0` which is equivalent to `_SetAlpha 100, _RGBA32(0, 0, 0, 0)`, a specific color value. If you want to set the alpha for every pixel regardless of color I believe you can omit the second argument all together and do `_SetAlpha 100`. Or alternatively with an image, `_SetAlpha 100, , S2`. RE: No warning to mix screen 0 and screen graphic commands! - TempodiBasic - 06-16-2023 (06-16-2023, 03:54 PM)DSMan195276 Wrote:Right! You are right!(06-16-2023, 01:51 PM)TempodiBasic Wrote: if _SETALPHA works on all the image why does not do this work when we omit a range of color to say all colors into the picture?Well, you never did that You were doing `_SetAlpha 100, 0` which is equivalent to `_SetAlpha 100, _RGBA32(0, 0, 0, 0)`, a specific color value. If you want to set the alpha for every pixel regardless of color I believe you can omit the second argument all together and do `_SetAlpha 100`. Or alternatively with an image, `_SetAlpha 100, , S2`. using _setalpha transparency%, , HandleImage& OR _setalpha transparency% we get the same result of fading both for background color both for foreground color. Thank you for more feedback! It appeared me strange that _setalpha did not work on the whole image... there were 2 obstacles 1. _setalpha must be applied just before _putimage 2. the sintax of _setalpha need a comma to distinguish between color and handleimage. |