View Full Version : Vampyre Imaging Library 0.22.0 Released
Galfar
05-02-2007, 01:11 PM
New version of Imaging was released few days ago. Support for quite a few new image
file formats was added and many bugs were fixed.
Current Imaging info and features:
Imaging is native Object Pascal cross platform image loading, saving and
manipulation library. Main development language is Object Pascal (Delphi, Kylix and Free Pascal compilers are supported) and there are interfaces to the library (compiled into dll/so) for other languages like C/C++ and Delphi.NET. Currently supported operating systems are Windows, Linux, FreeBSD (and some other Unixes), DOS (and .NET using unmanaged DLL). Supported CPU architectures are x86 and AMD64.
Currently supported image file formats are: (loading and saving) PNG, JPEG, DDS, TGA, MNG, JNG, BMP, JPEG2000, PGM, PPM, PAM, PFM (loading only) PCX, and PBM.
Many internal image data formats are supported: 8/16/24/32/48/64 bit RGB and ARGB formats, indexed formats, grayscale formats, half/single precision floating point formats, and compressed formats DXT1, DXT3, and DXT5.
Additionally there are extensions for creating SDL surfaces, OpenGL and D3D9 textures, VCL/LCL TGraphic descendants, canvas class, and more.
Imaging homepage: http://imaginglib.sourceforge.net
savage
05-02-2007, 01:31 PM
Upgraded to News Post.
JernejL
25-02-2007, 10:49 AM
i can't get it to work in freepascal under win32, it errors with this:
C:\appbuilder\imaginglib0220\Imaging\Source\JpegLi b\imjdapimin.pas(3,2) Warning: Unsupported switch "$N"
C:\appbuilder\imaginglib0220\Imaging\Source\JpegLi b\imjerror.pas(116,49) Warning: Procedure type "FAR" ignored
C:\appbuilder\imaginglib0220\Imaging\Source\JpegLi b\imjerror.pas(295,53) Warning: Procedure type "FAR" ignored
C:\appbuilder\imaginglib0220\Imaging\Source\JpegLi b\imjerror.pas(300,44) Warning: Local variable "buffer" does not seem to be initialized
C:\appbuilder\imaginglib0220\Imaging\Source\JpegLi b\imjerror.pas(300,44) Error: Argument can't be assigned to
C:\appbuilder\imaginglib0220\Imaging\Source\JpegLi b\imjerror.pas(319,68) Warning: Procedure type "FAR" ignored
C:\appbuilder\imaginglib0220\Imaging\Source\JpegLi b\imjerror.pas(351,74) Warning: Procedure type "FAR" ignored
C:\appbuilder\imaginglib0220\Imaging\Source\JpegLi b\imjerror.pas(418,54) Warning: Procedure type "FAR" ignored
C:\appbuilder\imaginglib0220\Imaging\Source\JpegLi b\imjerror.pas(438,21) Error: Wrong number of parameters specified
C:\appbuilder\imaginglib0220\Imaging\Source\JpegLi b\imjerror.pas(116,11) Hint: Found declaration: error_exit(j_common_ptr)
C:\appbuilder\imaginglib0220\Imaging\Source\JpegLi b\imjerror.pas(439,23) Error: Wrong number of parameters specified
C:\appbuilder\imaginglib0220\Imaging\Source\JpegLi b\imjerror.pas(319,11) Hint: Found declaration: emit_message(j_common_ptr, LongInt)
C:\appbuilder\imaginglib0220\Imaging\Source\JpegLi b\imjerror.pas(440,25) Error: Wrong number of parameters specified
C:\appbuilder\imaginglib0220\Imaging\Source\JpegLi b\imjerror.pas(295,11) Hint: Found declaration: output_message(j_common_ptr)
C:\appbuilder\imaginglib0220\Imaging\Source\JpegLi b\imjerror.pas(441,25) Error: Wrong number of parameters specified
C:\appbuilder\imaginglib0220\Imaging\Source\JpegLi b\imjerror.pas(351,11) Hint: Found declaration: format_message(j_common_ptr,var ShortString)
C:\appbuilder\imaginglib0220\Imaging\Source\JpegLi b\imjerror.pas(442,26) Error: Wrong number of parameters specified
C:\appbuilder\imaginglib0220\Imaging\Source\JpegLi b\imjerror.pas(418,11) Hint: Found declaration: reset_error_mgr(j_common_ptr)
C:\appbuilder\imaginglib0220\Imaging\Source\JpegLi b\imjerror.pas(461) Fatal: There were 6 errors compiling module, stopping
any ideas what i'm doing wrong?
edit: seems like {$mode delphi} helps ;)
Galfar
25-02-2007, 05:41 PM
That is strange. All JpegLib files in Imaging include imjconfig.inc where MODE DELPHI is defined for FPC. Where did you add that {$mode delphi} that helped?
You can also change this in ImagingJpeg unit:
{$DEFINE IMJPEGLIB}
{ $DEFINE PASJPEG}
to
{ $DEFINE IMJPEGLIB}
{$DEFINE PASJPEG}
which will tell Imaging to use FPC's own pasjpeg. This seems to work without setting MODE somewhere.
JernejL
25-02-2007, 05:45 PM
I added it before uses line, it is that i tried to use vampyre with delphi 4, and edited the compiler definitions include a bit trying to get it to work with D4, but later i undoed it all (or i thought i did), so maybe it was this problem.
Galfar
25-02-2007, 05:56 PM
I have found where the problem is:
{$I imjconfig.inc} is right after uses now in JpegLib, but MODE must be before uses to work. I had delphi mode hard-coded in fpc.cfg so I didn't notice anything (and it somehow worked in Linux and BSD). I'll update the files and commit them to SVN repository.
Did you have any success getting Imaging work in D4?
Chebmaster
04-03-2007, 08:29 AM
Looks very appetizing. :D I'll try to use it in my engine.
JernejL
04-03-2007, 11:49 AM
I have found where the problem is:
{$I imjconfig.inc} is right after uses now in JpegLib, but MODE must be before uses to work. I had delphi mode hard-coded in fpc.cfg so I didn't notice anything (and it somehow worked in Linux and BSD). I'll update the files and commit them to SVN repository.
Did you have any success getting Imaging work in D4?
No, i haven't tried since, but i got it to work with delphi 7 winxp and ported it flawlessly (100% same code works) to lazarus running in kubuntu linux :D
This library is worth gold, it's great for all sort of graphical utils and i think i'll use it in any further graphical apps i will be making (and i make quite some graphical manipulation tools for games), i can certainly already see how much pain it would save me if i had it 2-3 years ago.. (delphi & scanline & pixelformat mess)..
Galfar
05-03-2007, 09:48 PM
No, i haven't tried since, but i got it to work with delphi 7 winxp and ported it flawlessly (100% same code works) to lazarus running in kubuntu linux
Good to hear it works ok, I mainly develop in Win32 and do Linux testing in Mandrake and Fedora x64 before major releases.
i can certainly already see how much pain it would save me if i had it 2-3 years ago.. (delphi & scanline & pixelformat mess)..
Well, that "mess" is basically why I started Imaging few years ago, originally for loading textures
without dependencies on VCL or some DLLs.
i think i'll use it in any further graphical apps i will be making (and i make quite some graphical manipulation tools for games)
Any new features you would like to see in the library?
JernejL
06-03-2007, 10:04 AM
i think i'll use it in any further graphical apps i will be making (and i make quite some graphical manipulation tools for games)
Any new features you would like to see in the library?
Not really, it's quite fast and it got all the important features i need, just the error message callbacks i mentioned in PMs.
jdarling
06-03-2007, 02:01 PM
I'd love to see PSD (PhotoShop) support built in. You might be able to get some ideas from: http://www.delphi-gems.com/GraphicEx.php
Course then again, GraphEx has a lot of nice loaders, just not that many savers to accompany them.
Chebmaster
06-03-2007, 08:45 PM
I'd love to see PSD (PhotoShop) support built in.
Or The GIMP's XCF :roll:
Galfar
07-03-2007, 03:01 PM
I'll be adding full support for GIF and maybe TIFF for next release.
Jeremy:
I will look at PSD loading support but most probably just extracting raster data from images (like GraphicEx does I assume), no fancy Photoshop stuff that could be there. Simple saving can be added too I think.
Chebmaster:
I don't know anything about GIMP's XCF, do you have some info about this format?
Chebmaster
08-03-2007, 10:07 AM
don't know anything about GIMP's XCF, do you have some info about this format?
maybe
http://henning.makholm.net/xcftools/xcfspec.txt
?
To be honest, you, probably, can omit it for a while, since The GIMP can work with PSD as well.
Galfar
08-03-2007, 11:15 AM
maybe http://henning.makholm.net/xcftools/xcfspec.txt ?
To be honest, you, probably, can omit it for a while, since The GIMP can work with PSD as well.
Thanks for the link.
JernejL
10-03-2007, 10:00 PM
Trying to compile a vampyre powered project on freebsd gives this error:
http://www.gtatools.com/temp/imaging_bsd.jpg
edit: that's with my $mode delphi hacks i mentioned earlier, without thise it fails earlier, i tried with the latest version of your library from the website too, and those jmerror.pas errors came up just as in linux.
Galfar
11-03-2007, 12:01 AM
Please try code from SVN repository at http://sourceforge.net/svn/?group_id=125626
That should now work ok in BSD.
Chebmaster
11-03-2007, 05:01 PM
I was finishing integrating Vampyre into my game engine when Lazarus (0.9.20) crashed :shock: -- the first time during the years I use it! Luckily, I saved my work not too long ago, so the loss was negligible.
Further investigation showed that PImageData is a deadly poison for the identifier autocompletion mechanism... :shock: I switched it off, so I'm safe again (albeit uncomortable) :( Did I set something up wrong?
But why the hell does Lazarus die with "Floating point overflow" ? :?: In short, I think, we need a good shaman to resolve this mystery. And I'll try to update my Lazarus too.
Galfar
11-03-2007, 06:32 PM
That is really strange. My Lazarus' (in Win32) autocompletion just don't work for PImageData, fortunately without crashing (I have 0.9.20 too). Does your Lazarus crash on other pointer to record types or is it just PImageData (in that case that shaman or witchdoctor would be really helpful)?
Chebmaster
11-03-2007, 08:33 PM
Does your Lazarus crash on other pointer to record types or is it just PImageData
I didn't test it excessively, so I cannot really say. Before trying Vampyre I worked with pointers a lot and I never had any problems.
P.S. You know, it seems a big block of commented-out code full of compiler directives right above the offending line was responsible.
Now I removed it and Lazarus stopped crashing. Still, the autocompletion doesn't work, neither for TImageData nor for PImageData.
Well, Lazarus is *still* a beta. :roll:
Chebmaster
12-03-2007, 02:54 PM
I finished integrating, it works finely! :D
No more headache with loading the LibPng binaries! :D
Thank you :)
One side note: Despite the {$minenumsize 4} defined in ImagingOptions.inc, TImageFormat is *still* one byte in size! I had a nasty run-in with AVs when I redefined TImageData in my code, with Format having a type of "dword" (now corrected to "byte").
This perversion is because my game modules know nothing about their environment (including Vampyre), accessing it via wrapper functions provided by the engine core.
Galfar
12-03-2007, 03:34 PM
One side note: Despite the {$minenumsize 4} defined in ImagingOptions.inc, TImageFormat is *still* one byte in size! I had a nasty run-in with AVs when I redefined TImageData in my code, with Format having a type of "dword" (now corrected to "byte").
Thanks for bringing this up. This is most probably cause of crashes of Vampyre compiled to DLL and called from C. I've just tried moving {$minenumsize} to other places and it seems that it gets reset later by setting {$mode}. I've corrected this and updated the code in SVN repository - you can change it back to "dword" if you use this new code.
Chebmaster
12-03-2007, 05:43 PM
Uh... Thanks :lol: [shuffles away: Svn. :shock: Scary. :cry:] I, uh, solved it for now by editing ImagingTypes.pas and adding to my program:
procedure StartVampyre;
begin
if sizeof(tvyimage) <> sizeof (timagedata)
then Die('Record size mismatch, check compiler options/conditionals.'#13#10
+ 'SizeOf(TVyImage) = %0; SizeOf(TImageData) = %1.'
, [sizeof(tvyimage), sizeof(timagedata)]);
end;
I'll... check it with the next version you release, ok? :oops:
Galfar
12-03-2007, 06:08 PM
Uh... Thanks :lol: [shuffles away: Svn. :shock: Scary. :cry:] I, uh, solved it for now by editing ImagingTypes.pas and adding to my program:
...
I'll... check it with the next version you release, ok? :oops:
Or you could just download this one updated file that fixes this:
http://imaginglib.svn.sourceforge.net/svnroot/imaginglib/trunk/Source/ImagingOptions.inc
Not sure when I will be able to make a new release.
Chebmaster
12-03-2007, 07:11 PM
Thanks :)
Galfar
14-03-2007, 02:28 AM
I'd love to see PSD (PhotoShop) support built in.
I've just finished support for loading and saving of PSD images, it is in SVN repository now. It can handle most types of PSD images (indexed, grayscale, RGB(A) 24-64bit, CMYK, FP32 HDR).
Chebmaster
18-03-2007, 09:37 AM
A great news, indeed :) When it's out of the scary SVN, I'll try it.
Did you implement support for the user program to know the layer names and blending modes? The power of PSD is in the fact that your game can directly use the images you are working on, without a need for "exporting". So you can use layers to implement some serious stuff that is very hard to achieve otherwise (lets just remember the skin area marking in Neverwinter Nights 1 - without the layers it was *such a pain*, the skin/leather/metall were marked via colourization, it was easier to commit suicide right away than edit such a skin :x)
Chebmaster
19-03-2007, 06:44 PM
Oh! I did just remember! A long time ago, in the 20th century, my favorite graphical editor was DeLuxe Paint II Enhanced (yup, that infamous hardcore MS-DOS thingy). The game I made then (a 3d first-person shooter) ran under MS-DOS, compiled in Turbo Pascal, but the database compiler for it, on the other hand, was a 32-bit application written in some ancient version of Delphi (either 2 or 3 - I can't remember exactly).
So, the point of my rant: I want to share a piece of code with you. The one that loads DPIIE's format, .LBM. The procedure needs a bit [cough, cough] of cleaning, but... I guraantee that it *worked*, because I used the .LBM format a lot. The thing is, DPIIE has an internal error and while it in itself could load and save its own files just finely, the modern viewers (for example, IrfanView) just crash on them.
The procedure is pretty dumb and supports only the 256-color images (no 1- 2- or 4- bit versions, sorry -- I just had no need for them back them). Also it is probably a good idea to redefine the record as "packed".
UNIT M_LBM_F;
INTERFACE
USES Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, Gauges, StdCtrls,
e_String, M_Spr;
Procedure ReadLbm(name: string);
Var LbmX,LbmY: Word;
IMPLEMENTATION
Uses M_LIB;
Type pType=Array[0..255] of record R,G,B: Byte end;
VAR
P0: PType;
PAL:array[0..768] of byte;
MPa:array[0..767] of byte absolute P0;
GRAD: array[0..15,0..1] of byte;
LNAME: STRING;
Function min(a,b: longint):longint;
begin
if a<b then min:=a else min:=b
end;
Function SwW(w: word):word;
var a:array[0..1] of byte absolute w;
b:byte;
begin
b:=a[0]; a[0]:=a[1]; a[1]:=b;
SwW:=w;
end;
Function SwL(l: longint):longint;
var a:array[0..3] of byte absolute l;
b:byte;
begin
b:=a[0]; a[0]:=a[3]; a[3]:=b;
b:=a[1]; a[1]:=a[2]; a[2]:=b;
SwL:=l;
end;
Procedure LBMError(ru:string);
begin
ErrOut('Invalid '+LName+' (possible, not in DeLuxe Paint II format)'#10#13+ru);
end;
Type
BMHDType = Record
Xsize,
YSize,
X0,
Y0 : Word;
BitPlanes,
Reserved,
Encoding : Byte;
Reserved2: array[1..3] of byte;
Xaspect,Yaspect: Byte;
Xmax,
Ymax : Word;
End;
type pa = array[0..0] of byte;
Procedure ReadLbm(name:String);
label TinyShit;
var f: file;
s:string;
ba: array[0..3] of byte;
l: longint absolute ba;
ind, bi: longint;
X, Y, i, n ,BSize :integer;
BMHD: BmhdType;
B: array[0..20048] of byte;
c, a: byte;
p: ^pa;
o: integer;
function ReadB: string;
var _s:string;
_b:byte;
begin
_s:=#0#0#0#0;
BlockRead(f,_s[1],4);
i:=IoResult;
if i<>0 then RunError(i);
ReadB:=_s;
BlockRead(f,l,4);
i:=IoResult;
if i<>0 then RunError(i);
_b:=ba[0]; ba[0]:=ba[3]; ba[3]:=_b;
_b:=ba[1]; ba[1]:=ba[2]; ba[2]:=_b;
ind:=ind+l+8;
end;
begin
i:=0;
assign(f,name);
LName:=Name;
{$I- }
reset(f,1);
i:=IoResult;
if i<>0 then RunError(i);
if (FileSize(f)<1000) then RunError(254);
s:=ReadB; IF s<>'FORM' then LbmError(s);
Seek(f,8); s:=ReadB; if s<>'PBM'#$20 then
LbmError('File must be 256-color PBM-FORM, not the ILBM-FORM.');
ind:=12;
Seek(f,ind); i:=IoResult; if i<>0 then RunError(i);
s:=ReadB;
if s<>'BMHD' then
LbmError('Expected header BMHD, not the '+s);
BlockRead(f,BMHD,SizeOf(BmHd)); i:=IoResult; if i<>0 then RunError(i);
With BMHD do begin
if (BitPlanes<>8) or (Encoding<>1) then
LbmError('Uncnown compression type '+IntToStr(BitPlanes)+':'+IntToStr(Encoding));
Xsize:=sww(xsize); YSize:=sww(Ysize);
X0:=sww(X0); Y0 :=sww(Y0);
Xmax:=sww(Xmax); Ymax :=sww(ymax);
ResizeImage(XSize, YSize);
end;
Seek(f,ind); i:=IoResult; if i<>0 then RunError(i);
s:=ReadB;
if s<>'CMAP' then
LbmError('After header expected palette CMAP, not the '+s);
BlockRead(f,PAL,3*256); i:=IoResult; if i<>0 then RunError(i);
for i := $00 to $FF*3 do PAL[i]:=PAL[i] shr 2;
{palette(pal);}
n:=0;
While n<=15 do begin
Seek(f,ind); i:=IoResult; if i<>0 then RunError(i);
s:=ReadB;
if (s<>'CRNG') and (s<>'DPPS') then
LbmError('After palette expected 16 gradient descriptions CRNG, not the '+s);
BlockRead(f,B,6); i:=IoResult; if i<>0 then RunError(i);
BlockRead(f,GRAD[n],2); i:=IoResult; if i<>0 then RunError(i);
if s='DPPS' then Dec(n);
Inc(n);
end;
Seek(f,ind); i:=IoResult; if i<>0 then RunError(i);
bi:=ind+8;
s:=ReadB;
if (s<>'TINY') and (s<>'BODY') then
LbmError('After gradients expected TINY, or file BODY,~ not the '+s);
If s='TINY' then begin
TinyShit:
Seek(f,ind); i:=IoResult; if i<>0 then RunError(i);
bi:=ind;
s:=ReadB;
if copy(s,2,3)='BOD' then begin
ind:=bi+1;
Goto TinyShit;
end;
bi:=bi+8;
if s<>'BODY' then
LbmError('Expected BODY,~ not the '+s);
end;
X:=0; Y:=0;
BSize:=l;
GetMem(p, BSize);
Seek(f, bi);
BlockRead(f, p^, BSize);
If IOResult<0>=BMHD.Xsize then begin
SendLineToImage(y, B[0]);
Inc(y);
x:=0;
end;
Until (Y=BMHD.YSize) {or (y=Ysize)};
FreeMem(p, BSize);
end;
END.
I put the sample LBM images here: http://host-17-99.imsys.net/_share/_001/lbm/
As you can notice, IrfanView chokes with "IFF decoding error" on most of them.
JernejL
19-03-2007, 08:01 PM
Galfar, i'm having troubles with imaging and 32 bit BMP image saving, the pictures apparently contain raw picture and a header, but they won't open with any program i tried (irfanview, delphi Tpicture, paint shop pro... )
Galfar
19-03-2007, 09:37 PM
Galfar, i'm having troubles with imaging and 32 bit BMP image saving, the pictures apparently contain raw picture and a header, but they won't open with any program i tried (irfanview, delphi Tpicture, paint shop pro... )
Could you please send me one of those problematic BMPs?
I have tried one and it worked well in Irfan and Photoshop, it loaded ok but had swapped red and blue in Paint Shop Pro.
I think I know what causes it - I'm saving images with alpha to BMP V4 (introduced in Windows 95) where I can explicitly define that BMP contains n bit alpha channel.
But it looks like some programs can only handle V3 bitmaps.
Galfar
19-03-2007, 10:02 PM
A great news, indeed :) When it's out of the scary SVN, I'll try it.
Did you implement support for the user program to know the layer names and blending modes? The power of PSD is in the fact that your game can directly use the images you are working on, without a need for "exporting". So you can use layers to implement some serious stuff that is very hard to achieve otherwise (lets just remember the skin area marking in Neverwinter Nights 1 - without the layers it was *such a pain*, the skin/leather/metall were marked via colourization, it was easier to commit suicide right away than edit such a skin :x)
No layer support yet, that could get quite complicated. Only raw raster data is read from (and saved to) PSDs now.
IFF/LBM:
I managed to find some old format specs:
http://www.fileformat.info/format/iff/spec/7866a9f0e53c42309af667c5da3bd426/view.htm. Quite long. Thanks for the code, thats definitely shorter.
I put the sample LBM images here: http://host-17-99.imsys.net/_share/_001/lbm/
As you can notice, IrfanView chokes with "IFF decoding error" on most of them.
Indeed, they are Irfan and Photoshop hostile, but Paint Shop Pro opened them ok.
Chebmaster
19-03-2007, 11:19 PM
Thanks for the code, thats definitely shorter.
But may not be able to open anything that is *not* created by DPIIE :lol:
No layer support yet, that could get quite complicated.
So, the only 32-bit color multi-layer format for now is .MNG... TheGIMP saves it Ok, but then can't load it back, saying "unknown format" :shock:
Anyway, here's a .MNG (supposedly, 1-bit, but, as I said above, GIMP can't read them back) that reports an AV in LoadMultiImageFromFile(). The EImagingError is raised properly, the error message is composed properly.
http://host-17-99.imsys.net/_share/_001/_002/logo_oops.mng
Galfar
20-03-2007, 02:36 AM
So, the only 32-bit color multi-layer format for now is .MNG... TheGIMP saves it Ok, but then can't load it back, saying "unknown format" :shock:
Anyway, here's a .MNG (supposedly, 1-bit, but, as I said above, GIMP can't read them back) that reports an AV in LoadMultiImageFromFile(). The EImagingError is raised properly, the error message is composed properly.
http://host-17-99.imsys.net/_share/_001/_002/logo_oops.mng
Fixed! But as you may suspect it is in the SVN repository. You can get the file with needed changes here: http://imaginglib.svn.sourceforge.net/svnroot/imaginglib/trunk/Source/ImagingNetworkGraphics.pas.
Or you get some SVN client and just call this from command line:
svn co https://imaginglib.svn.sourceforge.net/svnroot/imaginglib imaginglib
to get whole updated Imaging.
Chebmaster
20-03-2007, 01:02 PM
But as you may suspect it is in the SVN repository. You can get the file with needed changes here:
Thanks! :D [tries to download the file, Firefox just won't display the "save" dialog] Stupid flea-bag! Behave, or I'll update ya to v 2.x! [opens the file in the browser window, tries to save it... The dialog just won't display...] :evil: Oo-key, you asked for it! [copy-pastes it as text to Lazarus and just saves it there] HA! Gotcha! :twisted:
JernejL
20-03-2007, 08:02 PM
here it is:
http://www.gtatools.com/temp/t.rar
There is no program that would load this bmp except a raw image loader.
the image is created using command: NewImage(512, 512, ifA8R8G8B8, img);, then i copy a bunch of other images into it.
Galfar
21-03-2007, 01:56 PM
here it is:
http://www.gtatools.com/temp/t.rar
There is no program that would load this bmp except a raw image loader.
the image is created using command: NewImage(512, 512, ifA8R8G8B8, img);, then i copy a bunch of other images into it.
I've managed to open that image in Irfan 3.99, Paint Shop Pro 9, Photoshop CS2, and all MS programs without problems. It failed to open in Opera and Delphi's and Lazarus' TBitmap.
So I have temporarily forced bitmap saver to create V3 bitmaps and it should be ok everywhere. I'll later add some option to enable V4 bitmaps for images with alpha because it could be useful for someone (for example Photoshop ignores alpha channel if bitmap is V3 but loads it properly if it is V4).
Updated code is in SVN repository.
JernejL
21-03-2007, 05:16 PM
i tried this:
http://imaginglib.svn.sourceforge.net/viewvc/*checkout*/imaginglib/trunk/Source/ImagingBitmap.pas?revision=79
but it still fails to load in delphi Tbitmap.
edit: i tried cloning and converting image to ifR8G8B8, but it refuses to load anywhere else as well. :(
Galfar
26-03-2007, 09:11 PM
i tried this:
http://imaginglib.svn.sourceforge.net/viewvc/*checkout*/imaginglib/trunk/Source/ImagingBitmap.pas?revision=79
but it still fails to load in delphi Tbitmap.
edit: i tried cloning and converting image to ifR8G8B8, but it refuses to load anywhere else as well. :(
I really don't know what is wrong. I could open that image saved in ifR8G8B8 and in ifA8R8G8B8 (after the V4 change) in everything that can open images (except Lazarus' TBitmap which cannot read top-down bitmaps). Which Delphi version TBitmap did you try?
Anyway, I changed some things in the bitmap saver, maybe it can help you:
http://imaginglib.svn.sourceforge.net/svnroot/imaginglib/trunk/Source/ImagingBitmap.pas
JernejL
27-03-2007, 08:26 AM
after the fix it loads in Tbitmap, but doesn't load in programs like paint shop pro 7.
Chebmaster
27-03-2007, 10:17 AM
I think, the answer is simple: despite what the specification says, there is *NO* such thing as BMP with alpha-channel, because nobody uses it. So the software vendors don't bother to support it properly.
JernejL
27-03-2007, 04:12 PM
What do you mean? there is absolutely no mention of alpha channels in BMP structure...
Galfar
30-03-2007, 01:57 PM
What do you mean? there is absolutely no mention of alpha channels in BMP structure...
There are actually five versions of BMP for Windows and two or more for OS2. Alpha channel is supported since V4 (introduced with Windows 95) but it is still not very common. Many programs only support V3 (Windows 3.0) as well as most information you can find on the Internet refers to V3 bitmaps.
after the fix it loads in Tbitmap, but doesn't load in programs like paint shop pro 7.I tried PSP 7 demo and it worked fine, I also compared 32bit BMP saved by Delphi's TBitmap with Imaging's bitmap and apart from top-down/bottom-up difference they were the same. I really don't know what is wrong here. Maybe that they are top-down can the cause of your problems - please try to remove - sign from BI.Height := -Height; on line 671 in ImagingBitmaps.pas and see if it helps (image will be flipped though).
Chebmaster
16-04-2007, 02:55 PM
Now I am building my text/font manager, all based on your library - it's of great help. :D
I think, your creation would benefit from supporting the lanczos filter (http://en.wikipedia.org/wiki/Lanczos_resampling) for resizing. It's one of the slowest I know (see IrfanView - it's a viewer that supports this filtering mode) but it's awesome in how it manages to keep the picture visually sharp even if your new size is just one pixel bigger. Bicubic blurs mercilessly in such cases. :wink:
Galfar
16-04-2007, 09:11 PM
I think, your creation would benefit from supporting the lanczos filter for resizing.
Imaging already supports Lanczos and other filters. It is only that ResizeImage function uses
only nearest, bilinear, and bicubic filtering to make low level interface functions in Imaging.pas unit simpler.
If you want to try other filters look at StretchResample functions in ImagingFormats.pas unit. You can even design your own filter and pass it to overloaded StretchResample.
type
TSamplingFilter = (sfNearest, sfLinear, sfCosine, sfHermite, sfQuadratic,
sfGaussian, sfSpline, sfLanczos, sfMitchell, sfCatmullRom);
procedure StretchResample(const SrcImage: TImageData; SrcX, SrcY, SrcWidth,
SrcHeight: LongInt; var DstImage: TImageData; DstX, DstY, DstWidth,
DstHeight: LongInt; Filter: TSamplingFilter; WrapEdges: Boolean = False); overload;
procedure StretchResample(const SrcImage: TImageData; SrcX, SrcY, SrcWidth,
SrcHeight: LongInt; var DstImage: TImageData; DstX, DstY, DstWidth,
DstHeight: LongInt; Filter: TFilterFunction; Radius: Single;
WrapEdges: Boolean = False); overload;
Chebmaster
17-04-2007, 06:17 AM
Wow. :D
Thanks. Sorry I did not look deeper. :oops:
Galfar
21-06-2007, 09:26 PM
Imaging v0.24 will be released in one or two weeks.
It will feature new GIF and PSD image support (and beta TIFF support)
and many bug fixes.
Chebmaster
23-06-2007, 09:19 AM
Splendid :D
When I finish tearing through the bug hordes in my engine I'll give it a try :oops:
It's nice to have lanczos resample option when loading non-power-of-2 images into textures. :)
Chebmaster
25-06-2007, 10:52 PM
P.P.S. I turned the compiler optimization settings to maximum and suddenly the lanczos resizing accelerated immensely, as if getting a good punt. I test it on two large pictures being resized to 1024x2048, and they, kind of, load in a blink of an eye now.
It was FPC 2.0.4 with -Op4 -Ou -O3 -Or (target Pentium 4, uncertaing optimizations on, maximum optimization, keep certain variables in registers). My CPU is Sempron (a renamed older version of Athlon XP).
One more reason to build Vampyre Imaging directly from sources :)
Galfar
26-06-2007, 04:04 AM
P.P.S. I turned the compiler optimization settings to maximum and suddenly the lanczos resizing accelerated immensely, as if getting a good punt. I test it on two large pictures being resized to 1024x2048, and they, kind of, load in a b]
Looks like FPS's optimizations are getting better and better (in my results from Bench Imaging demo it is faster than Delphi in numerous tests - that was not the case a while ago).
[quote="Chebmaster"]One more reason to build Vampyre Imaging directly from sources :)
Yeah true. If only there was some JPEG2000 library in native Pascal so Imaging wouldn't need those ugly C object files and have everything in Pascal.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.