将数组内容保存为csv格式

bool saveAsCsv(CString strFileName)
{
BYTE colorTable[256][3]={
{255,255,255},// 255
{255,250,250},// 254
{255,245,245},// 253
{255,240,240},// 252
{255,235,235},// 251
{255,230,230},// 250
{255,225,225},// 249
{255,220,220},// 248
{255,215,215},// 247
{255,210,210},// 246
{255,205,205},// 245
{255,200,200},// 244
{255,195,195},// 243
{255,190,190},// 242
{255,185,185},// 241
{255,180,180},// 240
{255,175,175},// 239
{255,170,170},// 238
{255,165,165},// 237
{255,160,160},// 236
{255,155,155},// 235
{255,150,150},// 234
{255,145,145},// 233
{255,140,140},// 232
{255,135,135},// 231
{255,130,130},// 230
{255,125,125},// 229
{255,120,120},// 228
{255,115,115},// 227
{255,110,110},// 226
{255,105,105},// 225
{255,100,100},// 224
{255,95,95},// 223
{255,90,90},// 222
{255,85,85},// 221
{255,80,80},// 220
{255,75,75},// 219
{255,70,70},// 218
{255,65,65},// 217
{255,60,60},// 216
{255,55,55},// 215
{255,50,50},// 214
{255,45,45},// 213
{255,40,40},// 212
{255,35,35},// 211
{255,30,30},// 210
{255,25,25},// 209
{255,20,20},// 208
{255,15,15},// 207
{255,10,10},// 206
{255,5,5},// 205
{255,0,0},// 204
{255,5,0},// 203
{255,10,0},// 202
{255,15,0},// 201
{255,20,0},// 200
{255,25,0},// 199
{255,30,0},// 198
{255,35,0},// 197
{255,40,0},// 196
{255,45,0},// 195
{255,50,0},// 194
{255,55,0},// 193
{255,60,0},// 192
{255,65,0},// 191
{255,70,0},// 190
{255,75,0},// 189
{255,80,0},// 188
{255,85,0},// 187
{255,90,0},// 186
{255,95,0},// 185
{255,100,0},// 184
{255,105,0},// 183
{255,110,0},// 182
{255,115,0},// 181
{255,120,0},// 180
{255,125,0},// 179
{255,130,0},// 178
{255,135,0},// 177
{255,140,0},// 176
{255,145,0},// 175
{255,150,0},// 174
{255,155,0},// 173
{255,160,0},// 172
{255,165,0},// 171
{255,170,0},// 170
{255,175,0},// 169
{255,180,0},// 168
{255,185,0},// 167
{255,190,0},// 166
{255,195,0},// 165
{255,200,0},// 164
{255,205,0},// 163
{255,210,0},// 162
{255,215,0},// 161
{255,220,0},// 160
{255,225,0},// 159
{255,230,0},// 158
{255,235,0},// 157
{255,240,0},// 156
{255,245,0},// 155
{255,250,0},// 154
{255,255,0},// 153
{250,255,0},// 152
{245,255,0},// 151
{240,255,0},// 150
{235,255,0},// 149
{230,255,0},// 148
{225,255,0},// 147
{220,255,0},// 146
{215,255,0},// 145
{210,255,0},// 144
{205,255,0},// 143
{200,255,0},// 142
{195,255,0},// 141
{190,255,0},// 140
{185,255,0},// 139
{180,255,0},// 138
{175,255,0},// 137
{170,255,0},// 136
{165,255,0},// 135
{160,255,0},// 134
{155,255,0},// 133
{150,255,0},// 132
{145,255,0},// 131
{140,255,0},// 130
{135,255,0},// 129
{130,255,0},// 128
{125,255,0},// 127
{120,255,0},// 126
{115,255,0},// 125
{110,255,0},// 124
{105,255,0},// 123
{100,255,0},// 122
{95,255,0},// 121
{90,255,0},// 120
{85,255,0},// 119
{80,255,0},// 118
{75,255,0},// 117
{70,255,0},// 116
{65,255,0},// 115
{60,255,0},// 114
{55,255,0},// 113
{50,255,0},// 112
{45,255,0},// 111
{40,255,0},// 110
{35,255,0},// 109
{30,255,0},// 108
{25,255,0},// 107
{20,255,0},// 106
{15,255,0},// 105
{10,255,0},// 104
{5,255,0},// 103
{0,255,0},// 102
{0,250,5},// 101
{0,245,10},// 100
{0,240,15},// 99
{0,235,20},// 98
{0,230,25},// 97
{0,225,30},// 96
{0,220,35},// 95
{0,215,40},// 94
{0,210,45},// 93
{0,205,50},// 92
{0,200,55},// 91
{0,195,60},// 90
{0,190,65},// 89
{0,185,70},// 88
{0,180,75},// 87
{0,175,80},// 86
{0,170,85},// 85
{0,165,90},// 84
{0,160,95},// 83
{0,155,100},// 82
{0,150,105},// 81
{0,145,110},// 80
{0,140,115},// 79
{0,135,120},// 78
{0,130,125},// 77
{0,125,130},// 76
{0,120,135},// 75
{0,115,140},// 74
{0,110,145},// 73
{0,105,150},// 72
{0,100,155},// 71
{0,95,160},// 70
{0,90,165},// 69
{0,85,170},// 68
{0,80,175},// 67
{0,75,180},// 66
{0,70,185},// 65
{0,65,190},// 64
{0,60,195},// 63
{0,55,200},// 62
{0,50,205},// 61
{0,45,210},// 60
{0,40,215},// 59
{0,35,220},// 58
{0,30,225},// 57
{0,25,230},// 56
{0,20,235},// 55
{0,15,240},// 54
{0,10,245},// 53
{0,5,250},// 52
{0,0,255},// 51
{0,0,250},// 50
{0,0,245},// 49
{0,0,240},// 48
{0,0,235},// 47
{0,0,230},// 46
{0,0,225},// 45
{0,0,220},// 44
{0,0,215},// 43
{0,0,210},// 42
{0,0,205},// 41
{0,0,200},// 40
{0,0,195},// 39
{0,0,190},// 38
{0,0,185},// 37
{0,0,180},// 36
{0,0,175},// 35
{0,0,170},// 34
{0,0,165},// 33
{0,0,160},// 32
{0,0,155},// 31
{0,0,150},// 30
{0,0,145},// 29
{0,0,140},// 28
{0,0,135},// 27
{0,0,130},// 26
{0,0,125},// 25
{0,0,120},// 24
{0,0,115},// 23
{0,0,110},// 22
{0,0,105},// 21
{0,0,100},// 20
{0,0,95},// 19
{0,0,90},// 18
{0,0,85},// 17
{0,0,80},// 16
{0,0,75},// 15
{0,0,70},// 14
{0,0,65},// 13
{0,0,60},// 12
{0,0,55},// 11
{0,0,50},// 10
{0,0,45},// 9
{0,0,40},// 8
{0,0,35},// 7
{0,0,30},// 6
{0,0,25},// 5
{0,0,20},// 4
{0,0,15},// 3
{0,0,10},// 2
{0,0,5},// 1
{0,0,0},// 0
};
CFile csvFile;
CString strLine;
CString strColor;
CString strColor2;
CString strColor3;

if( csvFile.Open( strFileName,CFile::modeReadWrite ) )
{
for (int i=0;i<256;i++)
{
strLine.Format(_T("%d,%d,%d\r\n"),colorTable[i][0],colorTable[i][1],colorTable[i][2]);
csvFile.Write(strLine,strLine.GetLength()*2);

}
}
csvFile.Close();
return true;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值