Page 2 of 3

Re: put pixel to get pixel and gui scroll

Posted: Thu Aug 25, 2016 11:54 am
by Octacone
shmx wrote:If only the text, then it is very simple.
How is it simple and why do you keep referring to the text. Remember in this case: text = just pixels.

Re: put pixel to get pixel and gui scroll

Posted: Thu Aug 25, 2016 12:06 pm
by shmx
octacone wrote:The problem is: getting pixels from selected region.
It is simply copying memory. I do not understand what could be the problem.

Re: put pixel to get pixel and gui scroll

Posted: Thu Aug 25, 2016 12:08 pm
by Octacone
shmx wrote:
octacone wrote:The problem is: getting pixels from selected region.
It is simply copying memory. I do not understand what could be the problem.
I only know how to put pixels using:

Code: Select all

unsigned location = (position.Y * screenWidthBGA * 4) + (position.X * 4);
	linearFrameBufferBGA[location + 0] = 0;
	linearFrameBufferBGA[location + 2] = color.R;
	linearFrameBufferBGA[location + 1] = color.G;
	linearFrameBufferBGA[location + 0] = color.B;
I don't know how to get specific pixels from wanted location.

Re: put pixel to get pixel and gui scroll

Posted: Thu Aug 25, 2016 12:13 pm
by shmx
octacone wrote:How is it simple and why do you keep referring to the text. Remember in this case: text = just pixels.
If "just pixels" then you need a lot of memory for the scroll. I do not see the point.

Re: put pixel to get pixel and gui scroll

Posted: Thu Aug 25, 2016 12:16 pm
by shmx
octacone wrote:I don't know how to get specific pixels from wanted location.

Code: Select all

DWORD GetPixel32(int X, int Y)
{
     DWORD *v_mem = (DWORD *)VideoMemory;
     return v_mem[X + Y * ScreenPithInPixels];
}
???

Re: put pixel to get pixel and gui scroll

Posted: Thu Aug 25, 2016 12:23 pm
by shmx
octacone wrote:I don't know how to get specific pixels from wanted location.
It is an inefficient way.

Code: Select all

DWORD SetPixel32(int X, int Y, DWORD Color)
{
     DWORD *v_mem = (DWORD *)VideoMemory;
    v_mem[X + Y * ScreenPithInPixels] = Color;
}
#define MAKE_RGB(r, g, b) ( ( ((DWORD)r) << 16 ) | ( ((DWORD)g) << 8 ) |  ( ((DWORD)b) << 0 ) )
#define GET_R(color) ( (color >> 16) & 0xFF)
#define GET_G(color) ( (color >> 8) & 0xFF)
#define GET_B(color) ( (color >> 0) & 0xFF)
But it is better to avoid the functions (get)setpixel. This is just an example of work with video memory. It is better to draw the primitives directly (it is a bit more complicated).

Re: put pixel to get pixel and gui scroll

Posted: Thu Aug 25, 2016 1:05 pm
by Octacone
shmx wrote:
octacone wrote:I don't know how to get specific pixels from wanted location.
It is an inefficient way.

Code: Select all

DWORD SetPixel32(int X, int Y, DWORD Color)
{
     DWORD *v_mem = (DWORD *)VideoMemory;
    v_mem[X + Y * ScreenPithInPixels] = Color;
}
#define MAKE_RGB(r, g, b) ( ( ((DWORD)r) << 16 ) | ( ((DWORD)g) << 8 ) |  ( ((DWORD)b) << 0 ) )
#define GET_R(color) ( (color >> 16) & 0xFF)
#define GET_G(color) ( (color >> 8) & 0xFF)
#define GET_B(color) ( (color >> 0) & 0xFF)
But it is better to avoid the functions (get)setpixel. This is just an example of work with video memory. It is better to draw the primitives directly (it is a bit more complicated).

I can plot pixels that is not a problem. I have my own way of doing it. Also I have my own Color structure that is RGB.

Re: put pixel to get pixel and gui scroll

Posted: Thu Aug 25, 2016 1:07 pm
by Octacone
shmx wrote:
octacone wrote:I don't know how to get specific pixels from wanted location.

Code: Select all

DWORD GetPixel32(int X, int Y)
{
     DWORD *v_mem = (DWORD *)VideoMemory;
     return v_mem[X + Y * ScreenPithInPixels];
}
???
Why DWORD? That is unsigned long right?
VideoMemory = my linear frame buffer
I will try that.

Re: put pixel to get pixel and gui scroll

Posted: Thu Aug 25, 2016 1:10 pm
by Octacone
No hope. This is just impossible to solve. :(

Re: put pixel to get pixel and gui scroll

Posted: Thu Aug 25, 2016 1:11 pm
by max
Hey, please don't create a new post everytime you want to add something. Edit your previous post.

Re: put pixel to get pixel and gui scroll

Posted: Thu Aug 25, 2016 1:21 pm
by Octacone
max wrote:Hey, please don't create a new post everytime you want to add something. Edit your previous post.
I know. Just trying to bring some attention over here.

Okay lets make it simple:
How do I capture 1600x900x32 area of pixels, save those pixels to a buffer and shift their y coordinate by wanted amount?

Re: put pixel to get pixel and gui scroll

Posted: Thu Aug 25, 2016 1:29 pm
by Ch4ozz
octacone wrote:
max wrote:Hey, please don't create a new post everytime you want to add something. Edit your previous post.
I know. Just trying to bring some attention over here.

Okay lets make it simple:
How do I capture 1600x900x32 area of pixels, save those pixels to a buffer and shift their y coordinate by wanted amount?
I already gave you the complete memcpy 2 liner in my previous post which solves your problem (even though you should REALLY save the text AND the pixels in 2 different buffers so you can REDRAW text INSTEAD of copying pixels)
Re-read my post and think about your answer (which makes no sense because your buffer is a linear frame buffer exactly like mine)

Re: put pixel to get pixel and gui scroll

Posted: Thu Aug 25, 2016 1:30 pm
by deleted
Hi,

I'm not experienced with graphics programming yet, my OS is still in a text-mode phase However, the concept is rather similar.

What you need to do (as others in this thread have said) is copy the data containing the previous line up one line. This should be pretty simple. Just find the height of a line of text in pixels, then use a loop to copy all the data up by one height unit, then clear the bottom line.

Cheers,
Walt

Re: put pixel to get pixel and gui scroll

Posted: Thu Aug 25, 2016 1:36 pm
by Octacone
Ch4ozz wrote:
octacone wrote:
max wrote:Hey, please don't create a new post everytime you want to add something. Edit your previous post.
I know. Just trying to bring some attention over here.

Okay lets make it simple:
How do I capture 1600x900x32 area of pixels, save those pixels to a buffer and shift their y coordinate by wanted amount?
I already gave you the complete memcpy 2 liner in my previous post which solves your problem (even though you should REALLY save the text AND the pixels in 2 different buffers so you can REDRAW text INSTEAD of copying pixels)
Re-read my post and think about your answer (which makes no sense because your buffer is a linear frame buffer exactly like mine)
for(i = center_y; i < center_y + new_h; i++)
blit(ctrl.buffer + (i*w*width + center_x*width), img_scaled->data + (i-center_y)*img_scaled->width*width + offset_x*width + offset_y*img_scaled->width*width, new_w*width);

It will take me some time to decode that.
Is there a way to make it compatible with this:
linearFrameBufferBGA --my main frame buffer
screenWidthBGA --self exp.
screenHeightBGA --self exp.
screenDepthBGA -- self exp. == 4 in this case because it gets multiplied by 8 inside of BGA initialization sequence
I guess that img_scaled->data is my second non existing framebuffer

I really need to chill. :o

Re: put pixel to get pixel and gui scroll

Posted: Thu Aug 25, 2016 2:14 pm
by shmx
octacone wrote:That is unsigned long right?
VideoMemory = my linear frame buffer
Yes.