Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER for Video Editing/Mangling

Reply
 
Thread Tools Display Modes
Old 02-17-2023, 03:09 PM   #1
Fabian
Human being with feelings
 
Fabian's Avatar
 
Join Date: Sep 2008
Location: Sweden
Posts: 7,416
Default gfx_getpixel returns wrong values, or what...?

Trying to track down an issue, I wrote the following experimental video processor code:
Code:
colorspace = 'RGBA';
myimg = gfx_img_alloc(project_w, project_h, 1);
gfx_dest = myimg; // from now on draw here
y = 0;
while (y < project_h)
(  x = 0;
   while (x < project_w)
   (
      res = gfx_getpixel(0, x, y, r, g, b); // get from input, returns 1
      gfx_set(r, g, b);
      gfx_fillrect(x, y, 1, 1); // draw 1x1 rect (a pixel) on myimg

      x += 1;
   );
   y += 1;
);
gfx_dest = -1;
gfx_blit(myimg); // blit to framebuffer
gfx_img_free(myimg);
I expected this to simply copy the input to myimg, by replicating each pixel as a 1x1 dimensional rectangle. But what I get is something that vaguely looks like the input, but the colors are all wrong, mostly white.

I've tried with the full parameter list of both gfx_getpixel and gfx_set, but that did not change anything.
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
Fabian is offline   Reply With Quote
Old 02-17-2023, 03:33 PM   #2
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

I'll not be of much help, but maybe I can ask some questions to exclude stuff.

Did you use the code as trackfx or takefx?
Are there multiple videosources(like different tracks) or is it only one video in the project?
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 02-17-2023, 03:43 PM   #3
Fabian
Human being with feelings
 
Fabian's Avatar
 
Join Date: Sep 2008
Location: Sweden
Posts: 7,416
Default

Quote:
Originally Posted by Meo-Ada Mespotine View Post
I'll not be of much help, but maybe I can ask some questions to exclude stuff.

Did you use the code as trackfx or takefx?
Are there multiple videosources(like different tracks) or is it only one video in the project?
Yeah, good points. Thanks.

Video processor as track FX. And it is the only FX on the only track in the whole project; there's just a single video source on this single track.

The "video" was a png, but I just now tried it with a gif, same result (actually worse, now I get not the slightest resemblance to the original, only white).
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
Fabian is offline   Reply With Quote
Old 02-17-2023, 04:37 PM   #4
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

You could try to put the rgb-values into a gmem and check with a gfx-reascript, whether the values are all white or even try to draw them in a gfx-window.
That way you could see, whether getpixel is the culprit or fillrect.

If it's all white, then its really getpixel. If it's drawn correctly, it's something else.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 02-17-2023, 04:50 PM   #5
papagirafe
Human being with feelings
 
papagirafe's Avatar
 
Join Date: Aug 2020
Location: Brasil
Posts: 679
Default

Quote:
Originally Posted by Fabian View Post
Trying to track down an issue, I wrote the following experimental video processor code:
Code:
<snip>
      res = gfx_getpixel(0, x, y, r, g, b); // get from input, returns 1
      gfx_set(r, g, b);
<snip>
I expected this to simply copy the input to myimg, by replicating each pixel as a 1x1 dimensional rectangle. But what I get is something that vaguely looks like the input, but the colors are all wrong, mostly white.

I've tried with the full parameter list of both gfx_getpixel and gfx_set, but that did not change anything.
Been through this one! getpixel() returns values in range 0-255 and gfx_set work with 0-1 range so you need to divide by 255.
papagirafe is offline   Reply With Quote
Old 02-18-2023, 11:32 AM   #6
Fabian
Human being with feelings
 
Fabian's Avatar
 
Join Date: Sep 2008
Location: Sweden
Posts: 7,416
Default

Quote:
Originally Posted by papagirafe View Post
Been through this one! getpixel() returns values in range 0-255 and gfx_set work with 0-1 range so you need to divide by 255.
Ouch! Thanks.

@Mespo: Could you maybe document this in your video processor documentation? Please.

@Papa: This is then an issue also with the Rutt Etra code
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...

Last edited by Fabian; 02-18-2023 at 11:55 AM.
Fabian is offline   Reply With Quote
Old 02-19-2023, 06:23 AM   #7
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Will do 🙂
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 02-19-2023, 07:36 AM   #8
papagirafe
Human being with feelings
 
papagirafe's Avatar
 
Join Date: Aug 2020
Location: Brasil
Posts: 679
Default

Quote:
Originally Posted by Fabian View Post
Ouch! Thanks.

@Mespo: Could you maybe document this in your video processor documentation? Please.

@Papa: This is then an issue also with the Rutt Etra code
Ok let's follow up on the Rutt Etra..

@mespo: I haven't forgotten about writing a guide to the video processor but it's closely linked to the release of my Girafx lib that will requires a guide that covers the same concepts...
papagirafe is offline   Reply With Quote
Old 02-22-2023, 03:55 PM   #9
papagirafe
Human being with feelings
 
papagirafe's Avatar
 
Join Date: Aug 2020
Location: Brasil
Posts: 679
Default

Quote:
Originally Posted by Meo-Ada Mespotine View Post
You could try to put the rgb-values into a gmem and check with a gfx-reascript, whether the values are all white or even try to draw them in a gfx-window.
That way you could see, whether getpixel is the culprit or fillrect.

If it's all white, then its really getpixel. If it's drawn correctly, it's something else.
Just a reminder that I wrote a "JS:vp debug console" a few months ago fo this purpose that works suprisingly well. Here is the reference post: https://forum.cockos.com/showthread.php?p=2538731
papagirafe is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 08:06 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.