-
Notifications
You must be signed in to change notification settings - Fork 94
Expand file tree
/
Copy pathMask2TE.cpp
More file actions
59 lines (47 loc) · 1.1 KB
/
Copy pathMask2TE.cpp
File metadata and controls
59 lines (47 loc) · 1.1 KB
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
/* Copyright (C) 2010 Ion Torrent Systems, Inc. All Rights Reserved */
// Converter: Mask list to TE mask format.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
int main (int argc, char *argv[])
{
if (argc != 2)
return 1;
FILE *fp = NULL;
FILE *out = NULL;
char *outFile = {"mask1"};
fp = fopen (argv[1], "rb");
if (fp == NULL)
return 1;
out = fopen (outFile, "wb");
int row, col;
int w, h;
int n = 0;
n = fscanf (fp, "%d %d\n", &w, &h);
assert (n == 2);
int *array = (int *) malloc(sizeof(int) * w * h);
memset(array,0,sizeof(int) * w * h);
while (!feof(fp)) {
n = fscanf (fp, "%d %d\n", &row, &col);
array[row*w + col] = 1;
}
fprintf (out, "0,0\n"); // origin of maks area, default to whole-chip
fprintf (out, "%d,%d\n", w,h); // width and height of region
for (int y=0;y<h;y++) {
for (int x=0;x<w;x++) {
fprintf (out, "%d", array[x+y*w]);
if (x+1 != w)
fprintf (out, ",");
}
fprintf (out, "\n");
}
if(fp!=NULL) {
fclose(fp);
}
if(out!=NULL) {
fclose(out);
}
free(array);
return (0);
}