Re: put pixel to get pixel and gui scroll
Posted: Thu Aug 25, 2016 11:54 am
How is it simple and why do you keep referring to the text. Remember in this case: text = just pixels.shmx wrote:If only the text, then it is very simple.
The Place to Start for Operating System Developers
http://f.osdev.org/
How is it simple and why do you keep referring to the text. Remember in this case: text = just pixels.shmx wrote:If only the text, then it is very simple.
It is simply copying memory. I do not understand what could be the problem.octacone wrote:The problem is: getting pixels from selected region.
I only know how to put pixels using:shmx wrote:It is simply copying memory. I do not understand what could be the problem.octacone wrote:The problem is: getting pixels from selected region.
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;
If "just pixels" then you need a lot of memory for the scroll. I do not see the point.octacone wrote:How is it simple and why do you keep referring to the text. Remember in this case: text = just pixels.
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];
}
It is an inefficient way.octacone wrote:I don't know how to get specific pixels from wanted location.
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)
shmx wrote:It is an inefficient way.octacone wrote:I don't know how to get specific pixels from wanted location.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).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)
Why DWORD? That is unsigned long right?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]; }
I know. Just trying to bring some attention over here.max wrote:Hey, please don't create a new post everytime you want to add something. Edit your previous post.
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)octacone wrote:I know. Just trying to bring some attention over here.max wrote:Hey, please don't create a new post everytime you want to add something. Edit your previous post.
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?
for(i = center_y; i < center_y + new_h; i++)Ch4ozz wrote: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)octacone wrote:I know. Just trying to bring some attention over here.max wrote:Hey, please don't create a new post everytime you want to add something. Edit your previous post.
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-read my post and think about your answer (which makes no sense because your buffer is a linear frame buffer exactly like mine)
Yes.octacone wrote:That is unsigned long right?
VideoMemory = my linear frame buffer