|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
johannes
Joined: 21 Jan 2011 Posts: 65 Location: Leimen, Germany
|
Posted: Thu Jan 21, 2016 5:22 pm Post subject: GET_DIB_BLOCK@ and 32-bit .bmp |
|
|
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 |
|
Back to top |
|
|
JohnCampbell
Joined: 16 Feb 2006 Posts: 2554 Location: Sydney
|
Posted: Fri Jan 22, 2016 12:04 am Post subject: |
|
|
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. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Fri Jan 22, 2016 9:38 am Post subject: |
|
|
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. |
|
Back to top |
|
|
Wilfried Linder
Joined: 14 Nov 2007 Posts: 314 Location: Düsseldorf, Germany
|
Posted: Fri Jan 22, 2016 11:42 am Post subject: |
|
|
As Paul said, GDI+ is the solution. The following small example works also with 32-bits BMP or 32-bits PNG:
Code: | 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 |
|
Back to top |
|
|
Wilfried Linder
Joined: 14 Nov 2007 Posts: 314 Location: Düsseldorf, Germany
|
Posted: Fri Jan 22, 2016 6:07 pm Post subject: |
|
|
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.
Code: | 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 |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|