static void drawVertices(JNIEnv* env, jobject, jlong canvasHandle,
                         jint modeHandle, jint vertexCount,
                         jfloatArray jverts, jint vertIndex,
                         jfloatArray jtexs, jint texIndex,
                         jintArray jcolors, jint colorIndex,
                         jshortArray jindices, jint indexIndex,
                         jint indexCount, jlong paintHandle) {
    AutoJavaFloatArray  vertA(env, jverts, vertIndex + vertexCount);
    AutoJavaFloatArray  texA(env, jtexs, texIndex + vertexCount);
    AutoJavaIntArray    colorA(env, jcolors, colorIndex + vertexCount);
    AutoJavaShortArray  indexA(env, jindices, indexIndex + indexCount);

    const float* verts = vertA.ptr() + vertIndex;
    const float* texs = texA.ptr() + vertIndex;
    const int* colors = NULL;
    const uint16_t* indices = NULL;

    if (jcolors != NULL) {
        colors = colorA.ptr() + colorIndex;
    }
    if (jindices != NULL) {
        indices = (const uint16_t*)(indexA.ptr() + indexIndex);
    }

    SkCanvas::VertexMode mode = static_cast<SkCanvas::VertexMode>(modeHandle);
    const Paint* paint = reinterpret_cast<Paint*>(paintHandle);
    get_canvas(canvasHandle)->drawVertices(mode, vertexCount, verts, texs, colors,
                                           indices, indexCount, *paint);
}
示例#2
0
    static void drawVertices(JNIEnv* env, jobject, SkCanvas* canvas,
                             SkCanvas::VertexMode mode, int vertexCount,
                             jfloatArray jverts, int vertIndex,
                             jfloatArray jtexs, int texIndex,
                             jintArray jcolors, int colorIndex,
                             jshortArray jindices, int indexIndex,
                             int indexCount, const SkPaint* paint) {

        AutoJavaFloatArray  vertA(env, jverts, vertIndex + vertexCount);
        AutoJavaFloatArray  texA(env, jtexs, texIndex + vertexCount);
        AutoJavaIntArray    colorA(env, jcolors, colorIndex + vertexCount);
        AutoJavaShortArray  indexA(env, jindices, indexIndex + indexCount);

        const int ptCount = vertexCount >> 1;

        SkPoint* verts;
        SkPoint* texs = NULL;
#ifdef SK_SCALAR_IS_FLOAT
        verts = (SkPoint*)(vertA.ptr() + vertIndex);
        if (jtexs != NULL) {
            texs = (SkPoint*)(texA.ptr() + texIndex);
        }
#else
        int count = ptCount;    // for verts
        if (jtexs != NULL) {
            count += ptCount;   // += for texs
        }
        SkAutoMalloc storage(count * sizeof(SkPoint));
        verts = (SkPoint*)storage.get();        
        const float* src = vertA.ptr() + vertIndex;
        for (int i = 0; i < ptCount; i++) {
            verts[i].set(SkFloatToFixed(src[0]), SkFloatToFixed(src[1]));
            src += 2;
        }
        if (jtexs != NULL) {
            texs = verts + ptCount;
            src = texA.ptr() + texIndex;
            for (int i = 0; i < ptCount; i++) {
                texs[i].set(SkFloatToFixed(src[0]), SkFloatToFixed(src[1]));
                src += 2;
            }
        }
#endif

        const SkColor* colors = NULL;
        const uint16_t* indices = NULL;
        if (jcolors != NULL) {
            colors = (const SkColor*)(colorA.ptr() + colorIndex);
        }
        if (jindices != NULL) {
            indices = (const uint16_t*)(indexA.ptr() + indexIndex);
        }

        canvas->drawVertices(mode, ptCount, verts, texs, colors, NULL,
                             indices, indexCount, *paint);
    }
示例#3
0
void text::render() const{
    const char * p = this->m_text.c_str();
    glDisable( GL_DEPTH_TEST ) ; // also disable the depth test so renders on top
    glPushMatrix();
    glTranslatef(this->m_origin.x(), this->m_origin.y(), this->m_origin.layer());
    glScalef(m_size, m_size, 1); //font size
    //glRotatef(10.0, 0, 0, 1);
    glColor4f(colorR(), colorG(), colorB(), colorA());
    do glutStrokeCharacter( GLUT_STROKE_ROMAN, *p ); while( *(++p) ) ; //GLUT_STROKE_MONO_ROMAN fix width
    glPopMatrix();
    glEnable( GL_DEPTH_TEST ) ; // Turn depth testing back on
}
static void drawBitmapMesh(JNIEnv* env, jobject, jlong canvasHandle, jlong bitmapHandle,
                           jint meshWidth, jint meshHeight, jfloatArray jverts,
                           jint vertIndex, jintArray jcolors, jint colorIndex, jlong paintHandle) {
    const int ptCount = (meshWidth + 1) * (meshHeight + 1);
    AutoJavaFloatArray vertA(env, jverts, vertIndex + (ptCount << 1));
    AutoJavaIntArray colorA(env, jcolors, colorIndex + ptCount);

    const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
    const Paint* paint = reinterpret_cast<Paint*>(paintHandle);
    get_canvas(canvasHandle)->drawBitmapMesh(*bitmap, meshWidth, meshHeight,
            vertA.ptr(), colorA.ptr(), paint);
}
示例#5
0
文件: main.c 项目: Gardenya/island
void setup()
{
    // Initialize AntTweakBar
    TwInit(TW_OPENGL_CORE, NULL);

    bgColor = color(100, 100, 100);
    rectColor = colorA(255, 0, 0, 200);

    // Create a tweak bar
    bar = TwNewBar("TweakBar");
    WindowSizeCB(window, width, height);

    glfwSetWindowSizeCallback(window, WindowSizeCB);
    glfwSetMouseButtonCallback(window, TwEventMouseButtonGLFW);
    glfwSetCursorPosCallback(window, TwEvenCursorPosGLFW);
    glfwSetScrollCallback(window, TwEventScrollGLFW);
    glfwSetKeyCallback(window, TwEventKeyGLFW);
    glfwSetCharCallback(window, TwEventCharGLFW);

    TwDefine(" GLOBAL help='This example shows how to integrate AntTweakBar with GLFW and OpenGL.' "); // Message added to the help bar.
    // Add 'speed' to 'bar': it is a modifable (RW) variable of type TW_TYPE_DOUBLE. Its key shortcuts are [s] and [S].
    TwAddVarRW(bar, "speed", TW_TYPE_DOUBLE, &speed,
               " label='Rot speed' min=0 max=2 step=0.01 keyIncr=s keyDecr=S help='Rotation speed (turns/second)' ");

    // Add 'wire' to 'bar': it is a modifable variable of type TW_TYPE_BOOL32 (32 bits boolean). Its key shortcut is [w].
    TwAddVarRW(bar, "wire", TW_TYPE_BOOL32, &wire,
               " label='Wireframe mode' key=w help='Toggle wireframe display mode.' ");

    // Add 'time' to 'bar': it is a read-only (RO) variable of type TW_TYPE_DOUBLE, with 1 precision digit
    TwAddVarRO(bar, "time", TW_TYPE_DOUBLE, &time, " label='Time' precision=1 help='Time (in seconds).' ");

    // Add 'bgColor' to 'bar': it is a modifable variable of type TW_TYPE_COLOR3F (3 floats color)
    TwAddVarRW(bar, "bgColor", TW_TYPE_COLOR3F, bgColor.rgba, " label='Background color' ");

    // Add 'rectColor' to 'bar': it is a modifable variable of type TW_TYPE_COLOR32 (32 bits color) with alpha
    TwAddVarRW(bar, "rectColor", TW_TYPE_COLOR4F, rectColor.rgba,
               " label='Rect color' alpha help='Color and transparency of the rect.' ");

}
示例#6
0
文件: ofApp.cpp 项目: firmread/parti
void ofApp::update() {
	kinect.update();
	if(kinect.isFrameNew()) {
		float* distancePixels = kinect.getDistancePixels(); // distance in millimeters
		unsigned char* resultPixels = result.getPixels();
		int n = kinect.getWidth() * kinect.getHeight();
		float nearThreshold = panel.getValueF("nearThreshold");
		float farThreshold = panel.getValueF("farThreshold");
		int nearTarget, farTarget;
		bool threshold = panel.getValueB("threshold");
		int thresholdLevel = (nearTarget + farTarget) / 2;
		bool nearWhite = panel.getValueB("nearWhite");
		if(nearWhite) {
			nearTarget = 255;
			farTarget = 0;
		} else {
			nearTarget = 0;
			farTarget = 255;
		}
		if(nearThreshold != farThreshold) {
			for(int i = 0; i < n; i++) {
				float cur = distancePixels[i];
				if(cur != 0) { // only remap nonzeros
				
					// this code will threshold data to white or black
					if(threshold) {
						if(cur > thresholdLevel) {
							if(nearWhite) {
								cur = 0;
							} else {
								cur = 255;
							}
						} else {
							if(nearWhite) {
								cur = 255;
							} else {
								cur = 0;
							}
						}
					}
					
					// alternatively, just remap between 0 and 255
					else {
						cur = ofMap(cur, nearThreshold, farThreshold, nearTarget, farTarget, true);
					}
				}
				resultPixels[i] = cur;
			}
		}
		result.update();
	}
    
    
    
    
//////////////////////////////////////cv//////////////////////////////////////////////
    //	ofBackground(100,100,100);
    
 
    

   grayImage.setFromPixels(result.getPixels(), 640,480);
    
    

    
    //        grayBg = grayImage;		// the = sign copys the pixels from grayImage into grayBg 
    
    
    
    // take the abs value of the difference between background and incoming and then threshold:
    grayDiff.absDiff(grayBg, grayImage);
    grayDiff.threshold(threshold);
    
    grayDiff.blur(5);
    // find contours which are between the size of 20 pixels and 1/3 the w*h pixels.
    // also, find holes is set to true so we will get interior contours as well....
    contourFinder.findContours(grayDiff, 20, (640,480)/3, 10, true);	// find holes

    
    
    // we are dealing with 4 images
    // image a, b, 
    // image mix
    // and the greysacale image: 
    // get the pixels
    
    unsigned char * grayPixels = grayDiff.getPixels();
    unsigned char * colorPixelsA = back.getPixels();
    unsigned char * colorPixelsB = vidPlayer.getPixels();
    unsigned char * mixPixels = mix.getPixels();
    
    
    for (int i = 0; i < 640*480; i++){
        
        // get the color from each color image. 
        
        ofColor colorA( colorPixelsA[i * 3], colorPixelsA[i * 3 + 1], colorPixelsA[i * 3 + 2]);
        ofColor colorB( colorPixelsB[i * 3], colorPixelsB[i * 3 + 1], colorPixelsB[i * 3 + 2]);
        
        // turn grayscale into a pct: 
        
        float pct = ofMap(grayPixels[i], 0, 255, 0,1);
        
        
        // mix the two colors based on pct:
        
        ofColor colorMix = colorA * (1-pct)  + colorB * pct;
        
        // set the color of the pixel in the mix image to the new mixed color
        
        mixPixels[i * 3] = colorMix.r;
        mixPixels[i * 3+1] = colorMix.g;
        mixPixels[i * 3+2] = colorMix.b;
        
        
        
    }
    
    // update the mix image
    
    mix.update();
    
    
      
}
示例#7
0
    static void drawBitmapMesh(JNIEnv* env, jobject, SkCanvas* canvas,
                          const SkBitmap* bitmap, int meshWidth, int meshHeight,
                          jfloatArray jverts, int vertIndex, jintArray jcolors,
                          int colorIndex, const SkPaint* paint) {

        const int ptCount = (meshWidth + 1) * (meshHeight + 1);
        const int indexCount = meshWidth * meshHeight * 6;

        AutoJavaFloatArray  vertA(env, jverts, vertIndex + (ptCount << 1));
        AutoJavaIntArray    colorA(env, jcolors, colorIndex + ptCount);
        
        /*  Our temp storage holds 2 or 3 arrays.
            texture points [ptCount * sizeof(SkPoint)]
            optionally vertex points [ptCount * sizeof(SkPoint)] if we need a
                copy to convert from float to fixed
            indices [ptCount * sizeof(uint16_t)]
        */
        ssize_t storageSize = ptCount * sizeof(SkPoint); // texs[]
#ifdef SK_SCALAR_IS_FIXED
        storageSize += ptCount * sizeof(SkPoint);  // storage for verts
#endif
        storageSize += indexCount * sizeof(uint16_t);  // indices[]

        SkAutoMalloc storage(storageSize);
        SkPoint* texs = (SkPoint*)storage.get();
        SkPoint* verts;
        uint16_t* indices;
#ifdef SK_SCALAR_IS_FLOAT
        verts = (SkPoint*)(vertA.ptr() + vertIndex);
        indices = (uint16_t*)(texs + ptCount);
#else
        verts = texs + ptCount;
        indices = (uint16_t*)(verts + ptCount);
        // convert floats to fixed
        {
            const float* src = vertA.ptr() + vertIndex;
            for (int i = 0; i < ptCount; i++) {
                verts[i].set(SkFloatToFixed(src[0]), SkFloatToFixed(src[1]));
                src += 2;
            }
        }
#endif

        // cons up texture coordinates and indices
        {
            const SkScalar w = SkIntToScalar(bitmap->width());
            const SkScalar h = SkIntToScalar(bitmap->height());
            const SkScalar dx = w / meshWidth;
            const SkScalar dy = h / meshHeight;
            
            SkPoint* texsPtr = texs;
            SkScalar y = 0;
            for (int i = 0; i <= meshHeight; i++) {
                if (i == meshHeight) {
                    y = h;  // to ensure numerically we hit h exactly
                }
                SkScalar x = 0;
                for (int j = 0; j < meshWidth; j++) {
                    texsPtr->set(x, y);
                    texsPtr += 1;
                    x += dx;
                }
                texsPtr->set(w, y);
                texsPtr += 1;
                y += dy;
            }
            SkASSERT(texsPtr - texs == ptCount);
        }
        
        // cons up indices
        {
            uint16_t* indexPtr = indices;
            int index = 0;
            for (int i = 0; i < meshHeight; i++) {
                for (int j = 0; j < meshWidth; j++) {
                    // lower-left triangle
                    *indexPtr++ = index;
                    *indexPtr++ = index + meshWidth + 1;
                    *indexPtr++ = index + meshWidth + 2;
                    // upper-right triangle
                    *indexPtr++ = index;
                    *indexPtr++ = index + meshWidth + 2;
                    *indexPtr++ = index + 1;
                    // bump to the next cell
                    index += 1;
                }
                // bump to the next row
                index += 1;
            }
            SkASSERT(indexPtr - indices == indexCount);
            SkASSERT((char*)indexPtr - (char*)storage.get() == storageSize);
        }

        // double-check that we have legal indices
#ifdef SK_DEBUG
        {
            for (int i = 0; i < indexCount; i++) {
                SkASSERT((unsigned)indices[i] < (unsigned)ptCount);
            }
        }
#endif

        // cons-up a shader for the bitmap
        SkPaint tmpPaint;
        if (paint) {
            tmpPaint = *paint;
        }
        SkShader* shader = SkShader::CreateBitmapShader(*bitmap,
                        SkShader::kClamp_TileMode, SkShader::kClamp_TileMode);
        tmpPaint.setShader(shader)->safeUnref();

        canvas->drawVertices(SkCanvas::kTriangles_VertexMode, ptCount, verts,
                             texs, (const SkColor*)colorA.ptr(), NULL, indices,
                             indexCount, tmpPaint);
    }
示例#8
0
/*
region<int> getDiffer( trackDocument * doc, int areaIndex, int start, int end, int time )
{
	boundaryArea & area = doc->areas[areaIndex];
	boundaryCurve & curve = area.divisions.first();
	boundaryCurveIndex index;
	index.curve = 0;
	index.size = curve.points.size;
	index.start = start;
	index.end = end;
	static array2<bool> flag;
	flag.allocate( doc->width, doc->height );
	region<int> result;
	if ( ! time ) return result;
	area.update( time - 1 );
	area.update( time );
	region<int> prevShape, nowShape;
	{
		list< point2<int> > segments;
		bool checkStart = true;
		for ( boundaryCurveIndex::iterator iti( index ); iti; ++iti ) {
			curve.segment( segments, iti(), time - 1 );
		}
		memset( flag.data, 0, sizeof( bool ) * flag.size );
		for ( list< point2<int> >::iterator itp( segments ); itp; ++itp ) {
			flag( clamp( 0, itp->x, doc->width - 1 ), clamp( 0, itp->y, doc->height - 1 ) ) = true;
		}
		prevShape.set( flag, 0, 0 );
	}
	{
		list< point2<int> > segments;
		bool checkStart = true;
		for ( boundaryCurveIndex::iterator iti( index ); iti; ++iti ) {
			curve.segment( segments, iti(), time );
		}
		memset( flag.data, 0, sizeof( bool ) * flag.size );
		for ( list< point2<int> >::iterator itp( segments ); itp; ++itp ) {
			flag( clamp( 0, itp->x, doc->width - 1 ), clamp( 0, itp->y, doc->height - 1 ) ) = true;
		}
		nowShape.set( flag, 0, 0 );
	}
	region<int> round;
	round = nowShape | prevShape;
	{
		region<int> line;
		point2<int> p1 = curve.points[start]( time - 1 );
		point2<int> p2 = curve.points[start]( time );
		line.line( p1.x, p1.y, p2.x, p2.y );
		round |= line;
	}
	{
		region<int> line;
		point2<int> p1 = curve.points[end]( time - 1 );
		point2<int> p2 = curve.points[end]( time );
		line.line( p1.x, p1.y, p2.x, p2.y );
		round |= line;
	}
	round.fill( result );
	return result;
}
*/
void stateDocument::paint()
{
	trackDocument * doc = trackDocument::get();
	trackView * view = trackView::get();
	if ( ! doc ) return;
	if ( ! view ) return;
	static image viewImage;//画面表示用画像
	viewImage.topdown = false;
	double maxValue = doc->maxValues[doc->currentViewImageIndex];
	double windowLevel = windowLevelBar->get();
	double windowSize = windowSizeBar->get();
	decimal rate = 255.0 / windowSize;
	decimal offset = windowLevel - windowSize / 2;

	imageInterface< pixelLuminance<int16> > * img = & doc->originalImages[doc->currentViewImageIndex];
	switch ( view->mode & trackView::baseImageMask ) {
	case trackView::original:
		break;
	case trackView::vertEdge: 
		img = & doc->verticalEdgeImages[doc->currentViewImageIndex]; 
		break;
	case trackView::horzEdge: 
		img = & doc->horizontalEdgeImages[doc->currentViewImageIndex]; 
		break;
	default:
		offset = 0;
		rate = 0;
		break;
	}
	viewImage.create( img->width, img->height );
	pixel p( 0, 0, 0, 255 );
	if ( rate ) {
		for ( int y = 0; y < img->height; ++y ) {
			for ( int x = 0; x < img->width; ++x ) {
				p.r = p.g = p.b = static_cast<int8>( clamp<decimal>( 0, 
					( img->getInternal( x, y ).y - offset ) * rate, 255.0 ) );
				viewImage.setInternal( x, y, p );
			}
		}
	} else {
		for ( int y = 0; y < img->height; ++y ) {
			for ( int x = 0; x < img->width; ++x ) {
				viewImage.setInternal( x, y, p );
			}
		}
	}
	//波の表示用の色
	pixel colorV( 0, 0, 255, 255 );
	pixel colorH( 0, 255, 0, 255 );
	pixel colorA( 255, 255, 0, 255 );
	pixel colorD( 255, 0, 255, 255 );
	//論文投稿用の表示
	if ( false && ( ( view->mode & trackView::baseImageMask ) == trackView::none ) ) {
		p.r = p.g = p.b = 0;
		for ( int y = 0; y < img->height; ++y ) {
			for ( int x = 0; x < img->width; ++x ) {
				viewImage.setInternal( x, y, p );
			}
		}
		for ( int t = 0; t < doc->sizeTime(); ++t ) {
			pixel c;
			if ( view->mode & trackView::vertical ) {
				for ( array< list<link> >::iterator ita( doc->verticalLinks ); ita; ++ita ) {
					for ( list<link>::iterator it( ita() ); it; ++it ) {
						c.r = c.g = c.b = clamp<int>( 0, it->reliability * 255, 255 );
						int x = it->cx * doc->wave[t] + it->bx;
						int y = it->cy * doc->wave[t] + it->by;
						viewImage.set( x, y, blendMax( viewImage.get( x, y ), c ) );
					}
				}
			}
			if ( view->mode & trackView::horizontal ) {
				for ( array< list<link> >::iterator ita( doc->horizontalLinks ); ita; ++ita ) {
					for ( list<link>::iterator it( ita() ); it; ++it ) {
						c.r = c.g = c.b = clamp<int>( 0, it->reliability * 255, 255 );
						int x = it->cx * doc->wave[t] + it->bx;
						int y = it->cy * doc->wave[t] + it->by;
						viewImage.set( x, y, blendMax( viewImage.get( x, y ), c ) );
					}
				}
			}
			if ( view->mode & trackView::ascent ) {
				for ( array< list<link> >::iterator ita( doc->ascentLinks ); ita; ++ita ) {
					for ( list<link>::iterator it( ita() ); it; ++it ) {
						c.r = c.g = c.b = clamp<int>( 0, it->reliability * 255, 255 );
						int x = it->cx * doc->wave[t] + it->bx;
						int y = it->cy * doc->wave[t] + it->by;
						viewImage.set( x, y, blendMax( viewImage.get( x, y ), c ) );
					}
				}
			}
			if ( view->mode & trackView::descent ) {
				for ( array< list<link> >::iterator ita( doc->descentLinks ); ita; ++ita ) {
					for ( list<link>::iterator it( ita() ); it; ++it ) {
						c.r = c.g = c.b = clamp<int>( 0, it->reliability * 255, 255 );
						int x = it->cx * doc->wave[t] + it->bx;
						int y = it->cy * doc->wave[t] + it->by;
						viewImage.set( x, y, blendMax( viewImage.get( x, y ), c ) );
					}
				}
			}
		}
	} else
	if ( view->mode != trackView::original ) {
/*
		if ( view->mode & trackView::vertical ) {
			checkMaximum<double> mx;
			for ( array< list<link> >::iterator ita( doc->verticalLinks ); ita; ++ita ) {
				for ( list<link>::iterator it( ita() ); it; ++it ) {
					mx( it->intensity );
				}
			}
			for ( array< list<link> >::iterator ita( doc->verticalLinks ); ita; ++ita ) {
				for ( list<link>::iterator it( ita() ); it; ++it ) {
					pixel c = colorV;
					c.a = clamp<int>( 0, c.a * it->intensity / mx(), 255 );
					int x = it->cx * doc->wave[doc->currentViewImageIndex] + it->bx;
					int y = it->cy * doc->wave[doc->currentViewImageIndex] + it->by;
					viewImage.set( x, y, blend( viewImage.get( x, y ), c ) );
				}
			}
		}
		if ( view->mode & trackView::horizontal ) {
			checkMaximum<double> mx;
			for ( array< list<link> >::iterator ita( doc->horizontalLinks ); ita; ++ita ) {
				for ( list<link>::iterator it( ita() ); it; ++it ) {
					mx( it->intensity );
				}
			}
			for ( array< list<link> >::iterator ita( doc->horizontalLinks ); ita; ++ita ) {
				for ( list<link>::iterator it( ita() ); it; ++it ) {
					pixel c = colorH;
					c.a = clamp<int>( 0, c.a * it->intensity / mx(), 255 );
					int x = it->cx * doc->wave[doc->currentViewImageIndex] + it->bx;
					int y = it->cy * doc->wave[doc->currentViewImageIndex] + it->by;
					viewImage.set( x, y, blend( viewImage.get( x, y ), c ) );
				}
			}
		}
		if ( view->mode & trackView::ascent ) {
			checkMaximum<double> mx;
			for ( array< list<link> >::iterator ita( doc->ascentLinks ); ita; ++ita ) {
				for ( list<link>::iterator it( ita() ); it; ++it ) {
					mx( it->intensity );
				}
			}
			for ( array< list<link> >::iterator ita( doc->ascentLinks ); ita; ++ita ) {
				for ( list<link>::iterator it( ita() ); it; ++it ) {
					pixel c = colorA;
					c.a = clamp<int>( 0, c.a * it->intensity / mx(), 255 );
					int x = it->cx * doc->wave[doc->currentViewImageIndex] + it->bx;
					int y = it->cy * doc->wave[doc->currentViewImageIndex] + it->by;
					viewImage.set( x, y, blend( viewImage.get( x, y ), c ) );
				}
			}
		}
		if ( view->mode & trackView::descent ) {
			checkMaximum<double> mx;
			for ( array< list<link> >::iterator ita( doc->descentLinks ); ita; ++ita ) {
				for ( list<link>::iterator it( ita() ); it; ++it ) {
					mx( it->intensity );
				}
			}
			for ( array< list<link> >::iterator ita( doc->descentLinks ); ita; ++ita ) {
				for ( list<link>::iterator it( ita() ); it; ++it ) {
					pixel c = colorD;
					c.a = clamp<int>( 0, c.a * it->intensity / mx(), 255 );
					int x = it->cx * doc->wave[doc->currentViewImageIndex] + it->bx;
					int y = it->cy * doc->wave[doc->currentViewImageIndex] + it->by;
					viewImage.set( x, y, blend( viewImage.get( x, y ), c ) );
				}
			}
		}

		*/
		if ( view->mode & trackView::vertical ) {
			for ( array< list<link> >::iterator ita( doc->verticalLinks ); ita; ++ita ) {
				for ( list<link>::iterator it( ita() ); it; ++it ) {
					pixel c = colorV;
					c.a = clamp<int>( 0, c.a * it->reliability, 255 );
					int x = it->cx * doc->wave[doc->currentViewImageIndex] + it->bx;
					int y = it->cy * doc->wave[doc->currentViewImageIndex] + it->by;
					viewImage.set( x, y, blend( viewImage.get( x, y ), c ) );
				}
			}
		}
		if ( view->mode & trackView::horizontal ) {
			for ( array< list<link> >::iterator ita( doc->horizontalLinks ); ita; ++ita ) {
				for ( list<link>::iterator it( ita() ); it; ++it ) {
					pixel c = colorH;
					c.a = clamp<int>( 0, c.a * it->reliability, 255 );
					int x = it->cx * doc->wave[doc->currentViewImageIndex] + it->bx;
					int y = it->cy * doc->wave[doc->currentViewImageIndex] + it->by;
					viewImage.set( x, y, blend( viewImage.get( x, y ), c ) );
				}
			}
		}
		if ( view->mode & trackView::ascent ) {
			for ( array< list<link> >::iterator ita( doc->ascentLinks ); ita; ++ita ) {
				for ( list<link>::iterator it( ita() ); it; ++it ) {
					pixel c = colorA;
					c.a = clamp<int>( 0, c.a * it->reliability, 255 );
					int x = it->cx * doc->wave[doc->currentViewImageIndex] + it->bx;
					int y = it->cy * doc->wave[doc->currentViewImageIndex] + it->by;
					viewImage.set( x, y, blend( viewImage.get( x, y ), c ) );
				}
			}
		}
		if ( view->mode & trackView::descent ) {
			for ( array< list<link> >::iterator ita( doc->descentLinks ); ita; ++ita ) {
				for ( list<link>::iterator it( ita() ); it; ++it ) {
					pixel c = colorD;
					c.a = clamp<int>( 0, c.a * it->reliability, 255 );
					int x = it->cx * doc->wave[doc->currentViewImageIndex] + it->bx;
					int y = it->cy * doc->wave[doc->currentViewImageIndex] + it->by;
					viewImage.set( x, y, blend( viewImage.get( x, y ), c ) );
				}
			}
		}
	}
	/*
	for ( int i = 0; i < 4; ++i ) {
		for ( array2<flicker>::iterator it( doc->flickers[i] ); it; ++it ) {
			if ( it->value < 0.25 ) continue;
			pixel c( 0, 255, 0, 255 );
			c.a = clamp<int>( 0, c.a * it->value, 128 );
			const point2<int> & pos = it->lnk.position( doc->currentViewImageIndex, doc->wave );
			int x = pos.x, y = pos.y;
			viewImage.set( x, y, blend( viewImage.get( x, y ), c ) );
		}
	}
	*/
	for ( list< boundaryArea >::iterator it( doc->areas ); it; ++it ) {
		it->update( doc->currentViewImageIndex );
	}
	list< point2<int> > points;
	pixel linecolor( 255, 255, 0, 128 );
	pixel pointcolor( 0, 255, 0, 255 );
	pixel itnitialpointcolor( 0, 0, 255, 255 );
	pixel editedpointcolor( 255, 0, 0, 255 );
	/*
	for ( list< boundaryArea >::iterator it( doc->areas ); it; ++it ) {
		boundaryArea & area = it();
		if ( ! area.enable ) continue;
		pixel areacolor( 0, 0, 0, 64 );
		for ( list< boundaryPart >::iterator ita( area.parts ); ita; ++ita ) {
			areacolor.r = rand() % 256;
			areacolor.g = rand() % 256;
			areacolor.b = rand() % 256;
			areacolor.a = 128;
			boundaryPart & part = ita();
			for ( region<int>::iterator itp( part.shapes[doc->currentViewImageIndex] ); itp; ++itp ) {
				int x = itp->x;
				int y = itp->y;
				viewImage.set( x, y, blend( viewImage.get( x, y ), areacolor ) );
			}
		}
	}
	*/
	for ( list< boundaryArea >::iterator it( doc->areas ); it; ++it ) {
		//曲線の表示
		if ( doc->show_curve )
		{
			for ( list< point2<int> >::iterator itp( it->boundaryCurves[doc->currentViewImageIndex] ); itp; ++itp ) {
				const point2<int> & p = itp();
				int x = p.x;
				int y = p.y;
				viewImage.set( x, y, blend( viewImage.get( x, y ), linecolor ) );
			}
		}
		//制御点の表示
		for ( list<boundaryPoint*>::iterator itc( it->controlPoints ); itc; ++itc ) {
			boundaryPoint & bp = *itc();
			const point2<int> & p = bp( doc->currentViewImageIndex );
			pixel c;
			switch ( bp.type( doc->currentViewImageIndex ) ) {
			case boundaryPointFrame::typeInitial: c = itnitialpointcolor; break;
			case boundaryPointFrame::typeEdited: c = editedpointcolor; break;
			case boundaryPointFrame::typeInterpolated: c = pointcolor; break;
			default: c = pointcolor; break;
			}
			for ( int y = p.y - 1; y <= p.y + 1; ++y ) {
				for ( int x = p.x - 1; x <= p.x + 1; ++x ) {
					viewImage.set( x, y, blend( viewImage.get( x, y ), c ) );
				}
			}
		}
	}
	paint( viewImage );
}