Borderless Grayscale Images






Hello,

I have succeeded in writing a gtkmm application which displays a grayscale
window using Gdk::Drawable::draw_gray_image( );

I create a class inheriting from Gtk::DrawingArea.

Here is my code ...

***********************************************************************************************

main.cc

#include "myImageDisplay.h"
#include <gtkmm/main.h>
#include <gtkmm/window.h>

int main (int argc, char *argv[])
{
    Gtk::Main kit(argc, argv);

    Gtk::Window win;

    MyImageDisplay myImage;
    win.add(myImage);
    myImage.show();

    Gtk::Main::run(win);

    return 0;
}

myImageDisplay.h

#ifndef GTKMM_MYIMAGEDISPLAY_H
#define GTKMM_MYIMAGEDISPLAY_H

#include <gtkmm/drawingarea.h>
#include <gdkmm/window.h>

class MyImageDisplay : public Gtk::DrawingArea
{
public:
    MyImageDisplay();
    virtual ~MyImageDisplay();

protected:
    //Overridden default signal handlers:
    virtual void on_realize();
    // The redraw event
    virtual bool on_expose_event(GdkEventExpose* event);

    // Area to store image data
    char m_Image[500000];

    // Graphic context
    Glib::RefPtr<Gdk::GC> m_refGC;
};

#endif // GTKMM_MYIMAGEDISPLAY_H


myImageDisplay.cc

#include "myImageDisplay.h"

MyImageDisplay::MyImageDisplay()
{
    int n;

    // Create an image (temporary code)
    for (n=0; n < 320 * 240; n++)
    {
        m_Image[n] = n % 320;
    }
}

MyImageDisplay::~MyImageDisplay()
{

}

// Called when the window is created.  Only now can you get a valid GC for
the window
// This is called only once on startup
void MyImageDisplay::on_realize()
{
    // Must call base version
    Gtk::DrawingArea::on_realize();

    // Get a GC (Graphics Context)
    Glib::RefPtr<Gdk::Window> window = get_window();
    m_refGC = Gdk::GC::create(window);
}

// Expose or paint event - called if part or all of the window needs
updating
bool MyImageDisplay::on_expose_event(GdkEventExpose *event)
{
    Glib::RefPtr<Gdk::Window> window = get_window();
    window->clear();
    window->draw_gray_image(m_refGC, 0, 0, 320, 240,
                            Gdk::RGB_DITHER_NORMAL, (guchar*)m_Image, 320);
    return true;
}

**************************************************************************************


This seems to work nicely.  However, I really want the displayed
window/widget to be borderless (and fullscreen).
I don't want the title, minimize, maximise icons etc.



(Embedded image moved to file: pic22386.jpg)


Is this possible?

Thanks.






*******************Internet Email Confidentiality Footer*******************
The contents of this e-mail message (including any attachments hereto) are
confidential to and are intended to be conveyed for the use of the
recipient to whom it is addressed only. If you receive this transmission in
error, please notify the sender of this immediately and delete the message
from your system. Any distribution, reproduction or use of this message by
someone other than recipient is not authorized and may be unlawful.

Attachment: pic22386.jpg
Description: JPEG image



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]