Page 1 of 2

GFL New Source Conversion help. !! Working !!

Posted: Wed Jul 09, 2003 4:57 am
by Inner
http://www.xnview.com

Is this the only freeware multi-format image loader/convertor/saver available or is there another, that supports more or less then 350 image formats?

I had an attempt at converting it, but I am no VB expert or any of the other languages it supports natively, like delphi, bcc, vc++ etc. the most I could port from the source code provided was a black image, I got all the other functions for infomation working, but when it comes to image display I am useless.

I can post my work if anyone wishes, to try futher.

[fustrated@self] - I don't know why PureBasic hasn't picked up this library already it would sovel imaging loading perminantly, and there wouldn't be any need for a plugin system like we have to day, because all formats are pretty much coverted, sure no one really needs 350 formats support out of those 350 only a few would be used maybe 10 or so, but it'd be nice. [/fustrated@self]

Posted: Wed Jul 09, 2003 8:31 am
by LarsG
I guess a reason for it not being used is that this program is not free for commercial use.. it costs 27$ for a 1 workstation lisense...

Posted: Wed Jul 09, 2003 8:34 am
by Inner
I guess that's a fare enough comment, except I am a freeware developer not a "expens'o'ware" developer.

Posted: Wed Jul 09, 2003 8:50 am
by Fred
I can recommend 'DevIL' which is really cool.

Posted: Wed Jul 09, 2003 9:17 am
by Inner
Er.. I guess that standards for Development Image Library :) --- ( I'm a Christian ) --- LOL . I'll take a look at it thanks Fred.

Just had a look, doesn't support nearly as many formats as xnview. :( keep in mind that beating or being equal to 350+ formats is pretty hard tasks to challange.

That and I don't feel comfortable with the name.

Posted: Wed Jul 09, 2003 1:32 pm
by Fred
Mouarf :twisted:

Posted: Wed Jul 09, 2003 1:51 pm
by Inner
:evil: 8O :arrow: Stage Left == Run ======= :arrow:

:)

I may just have to bite the bullet and build a interface of some discription inbetween PB and GFL.

Posted: Wed Jul 09, 2003 4:45 pm
by GedB
Irfan view is excellent, and supports batch conversions.

www.irfanview.com

Posted: Wed Jul 09, 2003 4:51 pm
by Inner
Yes it is excellent but;

doesn't support 350 formats
doesn't have an SDK for developers as far as I know.
& would mean I'd have to use the RunProgram command, which is umm not an elagant way to implyment something. :cry:

[background]
I guess by now it would appear as thou I'm being picky, but cd databasing software needs a wide deepth of flexibilite to identify/display/convert & resize all sorts of media, the last email I want about my software is can you support x or y image format, worse still getting an email of abuse because I just added a format of some discription that wasn't there before, forcing an end user to recatalog an entire cd collection. [ yes the idea is to when scanning cd's to take thumb nails of ever image it comes accross, store that data, and recall it again without having to have the cd in the drive, if the bigger image is requested obviously the correct cd would have to be re-inserted. ] the converting part I heaverly cludged together with NConvert.exe and I dispise it entirely. because it slows the scanner down having to fire up a .exe just to perform a resize on a .neo image file, or any other format for that matter.

this is my current work : http://www.inet.net.nz/~tjr/irc/gfl-purebasic.rar

maybe someone could help with it. [ please ] pretty please, please with a cherry on top :)

Posted: Thu Jul 10, 2003 2:37 pm
by Inner
It comes down to this last few problems;

Code: Select all

static void GetDIBFromBitmap( GFL_BITMAP *bitmap, LPBITMAPINFOHEADER * pbitmap_info, unsigned char **data )
{
	int i;
	int j;
	int bytes_per_line; 
	unsigned char *ptr_src;
	unsigned char *ptr_dst; 
	LPBITMAPINFOHEADER bitmap_info; 
	RGBQUAD *colormap; 

	*data = NULL; 
	*pbitmap_info = NULL; 

	bitmap_info = *pbitmap_info = calloc( 1, sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD) ); 
	colormap = (unsigned char *)bitmap_info + sizeof(BITMAPINFOHEADER); 
		
	bitmap_info->biSize   = sizeof(BITMAPINFOHEADER); 
	bitmap_info->biWidth  = bitmap->Width; 
	bitmap_info->biHeight = bitmap->Height; 
	bitmap_info->biPlanes = 1; 
		
	if ( bitmap->Type == GFL_BINARY )
	{
		bytes_per_line = ((bitmap->Width + 31) / 32) * 4; 
		bitmap_info->biClrUsed = 2;
		bitmap_info->biBitCount = 1; 
	}
	else
		if ( bitmap->Type == GFL_GREY || bitmap->Type == GFL_COLORS )
		{
			bytes_per_line = (bitmap->Width + 3) & ~3; 
			bitmap_info->biClrUsed = 256;
			bitmap_info->biBitCount = 8; 
		}
		else
		{
			bytes_per_line = (bitmap->Width * 3 + 3) & ~3; 
			bitmap_info->biClrUsed = 0;
			bitmap_info->biBitCount = 24; 
		}

	bitmap_info->biCompression = BI_RGB; 
    bitmap_info->biSizeImage = bytes_per_line * bitmap->Height; 
    bitmap_info->biClrImportant = 0; 
		
	if ( bitmap_info->biClrUsed > 0 )
	{
		if ( bitmap->Type == GFL_BINARY )
		{
			colormap[0].rgbRed   = 0; 
		    colormap[0].rgbGreen = 0; 
			colormap[0].rgbBlue  = 0;

			colormap[0].rgbRed   = 255; 
			colormap[0].rgbGreen = 255; 
			colormap[0].rgbBlue  = 255;
		}
		else
		if ( bitmap->Type == GFL_GREY )
		{
			for ( i=0; i<bitmap->ColorUsed; i++ )
			{
				colormap[i].rgbRed   = (i * 255) / (bitmap->ColorUsed-1); 
				colormap[i].rgbGreen = colormap[i].rgbRed; 
				colormap[i].rgbBlue  = colormap[i].rgbRed; 
			}
		}
		else
		{
			for ( i=0; i<bitmap->ColorUsed; i++ )
			{
				colormap[i].rgbRed   = bitmap->ColorMap->Red[i]; 
				colormap[i].rgbGreen = bitmap->ColorMap->Green[i]; 
				colormap[i].rgbBlue  = bitmap->ColorMap->Blue[i]; 
			}
		}
	}
}
And this function;

Code: Select all

					
StretchDIBits( hDC, 0, 0, TheBitmap->Width, TheBitmap->Height, 0, 0, TheBitmap->Width, TheBitmap->Height, dib_data ? dib_data : TheBitmap->Data, (BITMAPINFO *)dib_info, DIB_RGB_COLORS, SRCCOPY ); 
I've no idea how to convert those, he is using strange symbols I've not see ever before in C, like ~,: And ?.

Posted: Thu Jul 10, 2003 4:38 pm
by Saboteur
~ = one's complement (same in PB)

Code: Select all

x ? a : b 
is equal to

Code: Select all

if x
  a
else
  b
endif

Posted: Thu Jul 10, 2003 5:45 pm
by Inner
Thanks Saboteur

Posted: Thu Jul 10, 2003 7:15 pm
by Inner
New Source, and yes it doesn't work;

But it's closer :)

http://www.inet.net.nz/~tjr/irc/GFL_PB2.zip

includes the VB source
includes my pitaful atempt at porting it too.

But it kinda works if you like "Software Failure" :)

I feel completely useless, so anyone that whats to download the latest botch up, and mock me your more than welcome.

Posted: Thu Jul 10, 2003 10:37 pm
by Doobrey
Inner wrote: I feel completely useless, so anyone that whats to download the latest botch up, and mock me your more than welcome.
Don`t give up Inner, it`s all part of the learning process. Sometimes you can get stuck for ages on a bit of code, but then somehow it all comes together.
Porting code from a language you have little knowledge of is never easy but once you get to know the way it works it becomes a bit easier.

I tried writing a winamp plugin using PB last year..it kept crashing after 2 secs, so I gave up..until yesterday, spotted that a procedure in my DLL should have been a ProcedureCDLL instead of ProcedureDLL (no idea why Winamp mixes the 2 types in one plugin!) and it works. That one f#@$ing line took me 3 or 4 evenings of bugtracking to figure out :x

Posted: Fri Jul 11, 2003 1:21 am
by Inner
That'd be because ProcedureCDLL is a new resent command ;)

It's alot diferent trying to convert a programming language when the only comments in the source are french!, which makes it twice as hard because your going off purely code and only code.

The problem here is I know what I am doing, it's just not doing it.. the old and very worn out road of, "it doesn't work, it should work acording to logic"