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.
[Solved] put pixel to get pixel and gui scroll
Re: put pixel to get pixel and gui scroll
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
Re: put pixel to get pixel and gui scroll
It is simply copying memory. I do not understand what could be the problem.octacone wrote:The problem is: getting pixels from selected region.
Re: put pixel to get pixel and gui scroll
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;
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
Re: put pixel to get pixel and gui scroll
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.
Re: put pixel to get pixel and gui scroll
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
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)
Re: put pixel to get pixel and gui scroll
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)
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
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
Re: put pixel to get pixel and gui scroll
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]; }
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
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
Re: put pixel to get pixel and gui scroll
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
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
- max
- 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
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
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?
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
Re: put pixel to get pixel and gui scroll
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)
Last edited by Ch4ozz on Thu Aug 25, 2016 1:30 pm, edited 1 time in total.
Re: put pixel to get pixel and gui scroll
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
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
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)
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.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
Re: put pixel to get pixel and gui scroll
Yes.octacone wrote:That is unsigned long right?
VideoMemory = my linear frame buffer