Page 1 of 1

Grahpics and BMP's???

Posted: Sat Sep 28, 2002 4:38 pm
by gtsphere
if i wanted to draw a BITMAP to the screen for my OS, i know i have to change the page to a graphics mode, but then i'm lost?

could someone explain how to draw abitmap to the screen and all the workings behind it?

and also, how in the world do you make a GUI?? i can't even begin to imagine lol

thanks so much in advance

Re:Grahpics and BMP's???

Posted: Sat Sep 28, 2002 8:11 pm
by Tom
i've had some ( little ) GUI programming experience...

you %100 need ( for easieness ) getimage and putimage functions...

those are functions that get pixels in a box and put pixels

that's all I can help, untill I start programming my GUI

Re:Grahpics and BMP's???

Posted: Sat Sep 28, 2002 9:15 pm
by crazybuddha
gtsphere wrote: if i wanted to draw a BITMAP to the screen for my OS, i know i have to change the page to a graphics mode, but then i'm lost?

could someone explain how to draw abitmap to the screen and all the workings behind it?

and also, how in the world do you make a GUI?? i can't even begin to imagine lol

thanks so much in advance
This is a fairly broad question. The data in a "bitmap" depends on the bit depth of the screen. 8-bit uses index values into a color table with the actual RGB values. 24-bit uses one byte for each of Red-Green-Blue. There's also 16 and 32 bit. Which one to use depends on video mode.

So if you are in mode 13h, you use one byte per pixel on the screen, starting at 0xA000. These are indexes into a default "palette" of colors, which can be changed by programming the video registers. I'm assuming VGA here.

Experiment with drawing boxes and lines in VGA before thinking about GUIs.

Re:Grahpics and BMP's???

Posted: Sat Sep 28, 2002 9:44 pm
by Warmaster199
Hint for GUI: Make clipped-drawing routines... Define a rectangular area and give a rectangle to fill. Only draw the rect in the defined rectangular area...

Re:Grahpics and BMP's???

Posted: Mon Sep 30, 2002 2:06 am
by Pype.Clicker
What is a GUI about ?
- be able to store informations about what is to be redrawn (hm, you don't especially need to have a windowed GUI, at the start ;)
- be able to browse those infos and call the redrawing functions of each component. A smart way to do this is to define a virtual class (widget?) that will have a virtual draw(context) method that will draw the object in the current context. GUIs are often recursive, i.e. a menubar.draw() function will call each menubutton.draw() in order, with a context that is changed (i.e. each button reduces the remaining width) along the list...
- be able to catch user inputs (keyb, mouse, etc.) and dispatch them to the proper object (i.e. the one that has the focus: when a mouse click occurs, follow your GUI infos to find out the object that is under the mouse pointer and then call its virtual function receive_event()
- maybe be able to mask some events (i.e. some objects might not like to receive GUI_DRAGNDROP_EVENT, in this case, try to emit the event to the parent object. If no object can handle the event, just complain (beep, or whatever you like ;)

Note that i've been talking with classes and virtual functions ... encapsulated structures and function pointers basically do the very same job in non-OO languages ... and even in ASM ;-)

Re:Grahpics and BMP's???

Posted: Mon Sep 30, 2002 2:41 am
by Pype.Clicker
you will basically have 2 kind of graphical systems :
- those where the draw/handle code is at the CLIENT side (x-window), which means any operation involves the emission of a request to a remote object (Obj_id = 12345, event = REDRAW) that will be handled by the application which replies with a list of commands sent to the server (SET_PEN black,white), (CLEAR_BOX top_left, bottom_right) (DRAW_HLINE, top, left, right) (DRAW_HLINE bottom, left, right) (VLINE) (VLINE) (SET_FONT arial) (CENTER_TEXT center, "Hello World")

This approach can be heavy and gives poor responsiveness, but it can offer virtually any object you like ;). The other drawback is that it requires a LOT of events if you want to do something that is highly dynamic (each mouse move could need to be reported !)

- those where the object behaviour is known by the server itself, so you just send a construction event (create_text_button (center, arial, "Hello World") and the server will know what it is, how it should be redrawn, how it respond to basic events such as MOUSE_BUTTON_DOWN, FOCUS_LOST, FOCUSED, MOUSE_BUTTON_UP, ... : only a "clicked" event need to be reported to the application ...

Now the major drawback is that the server needs to know EVERY object that you'll have to draw on screen :(. Plug-ins will be your friends around here ...

And now my own idea about how it should work:
the server only knows about METALANGUAGES for widgets definitions. Those languages should be added as plug-in, but they could express a wide range of objects, combining primitives, etc.

for instance you could send at the construction

Code: Select all

object textbutton (
   properties: (string: text; boolean down, focused )
   content: (
       background: fillbox (color <= grey) @center, #expandxy
       corner_a: (
         hline (color<=lightgrey) @north, #expandx
         vline (color<=lightgrey) @east, #expandy
       )
       corner_b: (
         hline (color<=darkgrey) @south, #expandx
         vline (color<=darkgrey) @west, #expandy
       )
       txt: flattext (str<=text, color<=black) @center
   )
   on GET_FOCUS: background.color<=grey80;
   on MOUSE_DOWN: do {
      corner_a.color<=darkgrey;
      corner_b.color<=lightgrey;
      down=true;
   }
   on MOUSE_UP: do {
       corner_a.color<=lightgrey;
       corner_b.color<=darkgrey;
       down=false;
       if (focused) emit "clicked";
   }
   on GET_FOCUS: if (down) do {
       // colors = down colors.
       focused = true;
   }
   on FOCUS_LOST: if (down) do {
       // colors = up colors.
       focused = false;
   }
)

a small system in the display server could compile this into a small description (bytecoded ?) of what is to be repainted and actions to be carried out when something occurs (basically maths expressions, affectations to local state and event emissions). This is done only once when the object is described. then when the FOCUS_LOST event is received, the server only finds back the executor for that object (GUiDL virtual machines) which will execute some small bytecode (draw_lines with the proper color, set a new value to *focused* local variable) and we're done.


Re:Grahpics and BMP's???

Posted: Tue Oct 01, 2002 8:23 am
by ups
If you want to write an GUI OS, read docs on the Windows GDI. You'll get a feeling how it works. ;)