BBC BASIC for Windows
« Jpg display in bbcbasic4 windows »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 10:53pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Jpg display in bbcbasic4 windows  (Read 628 times)
larry
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 2
xx Jpg display in bbcbasic4 windows
« Thread started on: May 12th, 2014, 4:18pm »


below is the code I'm using in BBC4win to place a jpg in a window. The Procedure uses an api call.
I want it to display in whatever size the image is. rather than me having to specify the size.
any help would be greatly appreciated

cls

rem maximize window
SW_MAXIMIZE = 3
sys "ShowWindow", @hwnd%, SW_MAXIMIZE

rem Set parematers for loading the jpg onto the window
picture$="i:\jbg\jbg1\00000jb.jpg"
xpos%=0
ypos%=0
xsize%=450
ysize%=600

rem call the procedure that shows the picture to the window
procdisplay(picture$,xpos%,ypos%,xsize%,ysize%)

repeat
rem Wait for keypress
Key%=get
rem Translate key press to action code
case Key% of
when 27 cls:end
otherwise Code%=0
endcase
until Code%<>0

rem this is the procedure that opens and displays the picture

def procdisplay(picture$,xpos%,ypos%,xsize%,ysize%)
local oleaut32%, olpp%, iid%, gpp%, hmw%, hmh%, picture%, res%
sys "LoadLibrary", "OLEAUT32.DLL" to oleaut32%
sys "GetProcAddress", oleaut32%, "OleLoadPicturePath" to olpp%
if olpp%=0 error 100, "Could not get address of OleLoadPicturePath"
dim iid% local 15, picture% local 513
sys "MultiByteToWideChar", 0, 0, picture$, -1, picture%, 256
iid%!0 = &7BF80980
iid%!4 = &101ABF32
iid%!8 = &AA00BB8B
iid%!12 = &AB0C3000
sys olpp%, picture%, 0, 0, 0, iid%, ^gpp%
if gpp% = 0 error 100, "OleLoadPicturePath failed"
sys !(!gpp%+24), gpp%, ^hmw% : rem. IPicture::get_Width
sys !(!gpp%+28), gpp%, ^hmh% : rem. IPicture::get_Height
sys !(!gpp%+32), gpp%, @memhdc%, xpos%, ypos%, xsize%, ysize%, 0, \
\ hmh%, hmw%, -hmh%, 0 to res%
if res% error 100, "IPicture::Render failed"
sys !(!gpp%+8), gpp% : rem. IPicture::Release
sys "InvalidateRect", @hwnd%, 0, 0
sys "UpdateWindow", @hwnd%
endproc

« Last Edit: May 12th, 2014, 4:21pm by larry » User IP Logged

Ever standing ready to snatch defeat from the jaws of victory. smiley
rtr
Guest
xx Re: Jpg display in bbcbasic4 windows
« Reply #1 on: May 12th, 2014, 5:58pm »

on May 12th, 2014, 4:18pm, larry wrote:
I want it to display in whatever size the image is. rather than me having to specify the size.

The easiest way would probably be to take the image dimensions (hmw% and hmh%), convert them from HIMETRIC units to pixels (assume 96 DPI), and then put those values into the xsize% and ysize% variables respectively:

Code:
      xsize% = INT(hmw% * 96 / 2540 + 0.5)
      ysize% = INT(hmh% * 96 / 2540 + 0.5) 

Richard.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls