forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

GET_DIB_BLOCK@ and 32-bit .bmp

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
johannes



Joined: 21 Jan 2011
Posts: 65
Location: Leimen, Germany

PostPosted: Thu Jan 21, 2016 5:22 pm    Post subject: GET_DIB_BLOCK@ and 32-bit .bmp Reply with quote

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
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 1660
Location: Sydney

PostPosted: Fri Jan 22, 2016 12:04 am    Post subject: Reply with quote

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
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 4537
Location: Salford, UK

PostPosted: Fri Jan 22, 2016 9:38 am    Post subject: Reply with quote

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
View user's profile Send private message
Wilfried Linder



Joined: 14 Nov 2007
Posts: 297
Location: Düsseldorf, Germany

PostPosted: Fri Jan 22, 2016 11:42 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Wilfried Linder



Joined: 14 Nov 2007
Posts: 297
Location: Düsseldorf, Germany

PostPosted: Fri Jan 22, 2016 6:07 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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