Bos Taurus Copy and replace Bitamp

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
bluebird
Posts: 172
Joined: Wed Sep 28, 2016 3:55 am
DBs Used: DBF

Bos Taurus Copy and replace Bitamp

Post by bluebird »

Boss Taurus Gurus

I would like to load an image using BT, but be flexible enough to resize the image within HMG

BT has such a copy/resize function, however it did not behave as expected. The image bitmap copy version did not
have the same colors as the original.

The code I used to test the feature is shown below. I tried different parameters instead of BT_SCALE,BT_RESIZE_BILINEAR
but the result was just the same, ie. the colors did not match even when the copy was made without a size change.
hBitMap1:=BT_BitmapLoadFile ("Test.jpg")
hDC1:=BT_CreateDC(hBitmap1, BT_HDC_BITMAP , @BTstruct)
hDC2:=BT_BitmapCopyAndResize (hBitmap1, nXFullSize, nYFullSize, BT_SCALE,BT_RESIZE_BILINEAR)

aColor:=BT_DrawGetPixel (hDC1, 0,29 )
aColorx:=BT_DrawGetPixel (hDC2, 0,20 )
aColor from aDC1 was BLACK but aColorx in hDC2 was white

If anyone has tried to use this BT capablilty, please let me know if I am doing anything wrong.

Thanks all
edk
Posts: 911
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: Bos Taurus Copy and replace Bitamp

Post by edk »

Hi, this piece of code is working fine for me:

Code: Select all

hBitmap1 := BT_BitmapLoadFile(cAuxFile)
IF BT_BitmapWidth (hBitmap1)>1024 .OR. BT_BitmapHeight(hBitmap1)>768
	hBitmap2 := BT_BitmapCopyAndResize (hBitmap1, 1024, 768, BT_SCALE, BT_RESIZE_HALFTONE)		//BT_RESIZE_COLORONCOLOR)
	PictSave := BT_BitmapSaveFile (hBitmap2, NewPict, BT_FILEFORMAT_JPG)
	BT_BitmapRelease (hBitmap2)
ENDIF
BT_BitmapRelease (hBitmap1)
Make sure that the coordinates of both images
aColor:=BT_DrawGetPixel (hDC1, 0,29 )
aColorx:=BT_DrawGetPixel (hDC2, 0,20 )
match the same place in both images.
edk
Posts: 911
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: Bos Taurus Copy and replace Bitamp

Post by edk »

It seems to me that here is incorrect:
bluebird wrote: Wed Jan 24, 2018 5:14 am hDC2:=BT_BitmapCopyAndResize (hBitmap1, nXFullSize, nYFullSize, BT_SCALE,BT_RESIZE_BILINEAR)
BT_BitmapCopyAndResize (hBitmap, New_Width, New_Height, Mode_Stretch, Algorithm) : Copy and resizes the specified bitmap and returns a handle to the bitmap with the new size not handle to the device context (hDC)

Try:

Code: Select all

hBitMap1:=BT_BitmapLoadFile ("Test.jpg")
hDC1:=BT_CreateDC(hBitmap1, BT_HDC_BITMAP , @BTstruct)
hBitMap2:=BT_BitmapCopyAndResize (hBitmap1, nXFullSize, nYFullSize, BT_SCALE,BT_RESIZE_BILINEAR)
hDC2:=BT_CreateDC(hBitmap2, BT_HDC_BITMAP , @BTstruct2)

 aColor:=BT_DrawGetPixel (hDC1, 0,29 ) 
 aColorx:=BT_DrawGetPixel (hDC2, 0,20 ) 
I have not tested.
Post Reply