Форум программистов, компьютерный форум, киберфорум
С++ для начинающих
Войти
Регистрация
Восстановить пароль
Карта форума Темы раздела Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.83/6: Рейтинг темы: голосов - 6, средняя оценка - 4.83
0 / 0 / 0
Регистрация: 22.05.2012
Сообщений: 16
1

Error C2065: col_gray: необъявленный идентификатор

15.06.2015, 21:48. Показов 1177. Ответов 3
Метки нет (Все метки)

Author24 — интернет-сервис помощи студентам
C++
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
#include "stdafx.h"
#include "lab01.h"
 
lab07::lab07() : m_pBits( 0 )
{ 
    m_Imps.push_back( new s_imp_gray_scale );
    m_Imps.push_back( new s_imp_sharp );
    m_Imps.push_back( new s_imp_blur );
}
 
bool lab07::Input( const char* image_file )
{
    if( !m_Src.load( image_file ) )
        return false;
 
    return true;
}
 
void lab07::Init()
{
    for( t_imps::const_iterator i = m_Imps.begin(), e = m_Imps.end(); i != e; ++i )
        (*i)->Upload( &m_Src );
}
 
void lab07::Process()
{
    int cnt = 0, num = 0;
    char buf[32];
    for( t_imps::const_iterator i = m_Imps.begin(), e = m_Imps.end(); i != e; ++i, ++num )
    {
        if( (*i)->IsEnd() )
        {
            if( (*i)->IsReady() )
            {   sprintf_s( buf, sizeof( buf ), "result_%02u.tga", num + 1 );
                (*i)->Result().save( buf );
                (*i)->SaveOk();
            }// if( (*i)->IsReady() )
            continue;
        }// if( (*i)->IsEnd() )
 
        (*i)->Process();
        ++cnt;
    }// for( t_imps::const_iterator i = m_Imps.begin(), e = m_Imps.end(); i != e; ++i, ++num )
 
    if( !cnt )
    {
        if( main::m_iAuto <= 1 )
            main::m_iAuto = 2;
 
    }// if( !cnt )
 
}
 
 
void lab07::PrintResults( HDC wdc, HWND wnd ) const
{
    if( !m_Src.width() || m_Imps.empty() )
        return;
 
    RECT rc = { 0 };
    GetClientRect( wnd, &rc );
 
    static HDC dc = CreateCompatibleDC( 0 );
    static HDC mem_dc = CreateCompatibleDC( 0 );
    static HBITMAP bmp = CreateCompatibleBitmap( GetDC( 0 ), rc.right, rc.bottom );
 
    SelectObject( dc, bmp );
 
    HDC out_dc = wdc;
    wdc = dc;
 
    const COLORREF col_dgray = RGB( 80, 80, 80 );
    const COLORREF col_orange = RGB( 224, 112, 0 );
 
    HPEN pen_orange = CreatePen( PS_SOLID, 3, col_orange );
    HPEN pen_dgray = CreatePen( PS_SOLID, 1, col_dgray );
 
    HBRUSH brush_white = CreateSolidBrush( col_white );
 
 
    SelectObject( wdc, brush_white );
    SelectObject( wdc, pen_dgray );
    Rectangle( wdc, rc.left, rc.top, rc.right, rc.bottom );
 
    int cnt = int( m_Imps.size() );
 
    wchar_t buf[256];
    int szw = rc.right - rc.left, bx = szw / 24, sw = szw - bx * 4, firstx = bx * 3;
    int szh = rc.bottom - rc.top, by = szh / 12, sh = szh - by * 2;
    int stepy = sh / cnt, y = by + stepy;
    SIZE siz = { 0 };
 
    static HFONT fnt_dig = CreateFont( 12, 0, 0, 0, 200, 0, 0, 0, 0, 0, 0, 0, 0, L"Arial" );
    static HFONT fnt = CreateFont( 15, 0, 0, 0, 200, 0, 0, 0, 0, 0, 0, 0, 0, L"Arial" );
 
    static int scr_width = sw, scr_height = stepy - 8;
    static BITMAPINFO bmi =
     { { sizeof( BITMAPINFOHEADER ), scr_width, scr_height, 1, 32, 0, 0, 0, 0, 0, 0 } };
    static HBITMAP mem = CreateDIBSection( mem_dc, &bmi, DIB_RGB_COLORS, &m_pBits, 0, 0 );
 
    SelectObject( mem_dc, mem );
    SetBkMode( wdc, OPAQUE );
 
    {
        SetTextColor( wdc, col_black );
        SetBkColor( wdc, col_white );
        SelectObject( wdc, fnt );
        int sl = wsprintf( buf, (   main::m_iAuto == 1 ?
             L"Tab - отключить автоматический режим" :
            main::m_iAuto == 0 ? 
            L"Tab - включить автоматический режим   Enter - один шаг сортировки" :
            L"Обработка завершена. Нажмите любую клавишу для повторной обработки" )       );
        GetTextExtentPoint32( wdc, buf, sl, &siz ); 
        TextOut( wdc, ( szw - siz.cx ) / 2, 2, buf, sl );
    }
 
    SelectObject( wdc, pen_orange );
 
    for( t_imps::const_iterator i = m_Imps.begin(), e = m_Imps.end(); i != e; ++i, y += stepy )
    {
        s_imp* imp = (*i);
 
        SetBkColor( wdc, col_white );
        SelectObject( wdc, fnt );
 
        bool end = imp->IsEnd();
        {   SetTextColor( wdc, col_black );
            int sl = wsprintf( buf, L"%lS", imp->Name() );
            GetTextExtentPoint32( wdc, buf, sl, &siz ); 
            TextOut( wdc, 6, y - siz.cy * 3, buf, sl );
        }
        SetTextColor( wdc, end ? col_dgray : col_gray );
        {   int sl = wsprintf( buf, L"строка:%-4u (%-4u)", imp->Line(), m_Src.height() );
            GetTextExtentPoint32( wdc, buf, sl, &siz ); 
            TextOut( wdc, 6, y - siz.cy * 2, buf, sl );
        }
        {   int ops = imp->Ops() / 1000;
            int sl = wsprintf( buf, L"тыс. опер:%-4u", ops );
            GetTextExtentPoint32( wdc, buf, sl, &siz ); 
            TextOut( wdc, 6, y - siz.cy, buf, sl );
        }
 
        if( end )
        {
 
            int sl = wsprintf( buf, L"ЗАВЕРШЕНО" );
            TextOut( wdc, 6, y, buf, sl );
 
        }// if( end )
 
        SelectObject( wdc, fnt_dig );
 
        int width = m_Src.width(), height = m_Src.height();
 
        int max_scr_width = scr_width / 2;
        max_scr_width = min( width, max_scr_width );
        int line = imp->Line(), szy = min( height, scr_height );
 
        const h_image& res = imp->Result();
 
        int offsx = max( 0, width - max_scr_width ) / 2;
 
        t_color* p = static_cast<t_color*>( m_pBits );
 
        int roll_y = 0;
        if( end || line == 0 )
        {
            int offsy = max( 0, height - szy ) / 2;
            for( int iy = 0; iy < szy; ++iy )
            {
                for( int ix = 0; ix < max_scr_width; ++ix )
                {
                    t_color src = m_Src.pixel( ix + offsx, iy + offsy );
                    t_color dst = res.pixel( ix + offsx, iy + offsy );
 
                    p[ix + iy * scr_width] = win_color( src );
                    p[( ix + scr_width / 2 ) + iy * scr_width] = win_color( dst );
                    
                }// for( int ix = 0; ix < max_scr_width; ++ix )
 
            }// for( int iy = 0; iy < szy; ++iy )
 
        }// if( end || line == 0 )
        else
        {
            int bias_y = szy * 2 / 3;
            if( line > bias_y )
                roll_y = line - bias_y;
 
            if( szy + roll_y >= height )
                roll_y -= ( szy + roll_y ) - height;
 
 
            for( int iy = 0; iy < szy; ++iy )
            {
                int yy = iy + roll_y;
                if( yy < 0 )
                    continue;
 
                for( int ix = 0; ix < max_scr_width; ++ix )
                {
                    t_color src = m_Src.pixel( ix + offsx, yy );
                    t_color dst = res.pixel( ix + offsx, yy );
 
                    p[ix + iy * scr_width] = win_color( src );
                    p[ix + scr_width / 2 + iy * scr_width] = win_color( dst );
                    
                }// for( int ix = 0; ix < max_scr_width; ++ix )
 
            }// for( int iy = 0; iy < szy; ++iy )
 
        }// else if( end || line == 0 )
 
        int view_y = scr_height - szy;
        BitBlt( wdc, firstx, y - szy, max_scr_width, szy, mem_dc, 0, view_y, SRCCOPY );
        BitBlt( wdc, firstx + max_scr_width + 8, y - szy, max_scr_width, szy,
             mem_dc, scr_width / 2, view_y, SRCCOPY );
 
        if( !end && line )
        {
            int line_y = y - line + roll_y;
            MoveToEx( wdc, firstx, line_y, 0 );
            LineTo( wdc, firstx + max_scr_width * 2 + 8, line_y );
        }// if( !end && line )
 
    }// for( t_imps::const_iterator i = m_Imps.begin(), e = m_Imps.end(); i != e; ++i, y += stepy )
 
    DeleteObject( pen_orange );
    DeleteObject( pen_dgray );
 
    DeleteObject( brush_white );
 
    BitBlt( out_dc, 0, 0, rc.right, rc.bottom, wdc, 0, 0, SRCCOPY );
}
 
 
//считать изображение
bool lab07::h_tga_image::load( const char* img_name )
{
    data.clear();
    wid = hei = 0;
    s_tga_header header;
 
    bool res = false;
    FILE* f = fopen( img_name, "rb" );
    if( !f )
        goto lExit;
 
    fread( &header, 1, sizeof( header ), f );
 
    int it = header.image_type & TGA_FMT_MASK;
    if( it != TGA_TRUECOLOR && it != TGA_BW ) goto lExit;
 
    int components = header.bpp / 8, line_size = header.width * components;
 
    if( components != 1 && components != 3 && components != 4 ) goto lExit;
    if( header.is_rle() ) goto lExit;
 
    wid = header.width;
    hei = header.height;
    int img_size = wid * hei;
    data.resize( img_size );
 
    fseek( f, header.id_len, SEEK_CUR );
 
    switch( components )
    {
    case 1:
    case 3:
        {
            int pit = wid * components;
            vector<t_byte> buf( pit );
            for( int y = 0, p = 0; y < hei; ++y )
            {
                fread( &buf[0], components, wid, f );
                for( int x = 0; x < pit; x += components, ++p )
                {
                    t_color blue, green, red;
                    if( components == 1 )
                        blue = green = red = buf[x];
                    else
                    {   blue = buf[x + 0];
                        green = buf[x + 1];
                        red = buf[x + 2];
                    }// else if( components == 1 )
 
                    data[p] = red | ( green << 8 ) | ( blue << 16 ) | 0xff000000UL;
                }// for( int x = 0; x < pit; x += components, ++p )
            }// for( int y = 0, p = 0; y < hei; ++y )
            break;
        }
    case 4:
        {   fread( &data[0], sizeof( t_color ), img_size, f );
            break;
        }
 
    }// switch( components )
    res = true;
lExit:;
    if( f ) fclose( f );
    return res;
}
 
//записать изображение
bool lab07::h_tga_image::save( const char* img_name ) const
{
    bool res = false;
    s_tga_header header;
    if( data.empty() || !wid || !hei ) goto lExit;
 
    FILE* f = fopen( img_name, "wb" );
    if( !f ) goto lExit;
 
    header.color_type = TGA_NO_COLORMAP;
    header.image_type = TGA_TRUECOLOR;
 
    header.width = (t_word) wid;
    header.height = (t_word) hei;
    header.bpp = (t_byte) ( sizeof( t_color ) * 8 );
 
    fwrite( &header, sizeof( header ), 1, f );
    {
        t_colors temp_colors( data );
        for( t_colors::iterator i = temp_colors.begin(), e = temp_colors.end(); i != e; ++i )
            *i = win_color( *i ) | ( (*i) & 0xff000000UL );
 
 
        fwrite( &temp_colors[0], sizeof( t_color ), wid * hei, f );
    }
    res = true;
 
lExit:;
    if( f ) fclose( f );
    return res;
}
void lab07::s_imp_gray_scale::Process()
{
    if( IsEnd() ) return;
 
    int wid = src->width(), y = cur_y;
    for( int x = 0; x < wid; ++x )
    {
        t_color c = cur_pixel( x );
        int i = lum( c );
        result.set_pixel( x, y, color( i, i, i ) );
    }// for( int x = 0; x < wid; ++x )
 
    _add_op( wid );
    next();
}
 
void lab07::s_imp_sharp::Process()
{
    if( IsEnd() ) return;
 
    const int kernel_size = 8, sharp_level = 6;
    static const int offs[] =
    {
        -1, -1,  0, -1,  1, -1, 
        -1,  0,          1,  0, 
        -1,  1,  0,  1,  1,  1, 
    };
 
 
    int wid = src->width(), y = cur_y;
    for( int x = 0; x < wid; ++x )
    {
        t_color c = cur_pixel( x );
        int r = red( c ), g = green( c ), b = blue( c );
        int r1 = 0, g1 = 0, b1 = 0;
        for( int o = 0; o < kernel_size * 2; o += 2 )
        {   t_color c1 = src->pixel( x + offs[o + 0], y + offs[o + 1] );
            r1 += red( c1 ); g1 += green( c1 ); b1 += blue( c1 );
        }// for( int o = 0; o < kernel_size * 2; o += 2 )
 
        r += ( r * kernel_size - r1 ) / sharp_level;
        g += ( g * kernel_size - g1 ) / sharp_level;
        b += ( b * kernel_size - b1 ) / sharp_level;
 
        result.set_pixel( x, y, color( r, g, b ) );
    }// for( int x = 0; x < wid; ++x )
 
    _add_op( wid * 8 );
    next();
}
 
void lab07::s_imp_blur::Process()
{
    if( IsEnd() ) return;
 
    const int kernel_size = 8;
    static const int offs[] =
    {
        -1, -1,  0, -1,  1, -1, 
        -1,  0,          1,  0, 
        -1,  1,  0,  1,  1,  1, 
    };
 
 
    int wid = src->width(), y = cur_y;
    for( int x = 0; x < wid; ++x )
    {
        t_color c = cur_pixel( x );
        float sumw = 1.f;
        float r = red( c ) * sumw, g = green( c ) * sumw, b = blue( c ) * sumw;
        for( int o = 0; o < kernel_size * 2; o += 2 )
        {
            int ix = offs[o + 0], iy = offs[o + 1];
            t_color c1 = src->pixel( x + ix, y + iy );
            float w = 1.f / sqrtf( float( ix * ix + iy * iy ) );
            r += red( c1 ) * w; g += green( c1 ) * w; b += blue( c1 ) * w;
            sumw += w;
        }// for( int o = 0; o < kernel_size * 2; o += 2 )
 
        r /= sumw; g /= sumw; b /= sumw;
 
        result.set_pixel( x, y, color( int( r + 0.5f ), int( g + 0.5f ), int( b + 0.5f ) ) );
    }// for( int x = 0; x < wid; ++x )
 
    _add_op( wid * 8 );
 
    next();
}
Лабораторка непонятная какая то. Нужно обработать изображение в формате тга фильтрами шумами и так далее. а этот необъявленный идентификатор не дает компилировать работу. Таких ошибок пока что только 6
Помогите пожалуйста)
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
15.06.2015, 21:48
Ответы с готовыми решениями:

Error C2065: необъявленный идентификатор
В учебнике пишут, что если оператор new не может выделить память для нового объекта, он возвратит...

Error C2065: i: необъявленный идентификатор
Вроде все правильно и лупит ошибку кто что подскажет?! #include &quot;stdafx.h&quot; #include &lt;iostream&gt;...

Error C2065: cout: необъявленный идентификатор
Доброго времени суток. Решил научиться программированию, по книге. Автор рассматривает...

Error C2065: cout: необъявленный идентификатор
видаёт мне такую ошибку: 1&gt;c:\documents and settings\администратор.home-8a34687735\мои...

3
88 / 84 / 31
Регистрация: 18.11.2013
Сообщений: 390
15.06.2015, 22:22 2
в 72ой строчке заменить
const COLORREF col_dgray = RGB( 80, 80, 80 );
на
const COLORREF col_gray = RGB( 80, 80, 80 );
0
lss
941 / 869 / 355
Регистрация: 10.10.2012
Сообщений: 2,706
15.06.2015, 23:23 3
Цитата Сообщение от Krock21rus Посмотреть сообщение
в 72ой строчке заменить
const COLORREF col_dgray = RGB( 80, 80, 80 );
на
const COLORREF col_gray = RGB( 80, 80, 80 );
А тут тогда что на что менять (132)?
Цитата Сообщение от vladislav1809 Посмотреть сообщение
SetTextColor( wdc, end ? col_dgray : col_gray );
0
88 / 84 / 31
Регистрация: 18.11.2013
Сообщений: 390
15.06.2015, 23:45 4
не знаю, тогда у вас просто не обьявлена переменная col_gray, добавьте после 72ой строчки
const COLORREF col_gray = RGB( 160, 160, 160 );
1
15.06.2015, 23:45
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
15.06.2015, 23:45
Помогаю со студенческими работами здесь

error C2065: eof: необъявленный идентификатор
#include &quot;StdAfx.h&quot; int getline(char s, int lim) { int c,i; for(i=0; i&lt;lim-1 &amp;&amp;...

Error C2065: xlineMAX: необъявленный идентификатор
Вид исходного файла: INLINE : 233 XLINE : 202 668417,50000 565878,00000 995,87421 ...

Error C2065: lpConsoleTitle: необъявленный идентификатор
Как исправить? HWND hwnd; char Title; int iWidth =...

Страуструп: error C2065: i–1: необъявленный идентификатор
Выполняю код по книге Стауструпа, в Visual C++ 2010. При компиляции выдается ошибка(в предпоследней...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
4
Ответ Создать тему
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2024, CyberForum.ru