aboutsummaryrefslogtreecommitdiff
path: root/pix_preview/pix_preview.h
blob: 4e2a8517aa5b1a40ee8327671121bbcf8e3b927f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142

/*-----------------------------------------------------------------
pix_preview

-----------------------------------------------------------------*/

#ifndef INCLUDE_PIX_DUMP_H_
#define INCLUDE_PIX_DUMP_H_

#include "Base/GemPixObj.h"

/*needed for base64 conversion*/
#include <string>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netdb.h>

std::string base64_encode(unsigned char const* , unsigned int len);


/*-----------------------------------------------------------------
-------------------------------------------------------------------
CLASS

 pix_preview
 
  Get pixel information
  
   KEYWORDS
   pix
   
	DESCRIPTION
	
	 dumps the pix-data as a float-package
	 
-----------------------------------------------------------------*/
class GEM_EXTERN pix_preview : public GemPixObj
{
	CPPEXTERN_HEADER(pix_preview, GemPixObj)
		
public:
	
	//////////
	// Constructor
	pix_preview(t_floatarg fx, t_floatarg fy);
	int x_width, x_height;
	static int counter;
	
protected:
	
	//////////
	// Destructor
	virtual ~pix_preview();
	
	//////////
	// All we want is the pixel information, so this is a complete override.
	virtual void 	processImage(imageStruct &image);
	
	//////////
	virtual void 	processYUVImage(imageStruct &image);
	
	//////////
	void			trigger();
	int getx();
	int gety();
    	void	    	connectMess();

	//////////
	// The color outlet
	t_outlet    	*m_dataOut;
	
	//////////
	// the buffer
	int           xsize, ysize;      // proposed x/y-sizes
	int           m_xsize,  m_ysize;
	int           m_csize;
	t_atom       *m_buffer;
	int           m_bufsize;
	
	int           oldimagex;
	int           oldimagey;
	int           widgetwidth;
	int           widgetheight;
	
	//////////
	// navigation
	float         m_xstep;
	float         m_ystep;
	
	/////////
	// pointer to the image data
	unsigned char *m_data;
	
	/////////
	// LLUO :: widget tk list pointer
    	t_glist *m_glist;
	
	t_widgetbehavior   image_widgetbehavior;

	int s;
	int connected;
	struct addrinfo *res;
	struct addrinfo hints;
	int 		whoami;


private:
	
	//////////
	// Static member callbacks
	static void		triggerMessCallback(void *dump);
	static void		GREYMessCallback(void *dump);
	static void		RGBAMessCallback(void *dump);
	static void		RGBMessCallback(void *dump);
    	static void 		connectMessCallback(void *dump);


	static void image_drawme(pix_preview *x, t_glist *glist, int firsttime, int m_xsize, int m_ysize);

	static void image_erase(pix_preview* x,t_glist* glist);
	

/* ------------------------ image widgetbehaviour----------------------------- */


	static void image_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2);

	static void image_displace(t_gobj *z, t_glist *glist, int dx, int dy);

	static void image_select(t_gobj *z, t_glist *glist, int state);

	static void image_activate(t_gobj *z, t_glist *glist, int state);

	static void image_delete(t_gobj *z, t_glist *glist);
       
	static void image_vis(t_gobj *z, t_glist *glist, int vis);

};

#endif	// for header file