我有一個程序收集隨時間變化的數據。我用Gtk3編寫的程序實時顯示數據。在「渲染」功能中,數據在離屏幕表面上繪製,然後在曝光事件中複製到繪圖區域表面。Gtk移動表面變得模糊
這保留了以前的渲染操作的表面,我想要做的是將圖像向左移動一個步長,然後在右側繪製新數據。淨效應應該是一個向左滾動的圖像,新數據出現在右邊緣。
我到目前爲止的嘗試一直是創建一個新的曲面,使用舊曲面作爲新曲面的來源,然後使用一個班次對其進行繪製,然後使用類似的幾個命令將新曲面繪製回原始,然後添加新的數據。
它有點作品,但圖像變得更模糊,因爲它向左移動,背景白色消失。
有沒有辦法讓它保持清晰並實現我想要實現的目標?
順便說一句,我正在開發GNU/Linux,但該程序確實也在Windows上構建和運行。
James。
//Cairo context for the existing surface. cr = cairo_create (xy_surface); //create a similar surface to the existing surface cairo_surface_t *tmp_surf = cairo_surface_create_similar(xy_surface, CAIRO_CONTENT_COLOR, width-2, height); //create cairo context for the new surface cairo_t *tmp_cr = cairo_create (tmp_surf); source_x = ((gdouble)width * N_SAMPLES/sweep_rate) - 2; dest_x = 0.0; //Set the drawing source for the new surface to be the old surface cairo_set_source_surface (tmp_cr, xy_surface, dest_x - source_x, 0.0); cairo_rectangle (tmp_cr, dest_x, 0, width - 2 - source_x, height); cairo_set_operator(tmp_cr, CAIRO_OPERATOR_SOURCE); cairo_fill (tmp_cr); cairo_destroy(tmp_cr); //clear the existing surface cairo_set_source_rgb(cr, 1, 1, 1); cairo_paint(cr); cairo_set_operator(cr, CAIRO_OPERATOR_ATOP); cairo_set_source_surface(cr, tmp_surf, 0, 0); cairo_paint(cr); cairo_surface_destroy(tmp_surf);
你爲什麼使用運算符ATOP而不是來源還是OVER?是否有透明度? (我認爲ATOP等於SOURCE,相當於沒有任何alpha的OVER) –
絕望。我正在嘗試很多不同的事情。消息來源是正確的。我還需要在使用xy_surface作爲源之前繪製tmp_surf白色。 –
請考慮添加屏幕截圖以使其更清晰。 – unwind