--------------------------- source -----------------1----------------------
/*
source h2.h
*****************************************************************************
* INCLUDE HEADER FOR FUNCTION IMAGE_HBITMAP_CPP(char * File_Name); *
* WORKING WITH C\C++ *
* BY HATHAL 2012-10-02
http://WWW.LIVESYSTEM.NET &
LIVESYSTEM_NET@HOTMAIL.COM *
*****************************************************************************
*/
#ifdef __cplusplus
extern "C" {
#endif
#if defined(__STDC__) || defined(__cplusplus)
extern HBITMAP IMAGE_HBITMAP_CPP(char * File_Name);
#else
extern HBITMAP IMAGE_HBITMAP_CPP(char * File_Name);
#endif
#ifdef __cplusplus
}
#endif
-------------------------------src 2 ---------------------------------------------
/*
*****************************************************************************
* RETURN HBITMAP FOR IMAGE *.BMP *.EMF *.GIF *.ICO *.JPG *.PNG *.TIF *.WMF *
* BY HATHAL 2012-10-02
http://WWW.LIVESYSTEM.NET &
LIVESYSTEM_NET@HOTMAIL.COM *
*****************************************************************************
HBITMAP.CPP
*/
#include <windows.h>
#include <stdio.h>
#include <gdiplus.h>
#include <winuser.h>
#include <wingdi.h>
#include <commctrl.h>
#include <olectl.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <shellapi.h>
#include <commdlg.h>
#include <shellapi.h>
#include "h2.h"
static HBITMAP hbm; // RETURN HBITMAP TO FIVEWIN
using namespace Gdiplus;
HBITMAP IMAGE_HBITMAP_CPP(char * File_Name)
{
WCHAR wchPath[MAX_PATH];
ZeroMemory(wchPath,MAX_PATH);
MultiByteToWideChar(CP_ACP, 0,File_Name, -1,wchPath, MAX_PATH );
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
CLSID encoderClsid;
Bitmap* pBitmap = Bitmap::FromFile(wchPath);
Sleep(20);
delete pBitmap;
GdiplusShutdown(gdiplusToken);
return hbm;
}
------------------------- src 3 ----------------------------------
// I_HMM._F.C
#include <windows.h>
#include <winuser.h>
#include <wingdi.h>
#include "hbapi.h"
#include "hbvm.h"
#include "hbstack.h"
#include "hbapiitm.h"
#include "commctrl.h"
#include "olectl.h"
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <shellapi.h>
#include <commdlg.h>
#include "hbstack.h"
#include "item.api"
#include "hbpcode.h"
#include "hbvmpub.h"
#include <stdio.h>
#include <shellapi.h>
#include <commdlg.h>
#define IF(x,y,z) ((x)?(y):(z))
#include "hbinit.h"
#include <vfw.h>
// ****************************
#pragma comment(lib,"F_HBM_W.lib") // LINK F_HBM_W.lib WITH I_HBM.LIB
// *****************************
extern HBITMAP IMAGE_HBITMAP_CPP(char * bFile_Name);
// ********************
HB_FUNC ( IMAGE_HBITMAP )
{
hb_retnl ( (LONG) IMAGE_HBITMAP_CPP(hb_parc(1)));
}
------------------------- src 4 ----------- F_HBM_W.DEF --------------------------
LIBRARY GDIPLUS
EXPORTS
GdipFree @225 ; GdipFree
GdipCloneImage @50 ; GdipCloneImage
GdipAlloc @34 ; GdipAlloc
GdipDisposeImage @143 ; GdipDisposeImage
GdiplusStartup @609 ; GdiplusStartup
GdipLoadImageFromFile @419 ; GdipLoadImageFromFile
GdipGetImageEncodersSize @273 ; GdipGetImageEncodersSize
GdipGetImageEncoders @272 ; GdipGetImageEncoders
GdiplusShutdown @608 ; GdiplusShutdown
GdipCreateBitmapFromFile @66 ; GdipCreateBitmapFromFile
GdipCreateHBITMAPFromBitmap @87 ; GdipCreateHBITMAPFromBitmap
------------------------- COMP.BAT -----------------------------------
DEL *.OBJ
DEL *.LIB
bcc32 -M -c -O2 -I%FWDIR%\include -tW I_HBM_F.C
bcc32 -M -c -O2 -I%FWDIR%\include -tW HBITMAP.cpp
IMPLIB F_HBM_W.LIB + F_HBM_W.DEF
TLIB I_HBM_F +I_HBM_F.OBJ +HBITMAP.OBJ
--------------------------- TEST.PRG -----------------
/*
TEST.PRG
*****************************************************************************
* TESTING FOR VIEW IMAGE *.BMP *.EMF *.GIF *.ICO *.JPG *.PNG *.TIF *.WMF *
* BY HATHAL 2012-10-02
http://WWW.LIVESYSTEM.NET &
LIVESYSTEM_NET@HOTMAIL.COM *
*****************************************************************************
*/
#include "FiveWin.ch"
#pragma BEGINDUMP
// ********************************
#pragma comment(lib,"I_HBM_F.lib")
#pragma ENDDUMP
// ********************
STATIC ownd
//----------------------------------------------------------------------------//
FUNCTION main()
local oBar
local oIni
local cUnidad
DEFINE WINDOW ownd FROM 1, 1 TO 22, 75 ;
TITLE "Open image *.BMP *.EMF *.GIF *.ICO *.JPG *.PNG *.TIF *.WMF" MENU BuildMenu() ;
MDI
DEFINE BUTTONBAR oBar OF oWnd
DEFINE BUTTON FILENAME "Open.bmp" OF oBar ;
ACTION (OPEN_IMAGE()) MESSAGE "Open image *.BMP *.EMF *.GIF *.ICO *.JPG *.PNG *.TIF *.WMF"
SET MESSAGE OF ownd TO FWVERSION CLOCK DATE KEYBOARD
ACTIVATE WINDOW ownd MAXIMIZED
RETURN NIL
//----------------------------------------------------------------------------//
function BuildMenu()
local oMenu
MENU oMenu
MENUITEM "&Open"
MENU
MENUITEM "&Open BITMAP" ACTION (OPEN_IMAGE()) ;
MESSAGE OemToAnsi( "Open image *.BMP *.EMF *.GIF *.ICO *.JPG *.PNG *.TIF *.WMF" )
ENDMENU
MENUITEM "&Exit" ACTION oWnd:End() MESSAGE "Close Window"
ENDMENU
return oMenu
//----------------------------------------------------------------------------//
function OPEN_IMAGE( )
local oWndBmp, oBar, oBmp, oIcon, oLupa
local oSay,oFont
local cBmpFile
cBmpFile:= cGetFile( "BITMAP (*.bmp)| *.bmp|" + ;
"JPG (*.jpg)| *.jpg|" + ;
"GIF (*.GIF)| *.GIF|" + ;
"TIF (*.TIF)| *.TIF|" + ;
"ICO (*.ICO)| *.ICO|" + ;
"PNG (*.PNG)| *.PNG|" + ;
"EMF (*.EMF)| *.EMF|" + ;
"WMF (*.WMF)| *.WMF|" ,"Select ALL IMAGE" )
if ! Empty( cBmpFile )
DEFINE FONT oFont NAME "Arial" SIZE 5, 13
DEFINE WINDOW oWndBmp FROM 2,2 TO 25,50;
TITLE "BITMAP " + cBmpFile MDICHILD
DEFINE BUTTONBAR oBar OF oWndBmp
DEFINE BUTTON OF oBar FILENAME "OPEN" ;
ACTION (jpg(cBmpFile,obmp)) ;
MESSAGE "ADJUST BITMAP ON WINDOW"
DEFINE BUTTON OF oBar FILENAME "ZOOMOUT.bmp" ;
ACTION AjustaZoom( oBmp ,"S",oSay ) ;
MESSAGE "ADJUST BITMAP ON WINDOW"
DEFINE BUTTON OF oBar FILENAME "..\bitmaps\DELWATCH.bmp" ;
ACTION AjustaZoom( oBmp ,"A",oSay ) ;
MESSAGE "+ ZOOM 10%"
DEFINE BUTTON OF oBar FILENAME "Font.bmp" ;
ACTION AjustaZoom( oBmp ,"R", oSay ) ;
MESSAGE "- ZOOM 10%"
DEFINE BUTTON OF oBar FILENAME "Bitmap.bmp" ;
ACTION ( oBmp:lStretch := .f. , oBmp:Reload(),;
oBmp:Zoom( 1 ), AjustaZoom( oBmp,"z",oSay ) ) ;
MESSAGE "LOAD BITMAP"
DEFINE BUTTON OF oBar FILENAME "Report.bmp" GROUP ;
ACTION imprimirBmp( cBmpFile, oBmp ) ;
MESSAGE "PRINTER BITMAP"
DEFINE BUTTON OF oBar FILENAME "exit.bmp" GROUP;
ACTION oWndBmp:End() ;
MESSAGE "CLOSE BITMAP"
@ 9, 210 SAY oSay PROMPT "BITMAP ADJUST" SIZE 200, 16 ;
PIXEL OF oBar FONT oFont
DEFINE CURSOR oLupa RESOURCE "Search"
@ 0, 0 BITMAP oBmp FILENAME "OPEN" SCROLL ADJUST OF oWndBmp ;
CURSOR oLupa ;
on left click (AjustaZoom(OBMP,"A",oSay)) ;
on right click (AjustaZoom(OBMP,"R",oSay))
oWndBmp:SetControl( OBMP )
ajustazoom(OBMP,"z",oBar)
obmp:HBITMAP:=IMAGE_HBITMAP(cBmpFile )
ACTIVATE WINDOW oWndBmp
oFont:End()
endif
return oWndBmp
function imprimirbmp(Bmp,oBmp)
local oPrn
local nZoom:=oBmp:Zoom()
local anchura:=oBmp:nWidth()*nZoom
local altura :=oBmp:nHeight()*nZoom
PRINT oPrn NAME "BITMAP"
PAGE
oPrn:SayBitmap(0,0,bmp,anchura,altura)
ENDPAGE
ENDPRINT
return nil
Function AjustaZoom(oBmp,cAccion,oSay)
local nZoom:=oBmp:Zoom()
do case
case cAccion == "S"
oBmp:lStretch := !oBmp:lStretch
oBmp:ScrollAdjust()
oBmp:Refresh( .t. )
case cAccion == "R"
if nZoom*10>1
oBmp:lStretch := .f.
nZoom:=nZoom-(0.10)
oBmp:Zoom(nZoom)
oBmp:Refresh()
oBmp:ScrollAdjust()
endif
case cAccion == "A"
oBmp:lStretch := .f.
nZoom:=nZoom+0.10
oBmp:Zoom(nZoom)
oBmp:Refresh()
oBmp:ScrollAdjust()
endcase
if oBmp:lStretch
oSay:SetText(Oemtoansi("BITMAP ADJUST"))
else
oSay:SetText(Oemtoansi( "ZOOM BITMAP...: "+alltrim(str(nZoom*100,10,0))+"%"))
endif
return NIL
//----------------------------------------------------------------------------//
procedure AppSys // XBase++ requirement
return
//----------------------------------------------------------------------------//
func jpg(cBmpFile2,obmp)
LOCAL cBmpFile:= cGetFile( "BITMAP (*.bmp)| *.bmp|" + ;
"JPG (*.jpg)| *.jpg|" + ;
"GIF (*.GIF)| *.GIF|" + ;
"TIF (*.TIF)| *.TIF|" + ;
"ICO (*.ICO)| *.ICO|" + ;
"PNG (*.PNG)| *.PNG|" + ;
"EMF (*.EMF)| *.EMF|" + ;
"WMF (*.WMF)| *.WMF|" ,"Select ALL IMAGE" )
local hBitmap :=IMAGE_HBITMAP(cBmpFile)
if hBitmap != 0
if oBmp:hBitmap != 0
PalBmpFree( oBmp:hBitmap, oBmp:hPalette )
oBmp:hBitmap = 0
oBmp:hPalette = 0
endif
oBmp:hBitmap = hBitmap
oBmp:hPalette = 0 // Where to get it from ?
PalBmpNew( oBmp:hWnd, hBitmap, 0 )
oBmp:ScrollAdjust()
oBmp:nX = 0
oBmp:nY = 0
endif
---------------------------------------------------END SOURCE -----------------------------------------------------------------
I hope to be useful for all.
I'm working on the language C\C++ ONLY .
Respect for all.
HATHAL.