Page 1 of 1
resize BMP with harbour / HMG
Posted: Fri Nov 01, 2019 2:59 am
by AUGE_OHR
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
Re: resize BMP with harbour / HMG
Posted: Fri Nov 01, 2019 5:34 am
by AUGE_OHR
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)
Re: resize BMP with harbour / HMG
Posted: Fri Nov 01, 2019 1:28 pm
by mol
We have BosTaurus library for manipulating bitmaps. Try to search
Re: resize BMP with harbour / HMG
Posted: Fri Nov 01, 2019 1:31 pm
by mol
@ 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
Re: resize BMP with harbour / HMG
Posted: Fri Nov 01, 2019 10:28 pm
by AUGE_OHR
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.
Re: resize BMP with harbour / HMG
Posted: Sat Nov 02, 2019 12:19 am
by AUGE_OHR
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
Question : how to use [ <stretch: STRETCH> ]
Re: resize BMP with harbour / HMG
Posted: Sat Nov 02, 2019 1:02 am
by AUGE_OHR
hm ...
i now see some Artefact
- Artefact.jpg (17.8 KiB) Viewed 3161 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 (16.7 KiB) Viewed 3161 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
Re: resize BMP with harbour / HMG
Posted: Sat Nov 02, 2019 8:44 pm
by AUGE_OHR
hi,
can someone confirm the Problem
Re: resize BMP with harbour / HMG
Posted: Mon Nov 04, 2019 9:22 am
by gfilatov
AUGE_OHR wrote: ↑Sat Nov 02, 2019 8:44 pm
hi,
can someone confirm the Problem
Hi,
I don't understanding your problem.
BTW Please take a look for my result below
- screen.png (43.96 KiB) Viewed 3067 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 (43.28 KiB) Viewed 3065 times
Re: resize BMP with harbour / HMG
Posted: Mon Nov 04, 2019 7:37 pm
by AUGE_OHR
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
OR
does not work