initial cjeck in of wxWdigets image test dir
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Fri, 19 Oct 2012 04:50:43 +0000 (04:50 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Fri, 19 Oct 2012 04:50:43 +0000 (04:50 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@777 01035d8c-6547-0410-b346-abe4f91aad63

fdmdv2/tests/image/Makefile [new file with mode: 0644]
fdmdv2/tests/image/README.txt [new file with mode: 0644]
fdmdv2/tests/image/image.cpp [new file with mode: 0644]

diff --git a/fdmdv2/tests/image/Makefile b/fdmdv2/tests/image/Makefile
new file mode 100644 (file)
index 0000000..b6926b0
--- /dev/null
@@ -0,0 +1,16 @@
+WX_GTK_PATH=/home/david/Desktop/wxWidgets-2.9.4/build_gtk
+
+WX_CONFIG=$(WX_GTK_PATH)/wx-config
+WX_CPPFLAGS = $(shell $(WX_CONFIG) --cxxflags)
+WX_LIBS = $(shell $(WX_CONFIG) --libs core, base, aui)
+
+CPP_FLAGS = $(WX_CPPFLAGS) -g -Wall
+LIBS = $(WX_LIBS)  -lm -lportaudiocpp -lpthread 
+
+all: image
+
+image: image.cpp
+       g++ -o image image.cpp  $(CPP_FLAGS) $(LIBS)
+
+clean:
+       rm -f *.o image
diff --git a/fdmdv2/tests/image/README.txt b/fdmdv2/tests/image/README.txt
new file mode 100644 (file)
index 0000000..3818632
--- /dev/null
@@ -0,0 +1,2 @@
+David Rowe 19 October 2012
+Test directory to experiment with wxWidgets bit mapped image functions.
diff --git a/fdmdv2/tests/image/image.cpp b/fdmdv2/tests/image/image.cpp
new file mode 100644 (file)
index 0000000..3364211
--- /dev/null
@@ -0,0 +1,142 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        samples/image/image.cpp
+// Purpose:     sample showing operations with wxImage
+// Author:      Robert Roebling
+// Modified by: Francesco Montorsi
+// Created:     1998
+// RCS-ID:      $Id$
+// Copyright:   (c) 1998-2005 Robert Roebling
+//              (c) 2005-2009 Vadim Zeitlin
+// Licence:     wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+
+#include "wx/wx.h"
+#include "wx/image.h"
+#include "wx/file.h"
+#include "wx/filename.h"
+#include "wx/graphics.h"
+#include "wx/mstream.h"
+#include "wx/wfstream.h"
+#include "wx/quantize.h"
+#include "wx/scopedptr.h"
+#include "wx/stopwatch.h"
+#include "wx/versioninfo.h"
+#include "wx/rawbmp.h"
+
+
+//-----------------------------------------------------------------------------
+// MyApp
+//-----------------------------------------------------------------------------
+
+class MyApp: public wxApp
+{
+public:
+    virtual bool OnInit();
+};
+
+class MyRawBitmapFrame : public wxFrame
+{
+public:
+    enum
+    {
+        BORDER = 15,
+        SIZE = 150,
+        REAL_SIZE = SIZE - 2*BORDER
+    };
+
+    /*
+    MyRawBitmapFrame(wxFrame *parent)
+        : wxFrame(parent, wxID_ANY, wxT("Raw bitmaps (how exciting)")),
+        m_bitmap(SIZE, SIZE, 24),
+        m_alphaBitmap(SIZE, SIZE, 32)
+    */
+
+    MyRawBitmapFrame(): wxFrame( (wxFrame *)NULL, wxID_ANY, wxT("wxImage sample"),
+                               wxPoint(20, 20), wxSize(950, 700) ),
+                      m_bitmap(SIZE, SIZE, 24)
+    {
+        SetClientSize(SIZE, SIZE*2+25);
+
+        InitBitmap();
+
+    }
+
+    void InitBitmap()
+    {
+        // draw some colourful stripes without alpha
+        wxNativePixelData data(m_bitmap);
+        if ( !data )
+        {
+            wxLogError(wxT("Failed to gain raw access to bitmap data"));
+            return;
+        }
+
+        wxNativePixelData::Iterator p(data);
+        for ( int y = 0; y < SIZE; ++y )
+        {
+            wxNativePixelData::Iterator rowStart = p;
+
+            int r = y < SIZE/3 ? 255 : 0,
+                g = (SIZE/3 <= y) && (y < 2*(SIZE/3)) ? 255 : 0,
+                b = 2*(SIZE/3) <= y ? 255 : 0;
+
+            for ( int x = 0; x < SIZE; ++x )
+            {
+                p.Red() = r;
+                p.Green() = g;
+                p.Blue() = b;
+                ++p; // same as p.OffsetX(1)
+            }
+
+            p = rowStart;
+            p.OffsetY(data, 1);
+        }
+    }
+
+    void OnPaint(wxPaintEvent& WXUNUSED(event))
+    {
+        wxPaintDC dc( this );
+        dc.DrawText(wxT("This is alpha and raw bitmap test"), 0, BORDER);
+        dc.DrawText(wxT("This is alpha and raw bitmap test"), 0, SIZE/2 - BORDER);
+        dc.DrawText(wxT("This is alpha and raw bitmap test"), 0, SIZE - 2*BORDER);
+
+        dc.DrawText(wxT("Raw bitmap access without alpha"), 0, SIZE+5);
+        dc.DrawBitmap( m_bitmap, 0, SIZE+5+dc.GetCharHeight());
+    }
+
+private:
+    wxBitmap m_bitmap;
+
+    DECLARE_EVENT_TABLE()
+};
+
+
+//-----------------------------------------------------------------------------
+// MyRawBitmapFrame
+//-----------------------------------------------------------------------------
+
+
+BEGIN_EVENT_TABLE(MyRawBitmapFrame, wxFrame)
+    EVT_PAINT(MyRawBitmapFrame::OnPaint)
+END_EVENT_TABLE()
+
+
+//-----------------------------------------------------------------------------
+// MyApp
+//-----------------------------------------------------------------------------
+
+IMPLEMENT_APP(MyApp)
+
+bool MyApp::OnInit()
+{
+    if ( !wxApp::OnInit() )
+        return false;
+
+    wxInitAllImageHandlers();
+
+    wxFrame *frame = new MyRawBitmapFrame();
+    frame->Show( true );
+
+    return true;
+}