mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:47:44 +00:00
PixelPaint: Avoid division-by-zero in HistogramWidget
This is more of a hack fix than anything else, but let's stop PixelPaint from infinite-looping in HistogramWidget::paint_event().
This commit is contained in:
parent
9c1ee8cbd1
commit
28714deff6
1 changed files with 4 additions and 4 deletions
|
@ -89,10 +89,10 @@ ErrorOr<void> HistogramWidget::rebuild_histogram_data()
|
|||
m_widget_height = height();
|
||||
|
||||
for (int i = 0; i < 256; i++) {
|
||||
m_data.red[i] = (static_cast<float>(m_data.red[i]) / max_color_frequency) * m_widget_height;
|
||||
m_data.green[i] = (static_cast<float>(m_data.green[i]) / max_color_frequency) * m_widget_height;
|
||||
m_data.blue[i] = (static_cast<float>(m_data.blue[i]) / max_color_frequency) * m_widget_height;
|
||||
m_data.brightness[i] = (static_cast<float>(m_data.brightness[i]) / max_brightness_frequency) * m_widget_height;
|
||||
m_data.red[i] = m_data.red[i] != 0 ? (static_cast<float>(m_data.red[i]) / max_color_frequency) * m_widget_height : 0;
|
||||
m_data.green[i] = m_data.green[i] != 0 ? (static_cast<float>(m_data.green[i]) / max_color_frequency) * m_widget_height : 0;
|
||||
m_data.blue[i] = m_data.blue[i] != 0 ? (static_cast<float>(m_data.blue[i]) / max_color_frequency) * m_widget_height : 0;
|
||||
m_data.brightness[i] = m_data.brightness[i] != 0 ? (static_cast<float>(m_data.brightness[i]) / max_brightness_frequency) * m_widget_height : 0;
|
||||
}
|
||||
|
||||
update();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue