resize BMP with harbour / HMG

Discuss anything else that does not suite other forums.

Moderator: Rathinagiri

Post Reply
User avatar
AUGE_OHR
Posts: 182
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany
Has thanked: 17 times
Been thanked: 21 times

resize BMP with harbour / HMG

Post by AUGE_OHR » Fri Nov 01, 2019 2:59 am

hi,

under Xbase++ i have this Code

Code: Select all

FUNCTION BMP2BMP( oBMP, aXbpSize )
LOCAL oHuge, oTiny, oPS, oRet, nBits, nPlanes

   IF aXbpSize[ 2 ] > 0
      oHuge := oBMP
      nBits := oBMP:bits
      nPlanes := oBMP:planes

      oPS := XBPPRESSPACE() :new() :Create()            // Xbase++ Style 
      //Create a new empty bitmap 
      oTiny := XBPBITMAP() :New() :Create()
      oTiny:Make( aXbpSize[ 1 ], aXbpSize[ 2 ], nPlanes, nBits )
      oTiny:presSpace( oPS )                            // Xbase++ Style 

      //Copie and resize the huge bitmap to the small bitmap
      oHuge:Draw( oPS, { 0, 0, aXbpSize[ 1 ], aXbpSize[ 2 ] },,, 4 )
      oRet := oTiny
   ELSE
      oRet := oBMP
   ENDIF

RETURN oRet
i create a empty Bitmap with new Size.
than a "Draw" old Bildmap into new Bitmap

how to do it with harbour HMG :?:

User avatar
AUGE_OHR
Posts: 182
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany
Has thanked: 17 times
Been thanked: 21 times

Post by AUGE_OHR » Fri Nov 01, 2019 5:34 am

hi,

if i have a Line like this

Code: Select all

     @ 0, 0 IMAGE Image_1 PICTURE xxx ON CLICK MsgInfo ("Splash Image")
what Type can xxx be :?:

i'm not a C User so it is only to show how it "might" look under harbour what i mean

Code: Select all

HB_FUNC (BMP2BMP) // LPCTSTR BmpRes, INT nWidth, INT nHeight

  BmpRes    = (LPCTSTR) hb_parnl(1)
  nWidth    = (INT) hb_parnl(2)
  nHeight   = (INT) hb_parnl(3)

  hdcSource = CreateCompatibleDC(hdc);
  hBitmap1 = LoadImage(GetModuleHandle(NULL), BmpRes, IMAGE_BITMAP, nWidth, nHeight, LR_DEFAULTCOLOR);
  SelectObject(hdcSource, hBitmap1);

  hdcTarget = CreateCompatibleDC(hdc);
  hBitmap2 = CreateCompatibleBitmap(hdcSource, iExpWidth, iExpHeight);
  SelectObject(hdcTarget, hBitmap2);

  bResult = StretchBlt( hdcTarget, 0, 0, iExpWidth, iExpHeight, hdcSource, 0, 0, iWidth, iHeight, SRCCOPY );

* return bResult;
  return hBitmap2;
what i like to have are

Code: Select all

     @ 0, 0 IMAGE Image_1 PICTURE BMP2BMP(xxx,aSize[1],aSize[2]) ON CLICK MsgInfo ("Splash Image")
who can help to write HB_FUNC (BMP2BMP)

User avatar
mol
Posts: 3247
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 228 times
Been thanked: 132 times
Contact:

Post by mol » Fri Nov 01, 2019 1:28 pm

We have BosTaurus library for manipulating bitmaps. Try to search

User avatar
mol
Posts: 3247
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 228 times
Been thanked: 132 times
Contact:

Post by mol » Fri Nov 01, 2019 1:31 pm

@ 0, 0 IMAGE Image_1 PICTURE xxx ON CLICK MsgInfo ("Splash Image")

image_1 can be filenamr of your bitmap or appintment to resource, eg:
Image_1 BITMAP C:\PICTURES\BLABLA.BMP

User avatar
AUGE_OHR
Posts: 182
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany
Has thanked: 17 times
Been thanked: 21 times

Post by AUGE_OHR » Fri Nov 01, 2019 10:28 pm

hi
mol wrote:
Fri Nov 01, 2019 1:28 pm
We have BosTaurus library for manipulating bitmaps. Try to search
i have look into

c:\hmg.3.4.4\SOURCE\BosTaurus\c_BosTaurus.c

Code: Select all

bt_bmp_convert_to_24bpp (hBitmap, IsDelete_hBitmap_Original) ---> Return New_hBitmap
c:\hmg.3.4.4\SOURCE\BosTaurus\h_BosTaurus.prg

Code: Select all

BT_BitmapCopyAndResize (hBitmap, New_Width, New_Height, Mode_Stretch, Algorithm)
these both Function "might" do what i want.

i do not want to change/delete Original Image when create a New "resize" Image.
new hBitmap i need to pass to 3-PP API Function

thx for Help.

User avatar
AUGE_OHR
Posts: 182
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany
Has thanked: 17 times
Been thanked: 21 times

Post by AUGE_OHR » Sat Nov 02, 2019 12:19 am

hi,

i made a (typical) Xbase++ Error ... we are on Windows ;)

Windows have LoadImageA
https://docs.microsoft.com/en-us/window ... loadimagea

Code: Select all

HANDLE LoadImageA(
  HINSTANCE hInst,
  LPCSTR    name,
  UINT      type,
  int       cx,
  int       cy,
  UINT      fuLoad
);
so i can load it with Size cx and cy

--

have found in c:\hmg.3.4.4\INCLUDE\i_image.ch

Code: Select all

#xcommand @ <row>,<col> IMAGE <name> ;
   [ <dummy1: OF, PARENT> <parent> ] ;
   PICTURE <filename> ;
   [ <dummy2: ACTION,ON CLICK,ONCLICK> <action> ];
   [ WIDTH <w> ] ;
   [ HEIGHT <h> ] ;
   [ <stretch: STRETCH> ] ;
   [ HELPID <helpid> ] ;
   [ <invisible: INVISIBLE> ] ;
   [ <transparent: TRANSPARENT> ] ;
   [ BACKGROUNDCOLOR <backgroundcolor> ];
   [ <adjustimage: ADJUSTIMAGE>];
   [ TRANSPARENTCOLOR <transparentcolor> ];
   [ TOOLTIP <tooltip> ];
 =>;
so i change my Code to

Code: Select all

      @ 0, 0 IMAGE Image_1 PICTURE cFileName ;
                           WIDTH 500 HEIGHT 150 ;
                           ON CLICK MsgInfo ("Splash Image")
and it seems to work :D
Question : how to use [ <stretch: STRETCH> ] :?:

User avatar
AUGE_OHR
Posts: 182
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany
Has thanked: 17 times
Been thanked: 21 times

Post by AUGE_OHR » Sat Nov 02, 2019 1:02 am

hm ...
i now see some Artefact
Artefact.jpg
Artefact.jpg (17.8 KiB) Viewed 249 times
i have now use small Bitmap which i have normal in Resoure

when use F8 in Debugger i got this result
Hight_Error.jpg
Hight_Error.jpg (16.7 KiB) Viewed 249 times
so Image does not fill hole Area :(

Code: Select all

  DEFINE WINDOW Form_Splash ;
      AT 0,0 ;
      WIDTH 500 HEIGHT 150 ;
      ...
      @ 0, 0 IMAGE Image_1 PICTURE cFileName ;
                           WIDTH 500 HEIGHT 150 ;
attached Code and BMP Sample
SetRegion_2.zip
(27.75 KiB) Downloaded 13 times

User avatar
AUGE_OHR
Posts: 182
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany
Has thanked: 17 times
Been thanked: 21 times

Post by AUGE_OHR » Sat Nov 02, 2019 8:44 pm

hi,

can someone confirm the Problem :?:

User avatar
gfilatov
Posts: 667
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Has thanked: 24 times
Been thanked: 232 times
Contact:

Post by gfilatov » Mon Nov 04, 2019 9:22 am

AUGE_OHR wrote:
Sat Nov 02, 2019 8:44 pm
hi,

can someone confirm the Problem :?:
Hi,

I don't understanding your problem. :o

BTW Please take a look for my result below :arrow:
screen.png
screen.png (43.96 KiB) Viewed 155 times
and with an updated code

Code: Select all

      @ 0, 0 IMAGE Image_1 PICTURE cFileName ;
                           WIDTH 500 HEIGHT 150 STRETCH
it seems normally
screen2.png
screen2.png (43.28 KiB) Viewed 153 times
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein

User avatar
AUGE_OHR
Posts: 182
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany
Has thanked: 17 times
Been thanked: 21 times

Post by AUGE_OHR » Mon Nov 04, 2019 7:37 pm

gfilatov wrote:
Mon Nov 04, 2019 9:22 am
and with an updated code

Code: Select all

      @ 0, 0 IMAGE Image_1 PICTURE cFileName ;
                           WIDTH 500 HEIGHT 150 STRETCH
it seems normally
yes, now it work with this Syntax. Thx

the Question is why it does not work when only use

Code: Select all

WIDTH 500 HEIGHT 150 
OR

Code: Select all

STRETCH
does not work :?:

Post Reply