Display Image from bitmap

Moderator: Rathinagiri

Post Reply
User avatar
RussBaker
Posts: 51
Joined: Wed Jul 22, 2015 9:44 am

Display Image from bitmap

Post by RussBaker »

Silly language question. I have an image on a form. How do I display from a bitmap in memory?

I need to display a cropped section of an image file to anIMAGE


DEFINE IMAGE myphoto
ROW 10
COL 10
WIDTH 220
HEIGHT 180
PICTURE myfile
HELPID Nil
VISIBLE .T.
STRETCH .F.
ACTION Nil
END IMAGE

eg:
hBitmap1 := BT_BitmapLoadfile("myfile.jpg")
hBitmap2 := BT_BitmapClone(hBitmap1, 1,160,160,100)

How do I get the image to display the cropped image hBitmap2 ?

I saved the bitmap to a file and then place the file name in myfile
eg: myfile:="Newfile.jpg"

I would like to display directly from the bitmap and not need to save the file.

--Russ
User avatar
gfilatov
Posts: 1067
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: Display Image from bitmap

Post by gfilatov »

RussBaker wrote:Silly language question. I have an image on a form. How do I display from a bitmap in memory?
....
I would like to display directly from the bitmap and not need to save the file.
Hi Russ,

Please take a look for the following function from the BosTaurus library:

Code: Select all

Function BT_HMGSetImage (cFormName, cControlName, hBitmap, lReleasePreviousBitmap)
LOCAL hWnd, k

   IF ValType (lReleasePreviousBitmap) <> "L"
      lReleasePreviousBitmap := .T.
   ENDIF

   k := GetControlIndex (cControlName, cFormName)
   IF k > 0
   
      #ifdef __HMG__    // HMG Extended
         IF _HMG_aControlContainerHandle [k] <> 0 .AND. lReleasePreviousBitmap == .T.
            BT_BitmapRelease (_HMG_aControlContainerHandle [k])
         ENDIF
         _HMG_aControlContainerHandle [k] := hBitmap
         _HMG_aControlWidth  [k] := BT_BitmapWidth  (hBitmap)
         _HMG_aControlHeight [k] := BT_BitmapHeight (hBitmap)
      #else             // HMG Official
         IF _HMG_SYSDATA [37, k] <> 0 .AND. lReleasePreviousBitmap == .T.
            BT_BitmapRelease (_HMG_SYSDATA [37, k])
         ENDIF
         _HMG_SYSDATA [37, k] := hBitmap
         _HMG_SYSDATA [20, k] := BT_BitmapWidth  (hBitmap)
         _HMG_SYSDATA [21, k] := BT_BitmapHeight (hBitmap)
      #endif

      hWnd := GetControlHandle (cControlName, cFormName)
      #define _STM_SETIMAGE_ 0x0172
      #define _IMAGE_BITMAP_ 0
      SendMessage (hWnd, _STM_SETIMAGE_, _IMAGE_BITMAP_, hBitmap)
      #undef _IMAGE_BITMAP_
      #undef _STM_SETIMAGE_
   ENDIF
Return NIL
Hope that helps :idea:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
bpd2000
Posts: 1207
Joined: Sat Sep 10, 2011 4:07 am
Location: India

Re: Display Image from bitmap

Post by bpd2000 »

Grigory Filatov is correct
Refer following example for Resize Image and Set Control Image
C:\hmg\SAMPLES\BosTaurus\demo13.prg
BPD
Convert Dream into Reality through HMG
User avatar
RussBaker
Posts: 51
Joined: Wed Jul 22, 2015 9:44 am

Re: Display Image from bitmap

Post by RussBaker »

gfilatov,

Thanks.
I've browsed the BosTaurus samples and believe this is my new friend. So much power in those.

I think BosTaurus will answer many of my graphic challenges.

--Russ
Post Reply