DAS  3.1.6 - 18/09/2017
D_Zoom.c
Go to the documentation of this file.
1 #include <windows.h>
2 #include <stdio.h>
3 #include <math.h>
4 #include "mgui.h"
5 #include "bil.h"
6 #include "DAS_Spatram.h"
7 
8 
17 
18 unsigned int Maxx;
19 void D_DoLens(MIMAGE lensmim, MOBJECT lensdraw, int lenswx,
20  int lenswy, int lenspix, int sx, int sy);
21 void D_LensZoom(MOBJECT o, MVALUE o_data, void *a_data);
22 void D_To_DoLens(void);
23 void D_LensResizeCB(MOBJECT obj, DRAWAREA_PREF *pref, void *ad);
24 void D_LensCloseCB(MOBJECT p, void *od, void *ad);
25 void D_Lens(void);
26 
27 
28 /********************************************************/
29 void D_DoLens(MIMAGE lensmim, MOBJECT lensdraw, int lenswx, int lenswy, int lenspix, int sx, int sy)
30 {
31 
32  int l, h, p, d, md, x, y, wx, wy, ox, oy, px, py;
33  double dd;
34  int dred, dgreen, dblu;
35  sx++; sy++;
36  wx = lenswx / lenspix;
37  wy = lenswy / lenspix;
38  h= BIL.DPLOT.Imax;
39  l= BIL.DPLOT.Imin;
40 
41  p = lenspix;
42  d = h - l;
43  dd = d /= 256;
44  // If less then 256 levels
45  // inc range
46  if(d == 0)
47  {
48  md = 1;
49  dd = (double) (h - l) / 256.0;
50  if(dd == 0)
51  {
52  md = 0;
53  dd = d = 1;
54  }
55  }
56  for(y = sy - wy / 2; y < sy + wy / 2; y++)
57  {
58 
59 
60 // ma = &DPLOT.Graf[(long) y * maxplotw];
61 
62  for(x = sx - wx / 2; x < sx + wx / 2; x++)
63  {
64  if(x >= 0 && x < maxplotw && y >= 0 && y < maxploth)
65  {
66  MImageGetPixelRGB(BIL.BLENS.Imim, x, y, &dred, &dgreen, &dblu);
67  }
68  ox = (long) (x - (sx - wx / 2)) * p;
69  oy = (long) (y - (sy - wy / 2)) * p;
70  for(py = 0; py < p; py++)
71  for(px = 0; px < p; px++)
72  MImageSetPixelRGB(lensmim, ox + px, oy + py, dred, dgreen, dblu);
73  }
74  }
75 
76  MInstallImage(lensmim);
77  MDrawImage(lensdraw, lensmim, 0, 0, wx * p, wy * p, 0, 0);
78  MUninstallImage(lensmim);
79 
80  sx = wx / 2 * p - p;
81  sy = wy / 2 * p - p;
82  MDrawBox(lensdraw, wx / 2 * p - p, wy / 2 * p - p, p, p, MTCL.blue);
83 
84  // Y line
85  MDrawLine(lensdraw, sx + p / 2, sy - 30, sx + p / 2, sy, MTCL.blue);
86  MDrawLine(lensdraw, sx + p / 2, sy + p, sx + p / 2, sy + 30 + p, MTCL.blue);
87 
88  // X Line
89  MDrawLine(lensdraw, sx - 30, sy + p / 2, sx, sy + p / 2, MTCL.blue);
90  MDrawLine(lensdraw, sx + p + 30, sy + p / 2, sx + p, sy + p / 2, MTCL.blue);
91 
92 }
93 
94 void D_LensZoom(MOBJECT o, MVALUE o_data, void *a_data)
95 {
96  int l = (int) o_data, w = (int) a_data;
97  char buf[16];
98 
99  if(l < 2) l = 2;
100  BIL.BLENS.LensPix = l;
101  sprintf(buf, "DanBo ZOOM = %d", BIL.BLENS.LensPix);
102 
105 
106  //MObjectSetText(LensLbl, buf);
107 // MShellSetTitle(BIL.BLENS.LensShell, buf);
109 
110 }
111 void D_To_DoLens(void)
112 {
114 }
115 void D_LensResizeCB(MOBJECT obj, DRAWAREA_PREF *pref, void *ad)
116 {
117 
118  BIL.BLENS.LensWx = pref->new_w;
119  BIL.BLENS.LensWy = pref->new_h;
120 
123 
127 
128 }
129 void D_LensCloseCB(MOBJECT p, void *od, void *ad)
130 {
131  MShellUnrealize(p);
132  MShellDestroy(p);
133  BIL.BLENS.LensON = 0;
135 
136 }
137 
138 void D_Lens(void)
139 {
140  MOBJECT a, b, lbl, sb;
141  MTFont newfont;
142 
143  newfont = HELV_SMALL; //MLoadFont("Times", 16, False, False);
144 
145  if(BIL.BLENS.LensON)
146  {
148  return;
149  }
150 
152  MObjectSetBackgroundRGB(LensShell, 64, 68, 72);
153 
155  MObjectSetShadow(a, WS_NONE, 0, 0);
156  MObjectSetBackgroundRGB(a, 128, 128, 128);
157 
158  Maxx = MGetScreenWidth();
159  BIL.BLENS.LensWx = Maxx / 4;
160 
161  BIL.BLENS.LensPix = 2;
162 
164 
167 
171 
172  b = MCreateColForm(a);
173  MObjectSetBackgroundRGB(b, 184, 132, 0);
174 
175  lbl = MCreateLabel(b, "X:", newfont);
176  MObjectSetBackgroundRGB(lbl, 255,255,255);
177  MObjectSetResize(lbl, False, True);
178 // MObjectSetForegroundRGB(lbl, );
179 
180  BIL.BLENS.LensLblX = MCreateLabel(b, " 0000 ", newfont);
183 // MObjectSetForegroundRGB(LensLblX, );
184 
185  lbl = MCreateLabel(b, "Y:", newfont);
186  MObjectSetBackgroundRGB(lbl, 255,255,255);
187 // MObjectSetForegroundRGB(lbl, );
188  BIL.BLENS.LensLblY = MCreateLabel(b, "0000", newfont);
190 // MObjectSetForegroundRGB(LensLblY, );
191 
192  BIL.BLENS.LensLbl = MCreateLabel(b, "ZOOM = 2", newfont);
195 
196 
197  b = MCreateColForm(a);
198 // MObjectSetBackgroundRGB(b, );
199 
200  sb = MCreateScrollBar(a, SBT_HOR, 0, MAXZOOM);
201  MScrollBarSetPos(sb, 0);
202  MScrollBarSetPosCallback(sb, D_LensZoom, (void *) 0);
203  MObjectSetBackgroundRGB(sb, 184, 132, 0);
204 // MObjectSetForegroundRGB(sb, );
205 
208  BIL.BLENS.LensON = 1;
209 }
mtcl MTCL
Definition: 2DPlot.c:30
MTFont newfont
Definition: CreateForms.c:95
void MObjectSetBackgroundRGB(MOBJECT obj, int r, int g, int b)
unsigned int LocX
Definition: bildef.h:15
#define WS_NONE
Definition: Mguidefs.h:956
MIMAGE Imim
Definition: bildef.h:14
unsigned int Maxx
Definition: D_Zoom.c:18
MOBJECT lbl
Definition: DFileMan.c:42
INT32 MVALUE
Definition: Mguidefs.h:1422
MIMAGE LensMim
Definition: bildef.h:12
void MObjectSetShadow(MOBJECT obj, int type, int in, int out)
MTColor blue
void MShellRealize(MOBJECT obj)
#define SF_NO_MAXIMIZE
Definition: Mguidefs.h:1034
void MDrawLine(MOBJECT p, int x1, int y1, int x2, int y2, MTColor col)
MOBJECT LensLblY
Definition: bildef.h:11
unsigned int Imax
Definition: bildef.h:177
int LensPix
Definition: bildef.h:9
MOBJECT MCreateLabel(MOBJECT parent, const char *text, MTFont font)
void MObjectSetResize(MOBJECT obj, int resize_w, int resize_h)
#define False
Definition: Mguidefs.h:236
void D_LensZoom(MOBJECT o, MVALUE o_data, void *a_data)
Definition: D_Zoom.c:94
#define SF_NO_MINIMIZE
Definition: Mguidefs.h:1036
void MDrawAreaSetResizeCallback(MOBJECT obj, DRAWAREA_PREF_CB cb, void *ad)
void MShellUnrealize(MOBJECT obj)
unsigned int Imin
Definition: bildef.h:178
MOBJECT LensShell
Definition: D_Zoom.c:16
void MShellDestroy(MOBJECT obj)
void D_LensResizeCB(MOBJECT obj, DRAWAREA_PREF *pref, void *ad)
Definition: D_Zoom.c:115
void D_DoLens(MIMAGE lensmim, MOBJECT lensdraw, int lenswx, int lenswy, int lenspix, int sx, int sy)
Definition: D_Zoom.c:29
void D_LensCloseCB(MOBJECT p, void *od, void *ad)
Definition: D_Zoom.c:129
d_view DPLOT
Definition: bildef.h:254
DrawArea Object&#39;s resize data.
Definition: Mguidefs.h:1122
#define HELV_SMALL
Definition: Mguidefs.h:881
unsigned char LensON
Definition: bildef.h:8
MOBJECT MCreateScrollBar(MOBJECT parent, int type, long n, long max)
void MImageSetPixelRGB(MIMAGE pmi, int x, int y, int r, int g, int b)
int MTFont
Definition: Mguidefs.h:175
void MScrollBarSetPos(MOBJECT p, long pos)
void MDrawBox(MOBJECT p, int x, int y, int w, int h, MTColor bgc)
#define SBT_HOR
Definition: Mguidefs.h:1139
Image description.
Definition: Mguidefs.h:436
void(* OBJ_EVENT_CB)(MOBJECT obj, MEvent *e, void *ad)
Definition: Mguidefs.h:1456
void MFreeImage(MIMAGE data)
MOBJECT MCreateDrawArea(MOBJECT parent, int width, int height)
MOBJECT MCreateColForm(MOBJECT parent)
void MDrawAreaSetExposeCallback(MOBJECT obj, OBJ_EVENT_CB cb, void *ad)
MOBJECT MCreateShell(const char *title, int flags)
int maxploth
Definition: Spat_Plot.c:51
void MInstallImage(MIMAGE data)
void D_To_DoLens(void)
Definition: D_Zoom.c:111
void MShellRaise(MOBJECT obj)
Function prototypes.
bil BIL
Definition: 2DPlot.c:28
static double p
Definition: SOLPOS.C:131
void MDrawImage(MOBJECT p, MIMAGE gi, int pm_x, int pm_y, int w, int h, int x, int y)
unsigned int LocY
Definition: bildef.h:15
int LWy
Definition: bildef.h:10
int MGetScreenWidth(void)
void * MOBJECT
Definition: Mguidefs.h:192
blens BLENS
Definition: bildef.h:252
#define True
Definition: Mguidefs.h:235
MOBJECT LensDraw
Definition: bildef.h:11
int LWx
Definition: bildef.h:10
void MUninstallImage(MIMAGE data)
void D_Lens(void)
Definition: D_Zoom.c:138
MIMAGE MAllocImage(int img_w, int img_h, int nplanes)
int LensWx
Definition: bildef.h:10
void MImageGetPixelRGB(MIMAGE pmi, int x, int y, int *pr, int *pg, int *pb)
MOBJECT LensLblX
Definition: bildef.h:11
void MShellSetWMCloseCallback(MOBJECT p, WM_CLOSE_CB cb, void *a_data)
MOBJECT MCreateRowForm(MOBJECT parent)
#define MAXZOOM
Definition: bildef.h:20
int LensWy
Definition: bildef.h:10
void MScrollBarSetPosCallback(MOBJECT p, OBJ_VALUE_CB cb, void *data)
MOBJECT LensLbl
Definition: bildef.h:11
______________________________________________________________________________________
Generated on Mon Sep 18 2017 11:44:07 for DAS - Rel. 3.1.6 - 18/09/2017.