|
// ----------------------------------------------------------------------------
//
// Class_Frame_Update_GLI_Disp
//
// Create/update the GLI display image from the work image
//
// ----------------------------------------------------------------------------
int Class_Frame_Update_GLI_Disp( SliceO_Class *pt )
{
SliceO_Frame *frame = (SliceO_Frame *) pt ;
Region_2D update = *(frame->Region_Update_Get()) ;
// --- Get the "work GLI" buffer ---
int **work_gli = frame->Work_GLI_Get() ;
if ( ! work_gli )
return( NULL ) ;
// --- prepare memory for the Display GLI image ---
if ( ! frame->Buf_Disp_GLI ) {
SliceO_Buffer *buf_disp_gli = pt->User_Get( ID_DISP_GLI ) ;
if ( ! buf_disp_gli ) {
// --- prepare an erase buffer in the frame's user memory ---
buf_disp_gli = new SliceO_Buffer( PRIORITY_DISP_GLI ) ;
MEM_CHECK( buf_disp_gli ) ;
buf_disp_gli->Name_Set( "Disp GLI" ) ;
if ( ! buf_disp_gli->Data_New( frame->m_x * frame->m_y * sizeof(int) ) )
return( NULL ) ;
pt->User_Set( ID_DISP_GLI, buf_disp_gli ) ;
// --- The image is new, we want a complete update! ---
update.Set( 0, 0, frame->m_x-1, frame->m_y-1 ) ;
}
assert( buf_disp_gli ) ;
frame->Buf_Disp_GLI = (void *) buf_disp_gli->Data_Get() ;
}
unsigned int *disp_gli = (unsigned int *) frame->Buf_Disp_GLI ;
if ( ! disp_gli )
return( NULL ) ;
frame->Work_GLI_Lock() ;
// --- setup the GLI to Color conversion ---
if ( ! Fct_GLI_2_Color( frame->m_pix_type, frame->gli_scale, frame->gli_offset, frame->val_min, frame->val_max ) ) {
frame->Work_GLI_Unlock() ;
return( NULL ) ;
}
// --- for pixel values, compute 0.0 - 1.0 value ---
for ( int j= (int) update.min_y; j <= (int) update.max_y; j++ ) {
int k = j*frame->m_x + (int) update.min_x ;
for ( int i= (int) update.min_x; i <= (int) update.max_x; i++, k++ ) {
int GLI_val = work_gli[j][i] ;
disp_gli[k] = Fct_GLI_2_Color( GLI_val ) ;
}
}
frame->Work_GLI_Unlock() ;
return( 1 ) ;
}
|