• R/O
  • SSH

wp2latex: Commit

WP2LaTeX sources.


Commit MetaInfo

Revision62262796d9b1cdc7956110cd994cd5e1422c0b21 (tree)
Zeit2022-05-01 09:27:36
AutorFojtik
CommiterFojtik

Log Message

Extract functions RGB_BGR and NotR to a separate module.

Ändern Zusammenfassung

Diff

diff -r ff69fcbcc9ba -r 62262796d9b1 trunk/sources.cc/images/img_tool.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/trunk/sources.cc/images/img_tool.c Sun May 01 02:27:36 2022 +0200
@@ -0,0 +1,91 @@
1+/******************************************************************************
2+ * program: rasimg library *
3+ * function: Usefull block operations. *
4+ * modul: img_tool.c *
5+ * licency: GPL or LGPL *
6+ ******************************************************************************/
7+#include "img_tool.h"
8+
9+
10+/** Flip R and B coupounds inplace.
11+ * param[in] Data Pointer to data.
12+ * param[in] Size Amount of RGB tripplets. */
13+void RGB_BGR(char *Data, int size)
14+{
15+char c;
16+while(size-->0)
17+ {
18+ c=Data[2];
19+ Data[2]=*Data;
20+ *Data=c;
21+ Data+=3;
22+ }
23+}
24+
25+
26+/** Flip R and B coupounds to the different buffer. */
27+void RGB_BGR2(unsigned char *OutData, const unsigned char *InData, unsigned PixelCount)
28+{
29+ while(PixelCount-->0)
30+ {
31+ OutData[0] = InData[2];
32+ OutData[1] = InData[1];
33+ OutData[2] = InData[0];
34+ OutData += 3;
35+ InData += 3;
36+ }
37+}
38+
39+
40+void RGB32_BGR24(unsigned char *OutData, const unsigned char *InData, unsigned PixelCount)
41+{
42+ while(PixelCount-->0)
43+ {
44+ OutData[0] = InData[2];
45+ OutData[1] = InData[1];
46+ OutData[2] = InData[0];
47+ OutData += 3;
48+ InData += 4;
49+ }
50+}
51+
52+
53+void BGR_Gray24(unsigned char *OutData, const unsigned char *InData, unsigned PixelCount)
54+{
55+ while(PixelCount-->0)
56+ {
57+ OutData[2]=OutData[1]=OutData[0] = (InData[0]*4731 + InData[1]*46871 + InData[2]*13932)/65536;
58+ InData+=3;
59+ OutData+=3;
60+ }
61+}
62+
63+
64+void RGB32_Gray(unsigned char *OutData, const unsigned char *InData, unsigned PixelCount)
65+{
66+ while(PixelCount-->0)
67+ {
68+ *(OutData++) = (*(InData++) + *(InData++) + *(InData++)) / 3;
69+ InData++;
70+ }
71+}
72+
73+
74+void RGB_Gray(unsigned char *OutData, const unsigned char *InData, unsigned PixelCount)
75+{
76+ while(PixelCount-->0)
77+ {
78+ *(OutData++) = (*(InData++) + *(InData++) + *(InData++)) / 3;
79+ }
80+}
81+
82+
83+/** Invert block of data. */
84+void NotR(char *R, int size) //R1:=not(R1)
85+{
86+ while(size-->0)
87+ {
88+ *R = ~*R;
89+ R++;
90+ }
91+}
diff -r ff69fcbcc9ba -r 62262796d9b1 trunk/sources.cc/images/img_tool.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/trunk/sources.cc/images/img_tool.h Sun May 01 02:27:36 2022 +0200
@@ -0,0 +1,23 @@
1+#ifndef _IMG_TOOL_H
2+#define _IMG_TOOL_H
3+
4+#ifdef __cplusplus
5+extern "C" {
6+#endif
7+
8+void RGB_BGR(char *Data, int size);
9+void RGB_BGR2(unsigned char *OutData, const unsigned char *InData, unsigned PixelCount);
10+void RGB32_BGR24(unsigned char *OutData, const unsigned char *InData, unsigned PixelCount);
11+void RGB_Gray(unsigned char *OutData, const unsigned char *InData, unsigned PixelCount);
12+void RGB_Gray24(unsigned char *OutData, const unsigned char *InData, unsigned PixelCount);
13+void BGR_Gray24(unsigned char *OutData, const unsigned char *InData, unsigned PixelCount);
14+void BGR32_Gray24(unsigned char *OutData, const unsigned char *InData, unsigned PixelCount);
15+void RGB32_Gray(unsigned char *OutData, const unsigned char *InData, unsigned PixelCount);
16+void NotR(char *R, int size);
17+
18+#ifdef __cplusplus
19+}
20+#endif
21+
22+
23+#endif /* _IMG_TOOL_H */
diff -r ff69fcbcc9ba -r 62262796d9b1 trunk/sources.cc/images/img_tool_MSVC.asm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/trunk/sources.cc/images/img_tool_MSVC.asm Sun May 01 02:27:36 2022 +0200
@@ -0,0 +1,326 @@
1+.486 ;Target processor. Use instructions for Pentium class machines
2+.MODEL FLAT, C ;Use the flat memory model. Use C calling conventions
3+
4+.CODE ;Indicates the start of a code segment.
5+
6+
7+;void RGB_BGR(unsigned char *Data, unsigned PixelCount)
8+ public RGB_BGR
9+RGB_BGR proc \
10+ uses esi, \
11+ Data:ptr byte, \
12+ PixelCount:DWORD
13+
14+ mov ecx,[PixelCount] ; cx=amount of pixels
15+ cmp ecx,1
16+ jle ToEnd ; array has zero size
17+
18+ mov esi,[Data] ;
19+
20+LoopPix:mov al,[esi]
21+ mov ah,[esi+2]
22+ mov [esi],ah
23+ mov [esi+2],al
24+ add esi,3
25+ loop LoopPix
26+
27+ToEnd:
28+ ret ; _cdecl return
29+
30+RGB_BGR endp
31+
32+
33+;void RGB_BGR2(unsigned char *OutData, const unsigned char *InData, unsigned PixelCount)
34+ public RGB_BGR2
35+RGB_BGR2 proc \
36+ uses esi edi \
37+ OutData:ptr byte, \
38+ InData:ptr byte, \
39+ PixelCount:DWORD
40+
41+ mov ecx,[PixelCount] ; cx=amount of pixels
42+ cmp ecx,1
43+ jle ToEnd ; array has zero size
44+
45+ mov esi,[InData] ;
46+ mov edi,[OutData] ;
47+
48+LoopPix:lodsw
49+ mov [edi+2],al
50+ mov [edi+1],ah
51+ lodsb
52+ mov [edi],al
53+ add edi,3
54+ loop LoopPix
55+
56+ToEnd:
57+ ret ; _cdecl return
58+
59+RGB_BGR2 endp
60+
61+
62+;void RGB32_BGR24(unsigned char *OutData, const unsigned char *InData, unsigned PixelCount)
63+ public RGB32_BGR24
64+RGB32_BGR24 proc \
65+ uses esi edi \
66+ OutData:ptr byte, \
67+ InData:ptr byte, \
68+ PixelCount:DWORD
69+
70+ mov ecx,[PixelCount] ; cx=amount of pixels
71+ cmp ecx,1
72+ jle ToEnd ; array has zero size
73+
74+ mov esi,[InData] ;
75+ mov edi,[OutData] ;
76+
77+LoopPix:lodsd
78+ mov [edi+2],al
79+ mov [edi+1],ah
80+ shr eax,8
81+ mov [edi],ah
82+ add edi,3
83+ loop LoopPix
84+
85+ToEnd:
86+ ret ; _cdecl return
87+
88+RGB32_BGR24 endp
89+
90+
91+
92+;void RGB_Gray24(unsigned char *OutData, const unsigned char *InData, unsigned PixelCount)
93+ public RGB_Gray24simple
94+RGB_Gray24simple proc \
95+ uses esi edi ebx \
96+ OutData:ptr byte, \
97+ InData:ptr byte, \
98+ PixelCount:DWORD
99+
100+ mov ecx,[PixelCount] ; cx=amount of pixels
101+ cmp ecx,1
102+ jle ToEnd ; array has zero size
103+
104+ mov esi,[InData] ;
105+ mov edi,[OutData] ;
106+
107+ mov bh,0
108+LoopPix:mov ah,0
109+ mov al,[esi]
110+ mov bl,[esi+1]
111+ add ax,bx
112+ mov bl,[esi+2]
113+ add ax,bx
114+ mov bl,3
115+ div bl
116+ stosb
117+ stosb
118+ stosb
119+ add esi,3
120+ loop LoopPix
121+
122+ToEnd:
123+ ret ; _cdecl return
124+
125+RGB_Gray24simple endp
126+
127+
128+
129+;void BGR_Gray24(unsigned char *OutData, const unsigned char *InData, unsigned PixelCount)
130+ public BGR_Gray24
131+BGR_Gray24 proc \
132+ uses esi edi ebx \
133+ OutData:ptr byte, \
134+ InData:ptr byte, \
135+ PixelCount:DWORD
136+
137+ mov ecx,[PixelCount] ; cx=amount of pixels
138+ cmp ecx,1
139+ jle ToEnd ; array has zero size
140+
141+ mov esi,[InData] ;
142+ mov edi,[OutData] ;
143+
144+LoopPix:mov eax,0
145+ lodsb
146+ mov edx,4731
147+ mul edx
148+ mov ebx,eax
149+
150+ mov eax,0
151+ lodsb
152+ mov edx,46871
153+ mul edx
154+ add ebx,eax
155+
156+ mov eax,0
157+ lodsb
158+ mov edx,13932
159+ mul edx
160+ add eax,ebx
161+
162+ shr eax,16
163+ stosb
164+ stosb
165+ stosb
166+ loop LoopPix
167+
168+ToEnd:
169+ ret ; _cdecl return
170+
171+BGR_Gray24 endp
172+
173+
174+
175+;void BGR32_Gray24(unsigned char *OutData, const unsigned char *InData, unsigned PixelCount)
176+ public BGR32_Gray24
177+BGR32_Gray24 proc \
178+ uses esi edi ebx \
179+ OutData:ptr byte, \
180+ InData:ptr byte, \
181+ PixelCount:DWORD
182+
183+ mov ecx,[PixelCount] ; cx=amount of pixels
184+ cmp ecx,1
185+ jle ToEnd ; array has zero size
186+
187+ mov esi,[InData] ;
188+ mov edi,[OutData] ;
189+
190+LoopPix:mov eax,0
191+ lodsb
192+ mov edx,4731
193+ mul edx
194+ mov ebx,eax
195+
196+ mov eax,0
197+ lodsb
198+ mov edx,46871
199+ mul edx
200+ add ebx,eax
201+
202+ mov eax,0
203+ lodsb
204+ mov edx,13932
205+ mul edx
206+ add eax,ebx
207+
208+ shr eax,16
209+ stosb
210+ stosb
211+ stosb
212+ inc esi
213+ loop LoopPix
214+
215+ToEnd:
216+ ret ; _cdecl return
217+
218+BGR32_Gray24 endp
219+
220+
221+;void RGB32_Gray(unsigned char *OutData, const unsigned char *InData, unsigned PixelCount)
222+ public RGB32_Gray
223+RGB32_Gray proc \
224+ uses esi edi ebx \
225+ OutData:ptr byte, \
226+ InData:ptr byte, \
227+ PixelCount:DWORD
228+
229+ mov ecx,[PixelCount] ; cx=amount of pixels
230+ cmp ecx,1
231+ jle ToEnd ; array has zero size
232+
233+ mov esi,[InData] ;
234+ mov edi,[OutData] ;
235+
236+ mov bh,0
237+LoopPix:mov ah,0
238+ mov al,[esi]
239+ mov bl,[esi+1]
240+ add ax,bx
241+ mov bl,[esi+2]
242+ add ax,bx
243+ mov bl,3
244+ div bl
245+ stosb
246+ add esi,4
247+ loop LoopPix
248+
249+ToEnd:
250+ ret ; _cdecl return
251+
252+RGB32_Gray endp
253+
254+
255+;void RGB_Gray(unsigned char *OutData, const unsigned char *InData, unsigned PixelCount)
256+ public RGB_Gray
257+RGB_Gray proc \
258+ uses esi edi ebx \
259+ OutData:ptr byte, \
260+ InData:ptr byte, \
261+ PixelCount:DWORD
262+
263+ mov ecx,[PixelCount] ; cx=amount of pixels
264+ cmp ecx,1
265+ jle ToEnd ; array has zero size
266+
267+ mov esi,[InData] ;
268+ mov edi,[OutData] ;
269+
270+ mov bh,0
271+LoopPix:mov ah,0
272+ mov al,[esi]
273+ mov bl,[esi+1]
274+ add ax,bx
275+ mov bl,[esi+2]
276+ add ax,bx
277+ mov bl,3
278+ div bl
279+ stosb
280+ add esi,3
281+ loop LoopPix
282+
283+ToEnd:
284+ ret ; _cdecl return
285+
286+RGB_Gray endp
287+
288+
289+;void NotR(char *R, unsigned DataSize) //R1:=not(R1)
290+ public NotR
291+NotR proc \
292+ uses esi, \
293+ R:ptr byte, \
294+ DataSize:DWORD
295+
296+ mov ecx,[DataSize] ; cx=amount of pixels/bytes
297+ mov esi,[R] ; Row byte data
298+
299+ cmp ecx,4
300+ jl LoopPx1
301+
302+ sub ecx,4
303+LoopPx4:mov eax,[esi] ; Invert DWORDs
304+ not eax
305+ mov [esi],eax
306+ add esi,4
307+
308+ sub ecx,4
309+ jge LoopPx4
310+
311+ add ecx,4
312+
313+LoopPx1:jecxz ToEnd
314+LoopPix:mov al,[esi] ; Invert BYTEs
315+ not al
316+ mov [esi],al
317+ inc esi
318+ loop LoopPix
319+ToEnd:
320+ ret ; _cdecl return
321+
322+NotR endp
323+
324+
325+
326+ end
diff -r ff69fcbcc9ba -r 62262796d9b1 trunk/sources.cc/images/ras_img.cc
--- a/trunk/sources.cc/images/ras_img.cc Sat Apr 30 20:12:43 2022 +0200
+++ b/trunk/sources.cc/images/ras_img.cc Sun May 01 02:27:36 2022 +0200
@@ -25,6 +25,7 @@
2525 #include "common.h"
2626 #include "raster.h"
2727 #include "vecimage.h"
28+#include "img_tool.h"
2829 #include "ras_prot.h"
2930 #include "std_str.h"
3031
@@ -89,29 +90,6 @@
8990 #pragma warning(disable: 4244)
9091 #endif
9192
92-
93-static void RGB_BGR(char *Data,int size)
94-{
95-char c;
96-while(size-->0)
97- {
98- c=Data[2];
99- Data[2]=*Data;
100- *Data=c;
101- Data+=3;
102- }
103-}
104-
105-static void NotR(char *R, int size) //R1:=not(R1)
106-{
107- while(size-->0)
108- {
109- *R = ~*R;
110- R++;
111- }
112-}
113-
114-
11593 #if FileSize==1
11694 #undef FileSize
11795 #endif
diff -r ff69fcbcc9ba -r 62262796d9b1 trunk/sources.cc/makefile
--- a/trunk/sources.cc/makefile Sat Apr 30 20:12:43 2022 +0200
+++ b/trunk/sources.cc/makefile Sun May 01 02:27:36 2022 +0200
@@ -113,7 +113,7 @@
113113
114114 #library components
115115 OBJECTS=cp_lib/cptran$(OBJ)
116-OBJECTS+=images/raster$(OBJ) images/rasterc$(OBJ) images/rasterut$(OBJ) images/filehnd$(OBJ)
116+OBJECTS+=images/raster$(OBJ) images/rasterc$(OBJ) images/img_tool$(OBJ) images/rasterut$(OBJ) images/filehnd$(OBJ)
117117 OBJECTS+=images/vecimage$(OBJ) images/vecraster$(OBJ) images/error$(OBJ) images/imgsupp$(OBJ)
118118
119119 #mandatory components
diff -r ff69fcbcc9ba -r 62262796d9b1 trunk/sources.cc/makefile.gen
--- a/trunk/sources.cc/makefile.gen Sat Apr 30 20:12:43 2022 +0200
+++ b/trunk/sources.cc/makefile.gen Sun May 01 02:27:36 2022 +0200
@@ -113,7 +113,7 @@
113113
114114 #library components
115115 OBJECTS=cp_lib/cptran$(OBJ)
116-OBJECTS+=images/raster$(OBJ) images/rasterc$(OBJ) images/rasterut$(OBJ) images/filehnd$(OBJ)
116+OBJECTS+=images/raster$(OBJ) images/rasterc$(OBJ) images/img_tool$(OBJ) images/rasterut$(OBJ) images/filehnd$(OBJ)
117117 OBJECTS+=images/vecimage$(OBJ) images/vecraster$(OBJ) images/error$(OBJ) images/imgsupp$(OBJ)
118118
119119 #mandatory components
diff -r ff69fcbcc9ba -r 62262796d9b1 trunk/sources.cc/makefile.in
--- a/trunk/sources.cc/makefile.in Sat Apr 30 20:12:43 2022 +0200
+++ b/trunk/sources.cc/makefile.in Sun May 01 02:27:36 2022 +0200
@@ -92,7 +92,7 @@
9292
9393 #library components
9494 OBJECTS=cp_lib/cptran$(OBJ)
95-OBJECTS+=images/raster$(OBJ) images/rasterc$(OBJ) images/rasterut$(OBJ) images/filehnd$(OBJ)
95+OBJECTS+=images/raster$(OBJ) images/rasterc$(OBJ) images/img_tool$(OBJ) images/rasterut$(OBJ) images/filehnd$(OBJ)
9696 OBJECTS+=images/vecimage$(OBJ) images/vecraster$(OBJ) images/error$(OBJ) images/imgsupp$(OBJ)
9797 #OBJECTS+=atoms/sets$(OBJ) atoms/struct$(OBJ) atoms/lists$(OBJ) atoms/dbllist$(OBJ) atoms/strings$(OBJ) atoms/mtx_impl$(OBJ)
9898 #OBJECTS+=atoms/std_str$(OBJ) atoms/stack$(OBJ)
diff -r ff69fcbcc9ba -r 62262796d9b1 trunk/sources.cc/pass1wmf.cc
--- a/trunk/sources.cc/pass1wmf.cc Sat Apr 30 20:12:43 2022 +0200
+++ b/trunk/sources.cc/pass1wmf.cc Sun May 01 02:27:36 2022 +0200
@@ -1332,6 +1332,14 @@
13321332 pVecPoly->AttribFromPSS(PSS);
13331333 //memcpy(&pVecPoly->FillColor, &PSS.FillColor, sizeof(PSS.FillColor));
13341334 //pVecPoly->BrushStyle = PSS.FillPattern;
1335+ /*if(i==0) // debugging only!
1336+ {
1337+ pVecPoly->BrushStyle = 0; //PSS.FillPattern;
1338+ pVecPoly->LineStyle = 1;
1339+ memset(&pVecPoly->LineColor, 0, sizeof(pVecPoly->LineColor));
1340+ pVecPoly->PenWidth = 10*GetScale2PSU((TMapMode)MapMode);
1341+ } */
1342+
13351343 pVecPoly->Close = true;
13361344 VectList.AddObject(pVecPoly); pVecPoly=NULL;
13371345 }
Show on old repository browser