BT_BitmapSaveFile
Moderator: Rathinagiri
BT_BitmapSaveFile
Hola a todos
Estoy utilizando la BosTaurus para para cargar una imagen, dibujar algo sobre ella y guardarla en archivo.
Pero al utilizar BT_BitmapSaveFile(hBitmap, cFileName, nTypePicture) me guarda solo la imagen,
no lo que haya "dibujado" sobre ella.
Alguna idea ? Dr. Claudio ?
Gracias
-----------------------------------------------------------------------------------------------------------------
Hello everyone
I am using BosTaurus to to load an image, draw something on it and save it to file.
But using BT_BitmapSaveFile (hBitmap, cFileName, nTypePicture) I just saved the image,
not what is "drawn" on it.
Any idea? Dr. Claudio?
thanks
Estoy utilizando la BosTaurus para para cargar una imagen, dibujar algo sobre ella y guardarla en archivo.
Pero al utilizar BT_BitmapSaveFile(hBitmap, cFileName, nTypePicture) me guarda solo la imagen,
no lo que haya "dibujado" sobre ella.
Alguna idea ? Dr. Claudio ?
Gracias
-----------------------------------------------------------------------------------------------------------------
Hello everyone
I am using BosTaurus to to load an image, draw something on it and save it to file.
But using BT_BitmapSaveFile (hBitmap, cFileName, nTypePicture) I just saved the image,
not what is "drawn" on it.
Any idea? Dr. Claudio?
thanks
- Attachments
-
- imagen.jpg (264.11 KiB) Viewed 3419 times
Andrés González López
Desde Guadalajara, Jalisco. México.
Desde Guadalajara, Jalisco. México.
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: BT_BitmapSaveFile
Hola Andresandyglezl wrote: I am using BosTaurus to to load an image, draw something on it and save it to file.
But using BT_BitmapSaveFile (hBitmap, cFileName, nTypePicture) I just saved the image,
not what is "drawn" on it.
BosTaurus has a ton of "draw" functions, such as :
- BT_DrawLine()
BT_DrawRectangle()
BT_DrawEllipse()
BT_DrawFillRectangle()
...
Happy HMG'ing
Viva INTERNATIONAL HMG
Re: BT_BitmapSaveFile
Gracias esgici, lo se, pero lo que quiero es guardar en un archivo la imagen
ya modificada con lo que haya dibujado sobre ella, en este caso, el circulo rojo
como aparece en la imagen arriba.
Y al guardar con la funcion, BT_BitmapSaveFile(hBitmap, cFileName, nTypePicture,
me guarda solo la imagen que cargué, pero no el circulo rojo.
-----------------------------------------------------------------------------------------------------
Thanks Esgici, I know, but what I want is to save the image to a file
modified and what you draw on it, in this case, the red circle
as shown in the image above.
And to keep with the function, BT_BitmapSaveFile (hBitmap, cFileName, nTypePicture
I keep only the image I uploaded, but not the red circle.
ya modificada con lo que haya dibujado sobre ella, en este caso, el circulo rojo
como aparece en la imagen arriba.
Y al guardar con la funcion, BT_BitmapSaveFile(hBitmap, cFileName, nTypePicture,
me guarda solo la imagen que cargué, pero no el circulo rojo.
-----------------------------------------------------------------------------------------------------
Thanks Esgici, I know, but what I want is to save the image to a file
modified and what you draw on it, in this case, the red circle
as shown in the image above.
And to keep with the function, BT_BitmapSaveFile (hBitmap, cFileName, nTypePicture
I keep only the image I uploaded, but not the red circle.
Andrés González López
Desde Guadalajara, Jalisco. México.
Desde Guadalajara, Jalisco. México.
- srvet_claudio
- Posts: 2193
- Joined: Thu Feb 25, 2010 8:43 pm
- Location: Uruguay
- Contact:
Re: BT_BitmapSaveFile
Andrés,
espero que este ejemplo te sea de ayuda.
espero que este ejemplo te sea de ayuda.
Code: Select all
PROCEDURE Draw_in_image
LOCAL hBitmap
LOCAL hDC, BTstruct
hBitmap := BT_BitmapLoadFile ("Image1.jpg")
hDC := BT_CreateDC (hBitmap, BT_HDC_BITMAP, @BTstruct)
BT_DrawEllipse (hDC, 140, 200, 400, 230, RED, 5) // Draw in image
// BT_Draw... () // Others draws functions
BT_DeleteDC (BTstruct)
BT_BitmapSaveFile (hBitmap, "Image1.jpg", BT_FILEFORMAT_JPG)
BT_BitmapRelease (hBitmap)
RETURN
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: BT_BitmapSaveFile
Hola Andresandyglezl wrote:I know, but what I want is to save the image to a file
modified and what you draw on it, ...
And to keep with the function, BT_BitmapSaveFile (hBitmap, cFileName, nTypePicture
I keep only the image I uploaded, but not the red circle.
I know, you are knowing everything you need;
Nevertheless, look at once my humble work too :
Happy HMG'ing
Viva INTERNATIONAL HMG
Re: BT_BitmapSaveFile
Creo que ya vi cual es el detalle, yo estaba usando
Win1.Capture( cArch, 000 , 000 , BT_ClientAreaWidth("Win1") , BT_ClientAreaHeight("Win1") )
y si me guardaba todo lo que habia dibujado.
Pero ahora estoy cargando imagenes a su tamaño real para que se vean mejor, (con VIRTUAL WIDTH xxx VIRTUAL HEIGHT xxx),
recorro con las barras de Scroll hacia el lugar que quiero ver y señalo algun punto en la imagen.
Crei que con BT_BitmapSaveFile (hBitmap, cFileName, nTypePicture), me salvaria toda la imagen que cargue en hDC mas lo dibujado.
(y claro, solo me guardaba la imagen) Ahora me doy cuenta que tengo que capturar lo que se muestra en pantalla y guardarlo a archivo,
que no puedo guardar todo lo que tengo en la ventana virtual.
------------------------------------------------------------------------------------------------------------------------
I think I saw what the detail, I was using
Win1.Capture (Carch, 000, 000, BT_ClientAreaWidth ("Win1"), BT_ClientAreaHeight ("Win1"))
and if he saved all that was drawn.
But now I'm loading images at actual size to make them look better, (with VIRTUAL VIRTUAL HEIGHT WIDTH xxx xxx)
I walk with scroll bars to the place you want to see and point out some point in the image.
I thought that BT_BitmapSaveFile (hBitmap, cFileName, nTypePicture) , I would save the entire image to load in hDC with what I had drawn.
(and of course, just saved the image) Now I realize that I have to capture what is displayed on the screen and save it to file, I can not save
all I have in the virtual window.
Win1.Capture( cArch, 000 , 000 , BT_ClientAreaWidth("Win1") , BT_ClientAreaHeight("Win1") )
y si me guardaba todo lo que habia dibujado.
Pero ahora estoy cargando imagenes a su tamaño real para que se vean mejor, (con VIRTUAL WIDTH xxx VIRTUAL HEIGHT xxx),
recorro con las barras de Scroll hacia el lugar que quiero ver y señalo algun punto en la imagen.
Crei que con BT_BitmapSaveFile (hBitmap, cFileName, nTypePicture), me salvaria toda la imagen que cargue en hDC mas lo dibujado.
(y claro, solo me guardaba la imagen) Ahora me doy cuenta que tengo que capturar lo que se muestra en pantalla y guardarlo a archivo,
que no puedo guardar todo lo que tengo en la ventana virtual.
------------------------------------------------------------------------------------------------------------------------
I think I saw what the detail, I was using
Win1.Capture (Carch, 000, 000, BT_ClientAreaWidth ("Win1"), BT_ClientAreaHeight ("Win1"))
and if he saved all that was drawn.
But now I'm loading images at actual size to make them look better, (with VIRTUAL VIRTUAL HEIGHT WIDTH xxx xxx)
I walk with scroll bars to the place you want to see and point out some point in the image.
I thought that BT_BitmapSaveFile (hBitmap, cFileName, nTypePicture) , I would save the entire image to load in hDC with what I had drawn.
(and of course, just saved the image) Now I realize that I have to capture what is displayed on the screen and save it to file, I can not save
all I have in the virtual window.
Andrés González López
Desde Guadalajara, Jalisco. México.
Desde Guadalajara, Jalisco. México.
- serge_girard
- Posts: 3167
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: BT_BitmapSaveFile
Hello,
When I 'drop' a drawing on the picture it seems OK but when the window/form is minimized and opened again my draw has disappeared Almost like an UNDO...
Any idea how to make it mot disappear?
Thx, Serge
When I 'drop' a drawing on the picture it seems OK but when the window/form is minimized and opened again my draw has disappeared Almost like an UNDO...
Any idea how to make it mot disappear?
Thx, Serge
There's nothing you can do that can't be done...
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: BT_BitmapSaveFile
Hi Serge
DRAW ... commands or Bos Taurus ?
And please a SSW if possible.
Regards
What drawing you are about;serge_girard wrote: When I 'drop' a drawing on the picture it seems OK but when the window/form is minimized and opened again my draw has disappeared Almost like an UNDO...
Any idea how to make it mot disappear?
DRAW ... commands or Bos Taurus ?
And please a SSW if possible.
Regards
Viva INTERNATIONAL HMG
- serge_girard
- Posts: 3167
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: BT_BitmapSaveFile
Esgici,
Try this code. Select a drawing and place in somewhere in the picture. Then minimize the window and then reopen and your selected drawing has gone.
Try this code. Select a drawing and place in somewhere in the picture. Then minimize the window and then reopen and your selected drawing has gone.
Code: Select all
*******************************************************************************
* PROGRAMA: Demo ON PAINT event
* LENGUAJE: HMG
* FECHA: Setiembre 2012
* AUTOR: Dr. CLAUDIO SOTO
* PAIS: URUGUAY
* E-MAIL: srvet@adinet.com.uy
* BLOG: http://srvet.blogspot.com" onclick="window.open(this.href);return false;
*******************************************************************************
#include "hmg.ch"
#include "hfcl.ch"
#DEFINE SILVER { 192,192,192 }
FUNCTION MAIN
/**************/
PUBLIC hBitmap := 0
PUBLIC lCopy1 := .f.
PUBLIC lCopy2 := .f.
PUBLIC lCopy3 := .f.
PUBLIC lCopy4 := .f.
PUBLIC hDC
PUBLIC BTstruct
DEFINE WINDOW Win1;
AT 0,0;
WIDTH 960;
HEIGHT 780;
TITLE "Bos Taurus: Save Drawn Image Demo";
BACKCOLOR SILVER;
MAIN;
ICON "BT_Icon" ;
ON INIT Proc_ON_INIT ();
ON RELEASE Proc_ON_RELEASE ();
ON PAINT Proc_ON_PAINT () ;
ON MOUSECLICK Draw_Figure();
ON MOUSEDRAG Mouse_Drag();
ON MOUSEMOVE Mouse_Position()
ON KEY ESCAPE ACTION ThisWindow.Release
@ 0,00 FRAME Frame_1 ;
WIDTH 90 ;
HEIGHT 90
@ 100,00 FRAME Frame_2 ;
WIDTH 90 ;
HEIGHT 90
@ 200,00 FRAME Frame_3 ;
WIDTH 90 ;
HEIGHT 90
@ 500,10 LABEL Label_1 ;
VALUE " " ;
WIDTH 140 ;
HEIGHT 20 ;
FONT 'Arial' SIZE 10 ;
FONTCOLOR RED BOLD ;
BACKCOLOR SILVER;
@ 530,10 LABEL Label_2 ;
VALUE " " ;
WIDTH 140 ;
HEIGHT 20 ;
FONT 'Arial' SIZE 10 ;
FONTCOLOR GREEN BOLD ;
BACKCOLOR SILVER;
@ 560,10 LABEL Label_3 ;
VALUE " " ;
WIDTH 140 ;
HEIGHT 20 ;
FONT 'Arial' SIZE 10 ;
FONTCOLOR ORANGE BOLD ;
BACKCOLOR SILVER;
DEFINE MAIN MENU
DEFINE POPUP "File"
MENUITEM "Save" ACTION SaveImage()
END POPUP
END MENU
DEFINE STATUSBAR
STATUSITEM "" WIDTH 600
STATUSITEM "" WIDTH 100
STATUSITEM "" WIDTH 100
END STATUSBAR
END WINDOW
CENTER WINDOW Win1
ACTIVATE WINDOW Win1
RETURN Nil
FUNCTION Draw_Figure()
/*********************/
nMouse_Col := _HMG_SYSDATA [ 192 ]
nMouse_Row := _HMG_SYSDATA [ 191 ]
IF nMouse_Row <= 90 .AND. nMouse_Col <= 90
lCopy1 := .t.
ENDIF
IF nMouse_Row >= 100 .AND. nMouse_Row <= 190 .AND. nMouse_Col <= 90
lCopy2 := .t.
ENDIF
IF nMouse_Row >= 190 .AND. nMouse_Row <= 290 .AND. nMouse_Col <= 90
lCopy3 := .t.
ENDIF
IF lCopy1 .OR. lCopy2 .OR. lCopy3
IF nMouse_Row >= 10 .and. nMouse_Row <= 480 .AND. nMouse_Col >= 100 .AND. nMouse_Col <= 840 // op de foto
IF lCopy1
BT_DrawEllipse (hDC, nMouse_Row-15, nMouse_Col-15, 30, 30, RED, 1)
SetProperty('Win1','Label_1', 'Value', ALLTRIM(STR(nMouse_Row)) + ' ' + ALLTRIM(STR(nMouse_Col)) )
lCopy1 := .F.
ENDIF
IF lCopy2
BT_DrawEllipse (hDC, nMouse_Row-15, nMouse_Col-15, 30, 30, GREEN, 1)
SetProperty('Win1','Label_2', 'Value', ALLTRIM(STR(nMouse_Row)) + ' ' + ALLTRIM(STR(nMouse_Col)) )
lCopy2 := .F.
ENDIF
IF lCopy3
BT_DrawEllipse (hDC, nMouse_Row-30, nMouse_Col-30, 60, 60, ORANGE, 1)
SetProperty('Win1','Label_3', 'Value', ALLTRIM(STR(nMouse_Row)) + ' ' + ALLTRIM(STR(nMouse_Col)) )
lCopy3 := .F.
ENDIF
ENDIF
ENDIF
RETURN
FUNCTION Mouse_Drag()
/*********************/
RETURN
FUNCTION Mouse_Position()
/***********************/
Win1.StatusBar.Item( 2 ) := "Row : " + LTRIM( STR( _HMG_SYSDATA [ 191 ] )) // Mouse Row
Win1.StatusBar.Item( 3 ) := "Col : " + LTRIM( STR( _HMG_SYSDATA [ 192 ] )) // Mouse Col
RETURN
PROCEDURE Proc_ON_INIT
/*********************/
hBitmap := BT_BitmapLoadFile( "imagen.JPG" )
RETURN
PROCEDURE Proc_ON_RELEASE
/************************/
BT_BitmapRelease( hBitmap )
RETURN
PROCEDURE Proc_ON_PAINT
/*********************/
hDC := BT_CreateDC ("Win1", BT_HDC_INVALIDCLIENTAREA, @BTstruct)
BT_DrawBitmap (hDC, 10, 100, 740, 480, BT_COPY, hBitmap)
BT_DrawEllipse (hDC, 28, 27, 30, 30, RED, 1)
BT_DrawEllipse (hDC, 128, 27, 30, 30, GREEN, 1)
BT_DrawEllipse (hDC, 217, 15, 60, 60, ORANGE, 1)
BT_DrawLine (hDC, 345, 5, 345, 80, ORANGE, 2)
//BT_DeleteDC (BTstruct)
RETURN
PROCEDURE SaveImage()
/*********************/
LOCAL hBitmap := BT_BitmapCaptureClientArea("Win1",10, 100, 740, 480)
LOCAL cImgFNam2 := "SaveImage.jpg"
BT_BitmapSaveFile( hBitmap, cImgFNam2, 2 )
MsgInfo( "Saved AS SaveImage.jpg" )
RETURN
There's nothing you can do that can't be done...