mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-09-04 17:15:23 -06:00
changed svn layout
git-svn-id: svn://ultimatepp.org/upp/trunk@281 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
commit
263ff5f895
2665 changed files with 642923 additions and 0 deletions
58
tutorial/Image03/main.cpp
Normal file
58
tutorial/Image03/main.cpp
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
#include <CtrlLib/CtrlLib.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
struct MyApp : public TopWindow {
|
||||
Image img;
|
||||
|
||||
virtual void Paint(Draw& w);
|
||||
virtual void LeftDown(Point p, dword keyflags);
|
||||
|
||||
typedef MyApp CLASSNAME;
|
||||
MyApp();
|
||||
};
|
||||
|
||||
MyApp::MyApp()
|
||||
{
|
||||
ImageBuffer ib(50, 50);
|
||||
for(int y = 0; y < 50; y++) {
|
||||
RGBA *l = ib[y];
|
||||
for(int x = 0; x < 50; x++) {
|
||||
if(y == 0 || y == 49 || x == 0 || x == 49)
|
||||
*l++ = Black();
|
||||
else {
|
||||
l->a = 2 * (x + y);
|
||||
l->r = 4 * x;
|
||||
l->g = 4 * y;
|
||||
l->b = 200;
|
||||
l++;
|
||||
}
|
||||
}
|
||||
}
|
||||
Premultiply(ib);
|
||||
img = ib;
|
||||
}
|
||||
|
||||
void MyApp::Paint(Draw& w)
|
||||
{
|
||||
w.DrawRect(GetSize(), White);
|
||||
w.DrawImage(10, 5, img);
|
||||
w.DrawImage(40, 25, img);
|
||||
}
|
||||
|
||||
void MyApp::LeftDown(Point p, dword keyflags)
|
||||
{
|
||||
ImageBuffer ib(img);
|
||||
for(int y = 15; y < 35; y++) {
|
||||
RGBA *l = ib[y];
|
||||
for(int x = 15; x < 35; x++)
|
||||
l[x] = 100 * Red();
|
||||
}
|
||||
img = ib;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
GUI_APP_MAIN
|
||||
{
|
||||
MyApp().Sizeable().Run();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue