Hello forum, DIB_Block routines can handle max 24-bit image files, isnt't it?
How to read 32-bit *.bmp images? Is there a way to transform 32 bit to 24 bit. Any other worksaround is welcome. Johannes
Welcome to our forums
Hello forum, DIB_Block routines can handle max 24-bit image files, isnt't it?
How to read 32-bit *.bmp images? Is there a way to transform 32 bit to 24 bit. Any other worksaround is welcome. Johannes
The graphics used in clearwin is 3 x 8 bits. You can open a .bmp file and import the information (using IMPORT_BMP@), but I am wondering what will happen to the other 8 bits of information. Perhaps there is nothing there. ( Is it transparency info?) You should try a simple program to import and display what you get. (using DIB_PAINT@ to transfer to the %gr window)
Alternatively IMPORT_IMAGE@ will import a .bmp file and display in the current %gr window. I must admit that I find IMPORT_IMAGE@ and EXPORT_IMAGE@ more useable.
If you are looking for a software solution then it could be tricky. There may be method via Microsoft GDI+ but that would require coding in C++. I can put this on the wish list for ClearWin+.
If you are happy to convert the files directly then you could try using an online conversion such as http://image.online-convert.com/convert-to-bmp
I have not tried it so I don't know if it is safe.
As Paul said, GDI+ is the solution. The following small example works also with 32-bits BMP or 32-bits PNG:
winapp
program test
include <windows.ins>
external display
integer*4 j,display
c_external USE_GDIPLUS_IMAGE_FILES@ '__use_gdiPlusForImageFiles'
* (VAL):integer*4
j = use_gdiplus_image_files@(1L)
j = winio@('%`^gr[rgb_colours]',800L,600L,1L,DISPLAY)
end
integer*4 function display()
include <windows.ins>
integer*4 j
j = import_image@('{c:\my_images\testimage_1.bmp}',0,0)
display = 1
end
Wilfried
In addition, here are few lines of code showing the input and optional the conversion to a bitmap. Suitable for BMP, JPG, TIFF and PNG files.
winapp
program test
include <windows.ins>
c_external USE_GDIPLUS_IMAGE_FILES@ '__use_gdiPlusForImageFiles' (VAL):integer*4
integer*4 A,i,j,rows,cols,bits,rtcode
integer*1,allocatable:: ARR(:,:,:)
character*1,allocatable:: image(:)
character*120 ifile
j = use_gdiplus_image_files@(1L)
!!!
ifile = 'c:\my_images\bmp\testimage.bmp'
!!!
! get image dimensions
call get_dib_size@(ifile,cols,rows,bits,rtcode)
if (rtcode /= 0) goto 999
! allocate array
allocate(ARR(3L,cols,rows),stat=rtcode)
if (rtcode /= 0) goto 999
! read image file into the array
call get_dib_block@(ifile,ARR,cols,rows,0,0,cols,rows,0,0,rtcode)
if (rtcode /= 0) goto 999
! optional, if you prefer a bitmap structure instead of the array:
allocate(image(3*cols*rows),stat=rtcode)
if (rtcode == 0) then
A = 1
do i = 1,rows
do j = 1,cols
image(A ) = char(ARR(3,j,i))
image(A+1) = char(ARR(2,j,i))
image(A+2) = char(ARR(1,j,i))
A = A+3
end do
end do
end if
deallocate(image)
999 deallocate(ARR)
end
Wilfried