Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

problems with StretchDIbit

trevor_d_
Beginner
933 Views

I am converting a program from Fortran 10 to fortran 16 (evaluation version at the moment) in Windows 10.

Most things have converted well but I am having problems with a bitmap routine (based on a routine that Steve Lionel gave me many years ago).

I have solved most of the problems, e.g. handles but when I call StretchDibit it give me a fortll severe (157) program exception, access violation error.

As far as I can see the values of all of the variable seem fine ...but obviously they are not. Below are the pertinent bits of code.

type (T_BITMAPFILEHEADER) :: pbmfh

pointer (pheader, pbmfh)

integer(4) pBits

type (T_BITMAPINFO) bits

pointer (lpbits, bits)

!

! Read Bitmap file

!

if (pheader /= 0) call free(pheader)

iret = GetBitMap('Temp.bmp'C)

iret = DeleteFile('Temp.bmp'C) ! Delete temporary .bmp file.

if (iret > 0) then

lpbits = pheader + sizeof(pbmfh)

pBits = pheader + pbmfh.bfOffBits

else

Stop ' Error with reading bitmap'

c PrintWin = PW_ERR_READBITMAP ! Failed to read bitmap file.

c goto 9999

end if

if ( bits.bmiHeader.biSize /= 40) then

Stop ' Bitmap header is the wrong size'

c PrintWin = PW_ERR_READDIBHEADER ! Bitmap header is wrong size.

c goto 9999

end if

 

iret = StretchDIBits (Trevhdc, 0, 0, cxPage, cyPage, 0, 0,

& cxDib,cyDib, pbits, bits, DIB_RGB_COLORS, SRCCOPY)

 

Trevhdc is a handle and is correct.

0 Kudos
4 Replies
andrew_4619
Honored Contributor III
933 Views

Is this a 64 or 32 bit build? What is the type of the hdc?

0 Kudos
trevor_d_
Beginner
933 Views

This is a 64 bit build

Trevhdc is Integer (handle) and is used in several other calls, prior to the StretchdiBits call, without problem.

0 Kudos
andrew_4619
Honored Contributor III
933 Views
iret = StretchDIBits (Trevhdc, 0, 0, cxPage, cyPage, 0, 0,& 
cxDib,cyDib, pbits, bits, DIB_RGB_COLORS, SRCCOPY)

pbits is not "A pointer to the image bits, which are stored as an array of bytes. For more information, see the Remarks section."

 

0 Kudos
trevor_d_
Beginner
932 Views

Thank you,

I've replaced pbits with lpbits and that solves the problem (although I'm not sure why it used to work in my Fortran 10 version).

0 Kudos
Reply