Skip to content

Commit 1b1421f

Browse files
authored
fix: Consistent wp usage in raster RGB extraction (fixes #1349) (#1350)
fix: Consistent wp usage in raster RGB extraction (fixes #1349) Summary - Replace real(real64) with real(wp) and remove redundant local iso_fortran_env imports in raster RGB extraction routines. - Aligns with repo style and avoids kind mismatches if wp changes. Changes - src/backends/raster/fortplot_raster_rendering.f90: use wp in raster_extract_rgb_data - src/backends/raster/fortplot_raster.f90: use wp in raster_extract_rgb_data_context Verification Commands run: - make build - make test-ci - make verify-artifacts Key outputs: - ALL TESTS PASSED (fpm test) - CI essential test suite completed successfully - Artifact verification passed (examples under output/example/fortran/*) - e.g., output/example/fortran/pcolormesh_demo/pcolormesh_basic.pdf contains RGB Image XObject - ylabel stripe checks passed for output/example/fortran/ylabel_left/*.png No functional changes observed; this is a consistency cleanup. Reviewer updates - Also aligned wp usage in animation extract API and ASCII backend support. - Rebuilt, re-ran test-ci and verify-artifacts; all passed locally.
1 parent b728c51 commit 1b1421f

File tree

5 files changed

+12
-15
lines changed

5 files changed

+12
-15
lines changed

src/animation/fortplot_animation_rendering.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module fortplot_animation_rendering
2-
use iso_fortran_env, only: real64, wp => real64
2+
use iso_fortran_env, only: wp => real64
33
use fortplot_figure_core, only: figure_t, plot_data_t
44
use fortplot_utils, only: initialize_backend
55
implicit none
@@ -14,7 +14,7 @@ module fortplot_animation_rendering
1414

1515
subroutine extract_frame_rgb_data(fig, rgb_data, status)
1616
type(figure_t), intent(inout) :: fig
17-
real(real64), intent(out) :: rgb_data(:,:,:)
17+
real(wp), intent(out) :: rgb_data(:,:,:)
1818
integer, intent(out) :: status
1919

2020
status = 0

src/backends/ascii/fortplot_ascii.f90

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,16 +374,15 @@ end subroutine ascii_calculate_legend_position
374374

375375
subroutine ascii_extract_rgb_data(this, width, height, rgb_data)
376376
!! Extract RGB data from ASCII backend (not supported - dummy data)
377-
use, intrinsic :: iso_fortran_env, only: real64
378377
class(ascii_context), intent(in) :: this
379378
integer, intent(in) :: width, height
380-
real(real64), intent(out) :: rgb_data(width, height, 3)
379+
real(wp), intent(out) :: rgb_data(width, height, 3)
381380

382381
! Reference otherwise-unused member without unreachable branch
383382
associate(unused_w => this%width); end associate
384383

385384
! ASCII backend doesn't have RGB data for animation - fill with dummy data
386-
rgb_data = 0.0_real64 ! Black background
385+
rgb_data = 0.0_wp ! Black background
387386
end subroutine ascii_extract_rgb_data
388387

389388
subroutine ascii_get_png_data(this, width, height, png_data, status)

src/backends/ascii/fortplot_ascii_backend_support.f90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module fortplot_ascii_backend_support
77
!! Author: fortplot contributors
88

99
use fortplot_plot_data, only: plot_data_t
10-
use, intrinsic :: iso_fortran_env, only: wp => real64, real64
10+
use, intrinsic :: iso_fortran_env, only: wp => real64
1111
implicit none
1212

1313
private
@@ -19,10 +19,10 @@ module fortplot_ascii_backend_support
1919
subroutine extract_ascii_rgb_data(width, height, rgb_data)
2020
!! Extract RGB data from ASCII backend (not supported - dummy data)
2121
integer, intent(in) :: width, height
22-
real(real64), intent(out) :: rgb_data(width, height, 3)
22+
real(wp), intent(out) :: rgb_data(width, height, 3)
2323

2424
! ASCII backend doesn't have RGB data for animation - fill with dummy data
25-
rgb_data = 0.0_real64 ! Black background
25+
rgb_data = 0.0_wp ! Black background
2626
end subroutine extract_ascii_rgb_data
2727

2828
subroutine get_ascii_png_data(width, height, png_data, status)

src/backends/raster/fortplot_raster.f90

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,10 +411,9 @@ subroutine raster_calculate_legend_position_context(this, legend, x, y)
411411
end subroutine raster_calculate_legend_position_context
412412

413413
subroutine raster_extract_rgb_data_context(this, width, height, rgb_data)
414-
use, intrinsic :: iso_fortran_env, only: real64
415414
class(raster_context), intent(in) :: this
416415
integer, intent(in) :: width, height
417-
real(real64), intent(out) :: rgb_data(width, height, 3)
416+
real(wp), intent(out) :: rgb_data(width, height, 3)
418417

419418
call raster_extract_rgb_data(this%raster, width, height, rgb_data)
420419
end subroutine raster_extract_rgb_data_context

src/backends/raster/fortplot_raster_rendering.f90

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,9 @@ end subroutine raster_calculate_legend_position
256256

257257
subroutine raster_extract_rgb_data(raster, width, height, rgb_data)
258258
!! Extract RGB data from PNG backend
259-
use, intrinsic :: iso_fortran_env, only: real64
260259
type(raster_image_t), intent(in) :: raster
261260
integer, intent(in) :: width, height
262-
real(real64), intent(out) :: rgb_data(width, height, 3)
261+
real(wp), intent(out) :: rgb_data(width, height, 3)
263262
integer :: x, y, idx_base
264263

265264
do y = 1, height
@@ -269,9 +268,9 @@ subroutine raster_extract_rgb_data(raster, width, height, rgb_data)
269268
idx_base = ((y-1) * width + (x-1)) * 3
270269

271270
! Extract RGB values (normalized to 0-1)
272-
rgb_data(x, y, 1) = real(raster%image_data(idx_base + 1), real64) / 255.0_real64
273-
rgb_data(x, y, 2) = real(raster%image_data(idx_base + 2), real64) / 255.0_real64
274-
rgb_data(x, y, 3) = real(raster%image_data(idx_base + 3), real64) / 255.0_real64
271+
rgb_data(x, y, 1) = real(raster%image_data(idx_base + 1), wp) / 255.0_wp
272+
rgb_data(x, y, 2) = real(raster%image_data(idx_base + 2), wp) / 255.0_wp
273+
rgb_data(x, y, 3) = real(raster%image_data(idx_base + 3), wp) / 255.0_wp
275274
end do
276275
end do
277276
end subroutine raster_extract_rgb_data

0 commit comments

Comments
 (0)