Pelles C forum

C language => User contributions => Topic started by: Grincheux on March 23, 2016, 11:08:03 AM

Title: Image Viewer Ended
Post by: Grincheux on March 23, 2016, 11:08:03 AM
Binaries here (http://www.phrio.biz/ImagesViewer/7UpPImageViewer.exe)
Screen (http://www.phrio.biz/ImagesViewer/Presentation/Presentation_00005.jpg) (http://ivw.phrio.biz/Accueil) here
Title: Re: Image Viewer Ended
Post by: Grincheux on March 29, 2016, 08:41:33 AM
Hello the Ghosts

Added possiblity to play with some filters on the images chanels.
Added histogram.
Title: Re: Image Viewer Ended
Post by: Grincheux on April 13, 2016, 05:19:32 PM
(http://www.phrio.biz/ImagesViewer/gallery/Gallery_00036.jpg)
Download latest version here (http://www.phrio.biz/ivw/DonationWare/7UpEuphory.exe)

Some useful functions in (http://www.ivw.phrio.biz/Some_useful_functions) EUPHORY. ;D

Quote
2016/04/14 - When inserting data into memory database, I use TRANSACTION, to be faster.
2016/04/13 - Added new sort options.
2016/04/13 - Added the possibility to save only the image datas.
2016/04/13 - Added "Backup Datas" to get all the informations about directory images. Created an other CSV file.
2016/04/13 - When histogram is displayed, created a CSV file with histogram data.
2016/04/13 - Added some filters effects.
2016/04/13 - Replaced "Convolove 3x3" with new effects items.
2016/04/13 - Added histogram datas to the main database.
2016/04/13 - Added "Neighbors Detection".
2016/04/04 - Reorganized main menu.
2016/04/04 - Added Rows/Cols effects.
2016/04/04 - Added Box and Cube effects.
2016/03/31 - Euphory will be the new name of the donationware version.
2016/03/31 - Removed DLL filters.
2016/03/31 - A SQLite database replace the filters dll.
2016/03/29 - Renaming ImageViewer : E4I - Effects for Images - Euphorie - Euphory.
2016/03/29 - You can copy the histogram to the clipboard.
2016/03/29 - You can save the histogram to a file.
2016/03/29 - Added Histogram Tab.
2016/03/27 - Added a filter Tab. No easy to use but reults are interesting. Can apply a diffrent filter on Red, Green, Blue Channels.
2016/03/27 - Removed generated MSVC 2015 manifest, problem using SYSLINK, but none with Pelle's.
2016/03/27 - Added Effect 10.80
2016/03/27 - Added Effect 0.88
2016/03/27 - Added Donationware link in the meu bar for "French" & "English"
2016/03/24 - Added File Name displayed on the status bar while cleaning metadas.
2016/03/24 - Modified Crop all files.
2016/03/24 - Added File Name and Path to the dialog box informations.
2016/03/24 - Changed the Find Duplicates dialog box.
2016/03/24 - Modified some dialog texts.
2016/03/23 - Added Blend Cross effect.
2016/03/23 - Synchronized images between main screen and zoom/effects.
2016/03/23 - Added Cross effect.
2016/03/21 - Added Double Mirroring effect.
2016/03/21 - Added 3D Tab.
2016/03/21 - Added Eiffel Tower effect.
2016/03/21 - Added Tilt effects.
2016/03/17 - Making sort into another temporary table rather than the same.
2016/03/17 - Added more convolution filters. For tests.
2016/03/17 - Corrected a bug in Sort option.
2016/03/17 - Corrected a bug in installer. The profile ImageViewer.ini could not be updated.
2016/03/15 - Resolved problem of spacing icons in toolbar images with the help of Timo Lähde.
2016/03/11 - Reajusted status bar display area.
2016/03/11 - Corrected minor bugs.
2016/03/11 - Corrected sources files for MSVC2015 and Pelle's C Compiler give the same results.
2016/03/11 - Added C/C++ runtime dll into installation package.
2016/03/11 - Corrected bug in Sort function.
2016/03/11 - Added effect Java Niaise.
2016/03/10 - Corrected some bugs.
2016/03/10 - Added save option for layers.
2016/03/10 - Added Copy to clipboard for layers.
2016/03/10 - Added new fusion modes.
2016/03/08 - Added a kind of layers.
2016/03/07 - Added Colors files (140 files).
2016/03/05 - Added textures of my own.
2016/02/26 - Added CoolMenu (Owner drawn menu adapted by Mike Caetano 1/2002 - from source by James Brown,catch22.uk.net)
2016/02/26 - Added 128 undo levels for Memory option.
2016/02/26 - Added Memory option.
2016/02/26 - Added Rotate option.
2016/02/23 - Added 10 new effects
2016/02/22 - Some bugs corrected
2016/02/22 - Changed the Gallery with free images
2016/02/22 - Changed the site presentation with free images (Common Wiki or CopyLeft).
2016/02/22 - Added five vertical mirrors.
2016/02/21 - Added copy image to clipboard.
2016/02/21 - Added copy effect to clipboard.
2016/02/21 - Added auto cropping option.
2016/02/21 - Added functions for removing metadatas.
2016/02/21 - Added count colors options.
2016/02/21 - Modified main menu
2016/02/21 - Added filter : Laplace
2016/02/20 - Added filter : Kirsch
2016/02/20 - Added filter : Robinson
2016/02/20 - Added filter : Prewitt
2016/02/20 - Added filter : Sobel
2016/02/20 - Added eight filters that I did myself.
2016/02/20 - Added contours detection
2016/02/20 - Made only one archive and only one installer.
2016/02/20 - Merged the two projects under the same folder.
2016/02/20 - Corrected big bugs in grey levels conversion.
2016/02/19 - Added Gray levels.
2016/02/19 - Modified Main Menu.
2016/02/19 - Added Horizontal & Vertical Mirror.
2016/02/19 - Created a version for Visual Studio Community 2015.
2016/02/18 - Use double buffer for drawing icons.
2016/02/18 - Replace the highlight icons with colored border.
2016/02/18 - Added a tab for real size effect image.
2016/02/18 - Added a tab for real size image.
2016/02/18 - First release available.
2016/02/14 - A preview is available.
2016/01/23 - Start writting program.
Title: Re: Image Viewer Ended
Post by: JohnF on April 13, 2016, 07:27:24 PM
You have been busy, I've never seen a project completed so quickly.

Are you pleased with it?

John
Title: Re: Image Viewer Ended
Post by: Grincheux on April 13, 2016, 08:18:04 PM
(http://www.phrio.biz/ImagesViewer/gallery/Gallery_00007.jpg) This image makesme pretty. Thank you me.
I am very pleased and always have new ideas.
Now I would like to make some 3D with images.
For the instant I am creating filters. I have to create 387 420 488 filters. Happily I made an option that deletes similar images...
I have 66 folders with 100 SQLite files per folder.
I use two compilers: MSVC and Pelles. Pelles is the best between the two. It find errors that MS does not detect.
I have three warnings that I don't understand.
Quote
C:\Users\Grincheux\Documents\Visual Studio 2015\Projects\Euphory\Sqlite.c(218): warning #2154: Unreachable code.
C:\Users\Grincheux\Documents\Visual Studio 2015\Projects\Euphory\Sqlite.c(645): warning #2154: Unreachable code.
C:\Users\Grincheux\Documents\Visual Studio 2015\Projects\Euphory\Sqlite.c(767): warning #2154: Unreachable code.
When the program runs It uses these functions without any problem.
Yestirday I resolved one warning but here I can't.

Might I ask you to read the following page; http://ivw.phrio.biz/Some_useful_functions (http://ivw.phrio.biz/Some_useful_functions)
Because I had to use Google Translate, I made some corrections but it you stay any errors.

Thanks.

Philippe ;)
Title: Re: Image Viewer Ended
Post by: JohnF on April 14, 2016, 08:26:10 AM
Post the parts that trouble you here, I can't help today but maybe someone else will help.

John
Title: Re: Image Viewer Ended
Post by: frankie on April 14, 2016, 09:11:57 AM
I use two compilers: MSVC and Pelles. Pelles is the best between the two. It find errors that MS does not detect.
I have three warnings that I don't understand.
Quote
C:\Users\Grincheux\Documents\Visual Studio 2015\Projects\Euphory\Sqlite.c(218): warning #2154: Unreachable code.
C:\Users\Grincheux\Documents\Visual Studio 2015\Projects\Euphory\Sqlite.c(645): warning #2154: Unreachable code.
C:\Users\Grincheux\Documents\Visual Studio 2015\Projects\Euphory\Sqlite.c(767): warning #2154: Unreachable code.

These messages means that in your code there are some conditional parts which conditions can be solved statically at compile time. So the compiler detects that the code could "never be reached" because the condition will never be true and remove it as dead code.
I.e. consider following chunk:
Code: [Select]
const int a=1;
void foo(void)
{
if (a == 0)
printf("a is zero!\n");
}
It will give " warning #2154: Unreachable code." because 'a' is constant and always !=0, so the condition in the if is never satisfied and the conditional code will never be executed (unreachable).
Title: Re: Image Viewer Ended
Post by: Grincheux on April 14, 2016, 10:44:07 AM
Yes Frankie, I agree, I found such an error two days ago with a null pointer. I set it to NULL and after I test it! But here, no idea.
I join my source code. MSVC does not help me to resolve it, normal it's a BLIND compiler
Title: Re: Image Viewer Ended
Post by: frankie on April 14, 2016, 12:27:39 PM
Grincheux the code you posted is huge. Please restrict it to a compilable sample.
At least let us know which lines give the warning.
Title: Re: Image Viewer Ended
Post by: Grincheux on April 14, 2016, 02:46:01 PM
The first THREE lines tell where the error is.
Title: Re: Image Viewer Ended
Post by: TimoVJL on April 14, 2016, 03:19:32 PM
Partial code for SQLite_GetFileName for test with or without optimization.
Code: [Select]
PellesForum2.c(30): warning #2154: Unreachable code.
Title: Re: Image Viewer Ended
Post by: Grincheux on April 14, 2016, 04:07:49 PM
A big mystery. Thank you for making a new project
Title: Re: Image Viewer Ended
Post by: frankie on April 14, 2016, 06:12:24 PM
The warning correctly comes from the inlining of the strsafe functions, specifically StringCchCopy().
The compiler, without any more spec, inlines a local definition for specific safe string functions. In your case you use StringCchCopy() that is defined, in strsafe.h, as:

Code: [Select]
#ifndef STRSAFE_NO_CCH_FUNCTIONS
#ifdef STRSAFE_INLINE
STRSAFEAPI StringCchCopyA(char *pszDest, size_t cchDest, const char *pszSrc)
{
    if (cchDest > STRSAFE_MAX_CCH)
        return STRSAFE_E_INVALID_PARAMETER;
    else
        return StringCopyWorkerA(pszDest, cchDest, pszSrc);
}

...

#ifdef STRSAFE_INLINE
STRSAFEAPI StringCopyWorkerA(char *pszDest, size_t cchDest, const char *pszSrc)
{
    HRESULT hr = S_OK;

    if (cchDest == 0)
    {
        hr = STRSAFE_E_INVALID_PARAMETER;
    }
    else
    {
        while (cchDest && *pszSrc != '\0')
        {
            *pszDest++ = *pszSrc++;
            cchDest--;
        }

        if (cchDest == 0)
        {
            pszDest--;
            hr = STRSAFE_E_INSUFFICIENT_BUFFER;
        }

        *pszDest= '\0';
    }

    return hr;
}

...

In your code you use always constants for max string length when calling StringCchCopy():

Code: [Select]
//C:\Users\Grincheux\Documents\Visual Studio 2015\Projects\Euphory\Sqlite.c(218): warning #2154: Unreachable code.
LPSTR SQLite_GetFileName(int __iItem,LPSTR __lpszFileName)
{
StringCchCopy(__lpszFileName,MAX_PATH,(LPSTR) sqlite3_column_text(_hStatement,0)) ;
...

//C:\Users\Grincheux\Documents\Visual Studio 2015\Projects\Euphory\Sqlite.c(645): warning #2154: Unreachable code.
int SQLite_Sort(HWND __hWnd,int _iId)
{
if(szCurrentFile[0] == '\0') StringCchCopy(szCurrentFile,MAX_PATH,_lpszImg) ;
...
StringCchCopy(szCurrentDialogFile,MAX_PATH,_lpszImg) ;
...
if(_szFirstFile[0] == '\0') StringCchCopy(szCurrentFile,MAX_PATH,_lpszImg) ;
...
StringCchCopy(szCurrentFile,MAX_PATH,_szFirstFile) ;
...

//C:\Users\Grincheux\Documents\Visual Studio 2015\Projects\Euphory\Sqlite.c(768): warning #2154: Unreachable code.
void SQLiteDB_BackupToCsv(HWND __hWnd)
{
...
StringCchCopy(_szTmp1,sizeof(_szTmp1),"\"Item\";\"Image\";\"lParam\";\"FileSize\";\"ImgSize\";\"ImgWidth\";\"ImgHeight\";\"ImgRatio\";\"MedianRed\";\"MedianGreen\";\"MedianBlue\";\"NumRed\";\"NumGreen\";\"NumBlue\";\"MaxRed\";\"MaxGreen\";\"MaxBlue\";\"AnalyzedColors\";\"NumberOfUniqueColors\";\"FileMD5\";\"ImgMD5\";\"CurrentFile\"\n") ;
...
StringCchCopy(_szTmp1,sizeof(_szTmp1),"An error occured during backup operation") ;
...

For this reason when inlining the function StringCopyWorkerA() happen that the first check is constant so the conditional code is never used:

Code: [Select]
STRSAFEAPI StringCopyWorkerA(char *pszDest, size_t cchDest, const char *pszSrc)
{
    HRESULT hr = S_OK;

    if (cchDest == 0)    //if cchDest  is a constant and always !=0
    {
        hr = STRSAFE_E_INVALID_PARAMETER;    //This code will never execute, so it is **unreacheble**!!!!
    }

As a check replace the main function in the project provided by Timo with the following:

Code: [Select]
LPSTR SQLite_GetFileName(int __iItem,LPSTR __lpszFileName)
{
sqlite3_stmt *_hStatement ;
LPSTR _lpszErrorMessage ;
char _szTmp[1024] ;
volatile int max = MAX_PATH;

if(!__lpszFileName)
return (NULL) ;

*__lpszFileName = '\0' ;

StringCbPrintf(_szTmp,sizeof(_szTmp),szSQL_GetFileName,__iItem) ;

if(sqlite3_prepare_v2(hSQLite,(const char *) _szTmp,-1,&_hStatement,(const char **) &_lpszErrorMessage) != SQLITE_OK)
return (NULL) ;

while(sqlite3_step(_hStatement) == SQLITE_ROW)
//StringCchCopy(__lpszFileName,MAX_PATH,(LPSTR) sqlite3_column_text(_hStatement,0)) ;
StringCchCopy(__lpszFileName,max,(LPSTR) sqlite3_column_text(_hStatement,0)) ;

sqlite3_reset(_hStatement) ;
sqlite3_finalize(_hStatement) ;

return (__lpszFileName) ;
}

Note the volatile variable max that tells the compiler to not assume that the value will be constant. In this case the condition if (cchDest == 0) cannot be resolved at compile time, the conditional code must be generated and the warning is not issued.
Title: Re: Image Viewer Ended
Post by: Grincheux on April 14, 2016, 06:44:54 PM
Quote
Building 3D.obj.
Building About.obj.
Building Api_Borders.obj.
Building Api_Convolve.obj.
Building Api_Datas.obj.
Building Api_Effects.obj.
Building Api_Flou.obj.
Building Api_Functions.obj.
Building Api_IDCat.obj.
Building Api_Mirror.obj.
Building Api_Red.obj.
Building Api_Rotate.obj.
Building Api_Sort.obj.
Building Apr_Grey.obj.
Building Calques.obj.
Building Clipboard.obj.
Building Colors.obj.
Building CoolMenu.obj.
Building Cube.obj.
Building Datas.obj.
Building Dll_Effects.obj.
Building DonationWare.obj.
Building Effects.obj.
Building Euphory.obj.
Building Euphory.res.
Building FilterByColors.obj.
Building Filters_All.obj.
Building Filters_Dialog.obj.
Building Filtres.obj.
Building Histogramme.obj.
Building Icones.obj.
Building Images.obj.
Building ImagesToolBar.obj.
Building Incline.obj.
Building Incline2.obj.
Building Infos.obj.
Building Layer_Fusion.obj.
Building Layer_Paint.obj.
Building Layers.obj.
Building md5.obj.
Building Memory.obj.
Building Metadatas.obj.
Building Profile.obj.
Building Sqlite.obj.
Building Utils.obj.
Building Zoom.obj.
Building PEuphory.exe.
Successfully signed and timestamped 'PEuphory.exe'
Done.

I would never have found. Great work!
Title: Re: Image Viewer Ended
Post by: Grincheux on April 14, 2016, 07:00:51 PM
Now it's OK but I don't understand what you told.

I had replaced the CONSTANT with a sizeof, alway the same problem but with your solution it's clean.
I never had used STRSAFE, I made it once, this is the last!

Quote
volatile int sizeof_Tmp1 = sizeof(_szTmp1) ;
StringCchCopy(_szTmp1,sizeof_Tmp1,"\"Item\";\"Image\";\"lParam\";\"FileSize\";\"ImgSize\";\"ImgWidth\";\"ImgHeight\";\"ImgRatio\";\"MedianRed\";\"MedianGreen\";\"MedianBlue\";\"NumRed\";\"NumGreen\";\"NumBlue\";\"MaxRed\";\"MaxGreen\";\"MaxBlue\";\"AnalyzedColors\";\"NumberOfUniqueColors\";\"FileMD5\";\"ImgMD5\";\"CurrentFile\"\n") ;
Title: Re: Image Viewer Ended
Post by: frankie on April 15, 2016, 10:10:50 AM
Grincheux thank you for appreciation.
the operator sizeof gives a constant result. So the behavior is the same as for the #define.
The workaround to remove the annoyance are 2 (choose only one):

If you choose the first case use:
Code: [Select]
#pragma warn(disable:2154)
For the second:
Code: [Select]
#define STRSAFE_LIB 1
#include <Strsafe.h>
Title: Re: Image Viewer Ended
Post by: Grincheux on April 15, 2016, 02:06:42 PM
There is a third solution, DO NOT USE STRSAFE.

I choose this one. I don't want to disable that warning, it can helps while writing bad code.

Quote
Je tiens à vous remercier pour cette aide précieuse, sans vous je n'y serais jamais arrivé :).
Quote
Thank you for this valuable help, without you I would never have happened. :)
Title: Re: Image Viewer Ended
Post by: Grincheux on April 15, 2016, 07:55:35 PM
(http://www.phrio.biz/ImagesViewer/gallery/Gallery_00029.jpg)
Now there is no warnngs.
You can download the full program (MSVC + PELLE) here (http://www.phrio.biz/ivw/DonationWare/7UpEuphory.exe)
For details see here (http://ivw.phrio.biz/Accueil) and here (http://ivw.phrio.biz/Some_useful_functions).

If you find errors or mistakes tell it to me in this forum.

Thank you for your help. :) :) :)

Philippe RIO
France, Jura
Title: Re: Image Viewer Ended
Post by: Grincheux on April 27, 2016, 06:41:00 PM
Source code (http://www.phrio.biz/ivw/DonationWare/$$Euphory.exe) Psw = jardin39600

I tested a program (I answer to the post), in this program it loaded 19201 images, when treated by my program, it only kept 4 !

4/19204 = 2.08 !
Title: Re: Image Viewer Ended
Post by: Grincheux on April 29, 2016, 02:18:30 AM
Quote
2016/04/28 - Created P-Euphory.ini for PEuphory.exe.
2016/04/28 - Possibility or not to make the backup of DB_Effects. Backup is a long operation. Database can be used during backup.
2016/04/28 - Added backup at startup of DB_Effects in Temp directory. The file is named DB_Effects.db.Bak.
2016/04/28 - The DB_EFFECTS database is loaded in memory rather than making disk accesses.
2016/04/28 - When convolve operation is ended, the files are re-loaded automaticaly.
2016/04/28 - Added an option to display or not the end of convolve operations.
2016/04/27 - Added a flash and a beep when a long operation is finished.
2016/04/27 - Added a thread priority when generating filters. They are generated in background, when finished the program comes back to normal priority.
2016/04/27 - Replaced MD5 with CRC32
2016/04/27 - Added some masks and removed many others.
2016/04/27 - Modified "Neighbors" algorythm to delete more images when colors are very near. It is based on the Red, Green and Blue median.
2016/04/27 - Added auto delete duplicate image bits. It was too long making that with a listbox. I let the last way.

Profile : Euphory.ini
Quote
; Thumbs Width must be equal to Thumbs Canvas Width - 8
;
[Euphory]
Last Folder=E:\Euphory\Images de Tests\7x7\Work\01
Display End of Convole Operation=0
Backup DB_Effects=0
Thumbs Width=256
Thumbs Height=256
Thumbs Width Gap=8
Thumbs Height Gap=8
Thumbs Canvas Width=264
Thumbs Canvas Height=264
Icons Background=0
Images Background=0
Text Color=255
OutLine Color=0

Need users to make test, please.

Download (http://www.phrio.biz/ivw/DonationWare/7UpEuphory.exe)
Title: Re: Image Viewer Ended
Post by: JohnF on April 29, 2016, 12:15:01 PM
Can't run it because of all those strange looking DLLs.

API-MS-WIN-SERVICE-CORE-L1-1-0.DLL
""
""
""

John
Title: Re: Image Viewer Ended
Post by: TimoVJL on April 29, 2016, 12:39:05 PM
Those belongs to Visual C++ Redistributable for Visual Studio 2015 (https://www.microsoft.com/en-us/download/details.aspx?id=48145)
Title: Re: Image Viewer Ended
Post by: JohnF on April 29, 2016, 01:29:29 PM
Well, that's not a good idea. None of the apps on my PC need those.

John
Title: Re: Image Viewer Ended
Post by: Grincheux on April 29, 2016, 07:06:02 PM
Here are the files (http://www.phrio.biz/ivw/DonationWare/WinDll.7z)
Title: Re: Image Viewer Ended
Post by: JohnF on April 29, 2016, 07:15:30 PM
I put all those DLL's in your folder, here is the error message.

EDIT: I'll not be trying again.

John
Title: Re: Image Viewer Ended
Post by: Grincheux on April 29, 2016, 08:42:34 PM
Into the folder where ImageViewer is installed, you will find the Pelle's Version PEuphory.exe