[Solved] put pixel to get pixel and gui scroll

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: put pixel to get pixel and gui scroll

Post 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.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
shmx
Member
Member
Posts: 68
Joined: Sat Jan 16, 2016 10:43 am

Re: put pixel to get pixel and gui scroll

Post 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.
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: put pixel to get pixel and gui scroll

Post 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.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
shmx
Member
Member
Posts: 68
Joined: Sat Jan 16, 2016 10:43 am

Re: put pixel to get pixel and gui scroll

Post 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.
shmx
Member
Member
Posts: 68
Joined: Sat Jan 16, 2016 10:43 am

Re: put pixel to get pixel and gui scroll

Post 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];
}
???
shmx
Member
Member
Posts: 68
Joined: Sat Jan 16, 2016 10:43 am

Re: put pixel to get pixel and gui scroll

Post 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).
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: put pixel to get pixel and gui scroll

Post 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.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: put pixel to get pixel and gui scroll

Post 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.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: put pixel to get pixel and gui scroll

Post by Octacone »

No hope. This is just impossible to solve. :(
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
max
Member
Member
Posts: 616
Joined: Mon Mar 05, 2012 11:23 am
Libera.chat IRC: maxdev
Location: Germany
Contact:

Re: put pixel to get pixel and gui scroll

Post by max »

Hey, please don't create a new post everytime you want to add something. Edit your previous post.
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: put pixel to get pixel and gui scroll

Post 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?
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
Ch4ozz
Member
Member
Posts: 170
Joined: Mon Jul 18, 2016 2:46 pm
Libera.chat IRC: esi

Re: put pixel to get pixel and gui scroll

Post 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)
Last edited by Ch4ozz on Thu Aug 25, 2016 1:30 pm, edited 1 time in total.
User avatar
deleted
Member
Member
Posts: 82
Joined: Mon Jul 21, 2014 7:23 pm

Re: put pixel to get pixel and gui scroll

Post 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
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: put pixel to get pixel and gui scroll

Post 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
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
shmx
Member
Member
Posts: 68
Joined: Sat Jan 16, 2016 10:43 am

Re: put pixel to get pixel and gui scroll

Post by shmx »

octacone wrote:That is unsigned long right?
VideoMemory = my linear frame buffer
Yes.
Post Reply