Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
5ecb22b5
Commit
5ecb22b5
authored
Jun 15, 2010
by
jean-pierre charras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bitmap2component: better user interface (using wxWidgets) and more bitmaps file format import
parent
6e859e26
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
63 deletions
+32
-63
CMakeLists.txt
bitmap2component/CMakeLists.txt
+6
-1
bitmap2component.cpp
bitmap2component/bitmap2component.cpp
+26
-62
No files found.
bitmap2component/CMakeLists.txt
View file @
5ecb22b5
...
@@ -5,12 +5,17 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}
...
@@ -5,12 +5,17 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}
set
(
BITMAP2COMPONENT_SRCS
set
(
BITMAP2COMPONENT_SRCS
bitmap2component.cpp
bitmap2component.cpp
bitmap2cmp_gui_base
bitmap2cmp_gui
)
)
add_executable
(
bitmap2component WIN32 MACOSX_BUNDLE
${
BITMAP2COMPONENT_SRCS
}
${
BITMAP2COMPONENT_RESOURCES
}
)
add_executable
(
bitmap2component WIN32 MACOSX_BUNDLE
${
BITMAP2COMPONENT_SRCS
}
${
BITMAP2COMPONENT_RESOURCES
}
)
target_link_libraries
(
bitmap2component potrace kbool
)
target_link_libraries
(
bitmap2component
${
wxWidgets_LIBRARIES
}
potrace
kbool
)
install
(
TARGETS bitmap2component
install
(
TARGETS bitmap2component
DESTINATION
${
KICAD_PLUGINS
}
DESTINATION
${
KICAD_PLUGINS
}
...
...
bitmap2component/bitmap2component.cpp
View file @
5ecb22b5
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
#include <vector>
#include <vector>
#include "potracelib.h"
#include "potracelib.h"
#include "bitmap_io.h"
//
#include "bitmap_io.h"
#include "auxiliary.h"
#include "auxiliary.h"
...
@@ -49,6 +49,13 @@ enum output_format {
...
@@ -49,6 +49,13 @@ enum output_format {
PCBNEW_FMT
,
PCBNEW_FMT
,
EESCHEMA_FMT
EESCHEMA_FMT
};
};
/* free a potrace bitmap */
static
void
bm_free
(
potrace_bitmap_t
*
bm
)
{
if
(
bm
!=
NULL
)
{
free
(
bm
->
map
);
}
free
(
bm
);
}
/* Helper class th handle useful info to convert a bitmpa to
/* Helper class th handle useful info to convert a bitmpa to
...
@@ -185,53 +192,11 @@ void ArmBoolEng( Bool_Engine* aBooleng, bool aConvertHoles )
...
@@ -185,53 +192,11 @@ void ArmBoolEng( Bool_Engine* aBooleng, bool aConvertHoles )
}
}
int
main
(
int
argc
,
char
*
argv
[]
)
int
bitmap2component
(
potrace_bitmap_t
*
aPotrace_bitmap
,
FILE
*
aOutfile
,
int
aFormat
)
{
{
potrace_bitmap_t
*
potrace_bitmap
=
NULL
;
potrace_param_t
*
param
;
potrace_param_t
*
param
;
potrace_state_t
*
st
;
potrace_state_t
*
st
;
int
error
;
int
fmt_option
=
'0'
;
FILE
*
infile
,
*
outfile
=
NULL
;
if
(
argc
<
4
)
{
printf
(
"Usage:
\n
bitmap2component <infile_bitmap.ext> <outfile.ext> <0,1,2>
\n
"
);
printf
(
" Allowed bitmap files formats are .bmp or .pgm
\n
"
);
printf
(
"output format:
\n
0 = pcbnew.emp, 1 = eeschema.lib, 2 = ps
\n
"
);
return
-
1
;
}
infile
=
fopen
(
argv
[
1
],
"r"
);
if
(
infile
==
NULL
)
{
printf
(
"File %s could not be opened
\n
"
,
argv
[
1
]
);
return
-
2
;
}
outfile
=
fopen
(
argv
[
2
],
"w"
);
if
(
outfile
==
NULL
)
{
printf
(
"File %s could not be opened
\n
"
,
argv
[
2
]
);
return
-
2
;
}
double
threshold
=
0.5
;
// = 0 to 1.0
error
=
bm_read
(
infile
,
threshold
,
&
potrace_bitmap
);
if
(
error
!=
0
)
{
printf
(
"Bitmap %s could not be read
\n
"
,
argv
[
1
]
);
return
-
2
;
}
if
(
!
potrace_bitmap
)
{
fprintf
(
stderr
,
"Error allocating bitmap: %s
\n
"
,
strerror
(
errno
)
);
return
1
;
}
/* set tracing parameters, starting from defaults */
/* set tracing parameters, starting from defaults */
param
=
potrace_param_default
();
param
=
potrace_param_default
();
...
@@ -243,7 +208,7 @@ int main( int argc, char* argv[] )
...
@@ -243,7 +208,7 @@ int main( int argc, char* argv[] )
param
->
turdsize
=
0
;
param
->
turdsize
=
0
;
/* convert the bitmap to curves */
/* convert the bitmap to curves */
st
=
potrace_trace
(
param
,
p
otrace_bitmap
);
st
=
potrace_trace
(
param
,
aP
otrace_bitmap
);
if
(
!
st
||
st
->
status
!=
POTRACE_STATUS_OK
)
if
(
!
st
||
st
->
status
!=
POTRACE_STATUS_OK
)
{
{
fprintf
(
stderr
,
"Error tracing bitmap: %s
\n
"
,
strerror
(
errno
)
);
fprintf
(
stderr
,
"Error tracing bitmap: %s
\n
"
,
strerror
(
errno
)
);
...
@@ -251,41 +216,40 @@ int main( int argc, char* argv[] )
...
@@ -251,41 +216,40 @@ int main( int argc, char* argv[] )
}
}
BITMAPCONV_INFO
info
;
BITMAPCONV_INFO
info
;
info
.
m_PixmapWidth
=
p
otrace_bitmap
->
w
;
info
.
m_PixmapWidth
=
aP
otrace_bitmap
->
w
;
info
.
m_PixmapHeight
=
p
otrace_bitmap
->
h
;
// the bitmap size in pixels
info
.
m_PixmapHeight
=
aP
otrace_bitmap
->
h
;
// the bitmap size in pixels
info
.
m_Paths
=
st
->
plist
;
info
.
m_Paths
=
st
->
plist
;
info
.
m_Outfile
=
o
utfile
;
info
.
m_Outfile
=
aO
utfile
;
if
(
argc
>=
4
)
switch
(
aFormat
)
fmt_option
=
argv
[
3
][
0
];
switch
(
fmt_option
)
{
{
case
'2'
:
case
2
:
info
.
m_Format
=
POSTSCRIPT_FMT
;
info
.
m_Format
=
POSTSCRIPT_FMT
;
info
.
m_ScaleX
=
info
.
m_ScaleY
=
1.0
;
// the conversion scale
info
.
m_ScaleX
=
info
.
m_ScaleY
=
1.0
;
// the conversion scale
/* output vector data, e.g. as a rudimentary EPS file */
/* output vector data, e.g. as a rudimentary EPS file */
CreateOutputFile
(
info
);
break
;
break
;
case
'1'
:
case
1
:
info
.
m_Format
=
EESCHEMA_FMT
;
info
.
m_Format
=
EESCHEMA_FMT
;
info
.
m_ScaleX
=
info
.
m_ScaleY
=
1000.0
/
300
;
// the conversion scale
info
.
m_ScaleX
=
1000.0
/
300
;
// the conversion scale
info
.
m_ScaleY
=
-
info
.
m_ScaleX
;
// Y axis is bottom to Top for components in libs
CreateOutputFile
(
info
);
break
;
break
;
case
'0'
:
case
0
:
info
.
m_Format
=
PCBNEW_FMT
;
info
.
m_Format
=
PCBNEW_FMT
;
info
.
m_ScaleX
=
10000.0
/
300
;
// the conversion scale
info
.
m_ScaleX
=
10000.0
/
300
;
// the conversion scale
info
.
m_ScaleY
=
-
info
.
m_ScaleX
;
// Y axis is top to bottom in modedit
info
.
m_ScaleY
=
info
.
m_ScaleX
;
// Y axis is top to bottom in modedit
CreateOutputFile
(
info
);
break
;
break
;
default
:
default
:
printf
(
"Unknown output format
\n
"
);
break
;
break
;
}
}
CreateOutputFile
(
info
);
bm_free
(
potrace_bitmap
);
bm_free
(
aPotrace_bitmap
);
potrace_state_free
(
st
);
potrace_state_free
(
st
);
potrace_param_free
(
param
);
potrace_param_free
(
param
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment