Cover Flow

Cover Flow

Postby rhlawek » Thu Aug 23, 2012 11:54 pm

Two questions:

1) Is it possible to use the TCoverFlow() with either JPG or PNG files? The examples I have seen all use BMP files, but when I try to use JPG files the control doesn't seem to work.
2) Is it possible to populate the TCoverFlow() control, or any of the image controls such as TBitMap() or TImage() from data stored in memory (database blob) instead of loaded from a file on disk? If so, what is the syntax for doing this.

Any examples will be most appreciated. Thank you.

Robb
User avatar
rhlawek
 
Posts: 194
Joined: Sun Jul 22, 2012 7:01 pm

Re: Cover Flow

Postby Antonio Linares » Fri Aug 24, 2012 5:04 pm

Rob,

1. FiveWin provides Class TImage to manage most of different graphic files formats:

DEFINE IMAGE oImg FILENAME "name.gif" // or JPG, etc.

then you can use Class TCoverFlow Method AddCoverH() to supply the required bitmap handle:

oCF:AddCoverH( oImg:hBitmap, "title", nRGBColorTitle )

Here you have a complete working example:

Code: Select all  Expand view  RUN
// CoverFlow with GIFs, JPGs, etc.

#include "FiveWin.ch"

function Main()

   local oWnd, oCF, oImg1, oImg2, oImg3
   
   DEFINE IMAGE oImg1 FILENAME "..\gifs\matrix.gif"
   DEFINE IMAGE oImg2 FILENAME "..\gifs\015.gif"
   DEFINE IMAGE oImg3 FILENAME "..\gifs\006.gif"
   
   DEFINE WINDOW oWnd FROM 2, 2 TO 40, 96 color CLR_BLACK, CLR_CYAN

   oWnd:Center()
 
   oCF = TCoverFlow():New( 30, 30 )

   oCF:bAction = { | o, nCover, nOld | msginfo( "Seleted: " + str( nCover, 2 ) + CRLF + "From: " + str( nold ) ) }

   oCF:nMaxCover    = 5
   
   oCF:lAnimated= .T.
   oCF:SetColor( 0, CLR_BLACK )
   
   oCF:AddCoverH( oImg1:hBitmap, "matrix.gif", CLR_GREEN )
   oCF:AddCoverH( oImg2:hBitmap, "chair.gif", CLR_GREEN )
   oCF:AddCoverH( oImg3:hBitmap, "blue.gif", CLR_GREEN )

   oWnd:oClient = oCF

   ACTIVATE WINDOW oWnd ON INIT ( oCF:Resize(), oCF:Refresh() )
                       
   RELEASE OBJECT oImg1, oImg2, oImg3                
                       
return nil


Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42107
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Cover Flow

Postby Antonio Linares » Fri Aug 24, 2012 5:58 pm

Rob,

2. FiveWin provides a ReadBitmap( hDC, cBmpFileName ) to load a DIB from a file. We can modify its source code to load the dib from a string in memory, but that will only work for BMP files.

For other graphic formats files we can use FreeImage.dll functions, as explained here:

http://www.powerbasic.com/support/forums/Forum7/HTML/001513.html

the code that we need to port is:
FUNCTION FreeImage_LoadDIBFromHandle( BYVAL hDC AS LONG, BYVAL fHandle AS DWORD ) AS LONG

Its not difficult. We can work on that from next week on.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42107
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Cover Flow

Postby rhlawek » Tue Aug 28, 2012 12:14 am

Antonio,

Thank you for the detailed reply, I look forward to experimenting with this. It looks straightforward by this example. I like how you answer questions. Once answered they stay answered.

For the project I am working on I would get a good bit of benefit of being able to load straight from memory and never have to first write to disk so I am trying to put together the most efficient way to do so, where efficient means speed primarily, followed very closely by memory use. Certainly willing to test whatever makes sense.

I am also creating the jpg files and have some flexibility in what format to use. I have so far chosen jpg because the files are 5Kb, while the equivalent bmp file is 212Kb. So long as I can get the desired resolution and quality at minimal file\memory and/or most efficient memory use, I'm open to test most anything. I don't personally have enough testing done yet to determine which is most efficient for my needs, but I'm learning.

Robb
User avatar
rhlawek
 
Posts: 194
Joined: Sun Jul 22, 2012 7:01 pm

Re: Cover Flow

Postby HATHAL » Tue Oct 02, 2012 11:48 am

Antonio.
I stopped with image problems
I written source C + + works with all the images.
It HBITMAP return with any image.
No DLL libraries or anything outside source.
Windows operating system uses technology.
Working with iamge.
******************
BMP
EMF
GIF
ICO
JPG
PNG
TIF
WMF
******************
If you have a gift to me lift the full source.
Greetings hathal :D
User avatar
HATHAL
 
Posts: 77
Joined: Tue Nov 15, 2005 3:38 pm
Location: The Kingdom Saudi Arabia -Riyadh

Re: Cover Flow

Postby Antonio Linares » Tue Oct 02, 2012 12:06 pm

Hathal,

If you let me review it, and I find it useful, then I will compensate you :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42107
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Cover Flow

Postby HATHAL » Tue Oct 02, 2012 8:23 pm

i Sent to you email .

Your email does not receive.
--------------------
This is an automatically generated Delivery Status Notification. Delivery to the following recipients failed. alinares@fivetechsoft.com


--Forwarded Message Attachment--
From: livesystem_net@hotmail.com
To: alinares@fivetechsoft.com
Subject: image view full source
Date: Tue, 2 Oct 2012 23:21:34 +0300
----------------------------
Antonio
What is your e-mail now ؟؟
User avatar
HATHAL
 
Posts: 77
Joined: Tue Nov 15, 2005 3:38 pm
Location: The Kingdom Saudi Arabia -Riyadh

SOURCE FOR IMAGE WITH *.BMP *.EMF *.GIF *.ICO *.JPG *.PNG *

Postby HATHAL » Sun Oct 06, 2013 8:46 pm

--------------------------- 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 .
:D
Respect for all.
HATHAL.
User avatar
HATHAL
 
Posts: 77
Joined: Tue Nov 15, 2005 3:38 pm
Location: The Kingdom Saudi Arabia -Riyadh

Re: Cover Flow

Postby Antonio Linares » Mon Oct 07, 2013 9:50 am

Hathal,

many thanks!

My email is alinares@fivetechsoft.com but it uses gmail, so attached EXEs, or ZIP, are bounced back. To send a ZIP file please rename it as ZOP and gmail will accept it, thanks :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42107
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Cover Flow

Postby HATHAL » Tue Oct 08, 2013 1:23 pm

oK.
source has been sent to you my friend Antonio.
--------------------
But the same problem was returned mail
See below.
------------------------------
This is an automatically generated Delivery Status Notification.
Delivery to the following recipients failed.
alinares@gmail.com
--Forwarded Message Attachment--
From: livesystem_net@hotmail.com
To: alinares@gmail.com
Subject: FW: image view full source
Date: Tue, 8 Oct 2013 16:26:46 +0300
-----------------
Send me a message from I your e-mail.
Send you a refund attachments.
hathal.
User avatar
HATHAL
 
Posts: 77
Joined: Tue Nov 15, 2005 3:38 pm
Location: The Kingdom Saudi Arabia -Riyadh

Re: Cover Flow

Postby Antonio Linares » Tue Oct 08, 2013 2:27 pm

Hathal,

You have to use alinares@fivetechsoft.com or antonio.fivetech@gmail.com

in both cases, please rename the file as *.zop

thanks :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42107
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 38 guests