<peteraddington@...> wrote:
>
> Has anyone managed to open a HDR with freeimage yet?
>
> Also, has anyone got any tips on the fastest methods of returning
> thumbnails using AIL?
This is the code you'd use to load an HDR image and resize it to 200
x 200 pixels (thumbnail size)... then convert it to an StdPicture
object to display on a form or PictureBox control in VB6:
------------------------
Dim objAIL As New cAdvancedImagery
Dim hIMG As Long
Dim objPic As StdPicture
Me.AutoRedraw = True
If objAIL.IO_LoadImage("C:\TEST.HDR", hIMG) = True Then
If objAIL.Effect_Resize(hIMG, 200, 200, rc_Clean) = True Then
If objAIL.Convert_ImageToPicture(hIMG, objPic) = True Then
Set Me.Picture = objPic
Me.Refresh
MsgBox "Success!"
Else
MsgBox "Error converting: " & objAIL.Error_GetLast
End If
Else
MsgBox "Error resizing: " & objAIL.Error_GetLast
End If
objAIL.IO_DestroyImage hIMG
Else
MsgBox "Error loading: " & objAIL.Error_GetLast
End If
Set objAIL = Nothing
------------------------
Problem is that the convert function throws an error. In fact, when
the resize function tries to convert the image to 32-bit to
manipulate, the image does not get converted to 32-bit. It starts
out at 96-bits (according to FreeImage_GetBPP function) and stays
that way even after calling FreeImage_ConvertTo32Bits function.
There's obviously something fishy going on with loading / manipulating HDR
images. I've posted about it on the official FreeImage forums and will let you
know what the result is:
https://sourceforge.net/forum/forum.php?thread_id=2335019&forum_id=36111
- Kevin
the images i downloaded were from http://www.debevec.org/probes/ and
they don't open in the pictureit utility either. i have tried a hdr
from another source with similar results.
hi, i am using the resize function to make thumbnails of various
filetypes, and this works for all types except high dynamic range .HDR
files. Is it something to do with the format that means i cant do this?
my function is returning a vb.net image. it loads the hdr but fails at
the convert_imagetoBitmap part.
If objAIL.Effect_Resize(hIMG, ThumbW, ThumbH,
cAdvancedImagery.ResizeConstants.rc_Fast) = True Then
If objAIL.Convert_ImageToBitmap(hIMG, hbitmap) = True Then
AILbmp = Image.FromHbitmap(hbitmap)
Call objAIL.IO_DestroyImage(hIMG)
Call objAIL.IO_DestroyBitmap(hbitmap)
Return AILbmp
Else
MsgBox("Error - " & objAIL.Error_GetLast)
End If
Else
MsgBox("Error - " & objAIL.Error_GetLast)
End If
Call objAIL.IO_DestroyImage(hIMG)
I got it to work no problem. Here's what I did:
1) Downloaded and installed the latest version of REALbasic
(v2008r3.1)
2) Started a new Windows Program
3) Went to the "Sub Open()" method of the default form
4) Pasted in the following code (which was cut & pasted from the help
file):
-------------------
Dim objAIL As cAdvancedImagery
Dim hIMG As Integer
objAIL = New cAdvancedImagery
If objAIL.IO_LoadImage("C:\TEST.BMP", hIMG) = True Then
If objAIL.Metadata_Set_IPTC(hIMG, "ObjectName", "My Image Title") =
True Then
If objAIL.IO_SaveImage(hIMG, "C:\OUTPUT.JPG", objAIL.IF_JPEG, 90,
True) = True Then
MsgBox "Successfully saved IPTC information to image"
Else
MsgBox "Error - " + objAIL.Error_GetLast
End If
Else
MsgBox "Error - " + objAIL.Error_GetLast
End If
Call objAIL.IO_DestroyImage(hIMG)
Else
MsgBox "Error - " + objAIL.Error_GetLast
End If
objAIL = Nil
-------------------
5) Went and opened the "C:\OUTPUT.JPG" file that was created by the
code using "PictureIt" (the sample picture application that is
included with the Advanced Imagery Library... which you can also
download from the web site www.advimglib.com)
6) Went to FILE >> PROPERTIES and went to the METADATA tab... then
clicked IPTC. The IPTC data was as follows:
DirectoryVersion = 2
ObjectName = My Image Title
- Kevin
Hey folks, just started using the metadata_set_iptc method and the
iptc data isn't being written to the .jpg image, even though
everything seems to work. I'm using the basic sample code and the
image loads successfully, the data seemingly is written to the image
file, it saves it out as a new file and then generates a "Successfully
saved IPTC information to image" dialog. However, when the image is
opened in Photoshop or another image editor, the IPTC fields are
blank. I'm doing REALbasic development and using Windows 2000 server
to run the solution. Any thoughts or suggestions? Thks
They are used in programs like 3dsmax in the 3d industry for
compositing as you can add extra channels for data like velocity,
zdepth and material ids. cheers anyway.
My understanding is RPF files are "AutoCAD Raster-pattern Fill
Definition" files... and that's beyond the scope of both FreeImage and
the Advanced Imagery Library.
Sorry. =(
- Kevin
--- In AIL_Development@yahoogroups.com, "bluescreenweasel"
<peteraddington@...> wrote:
>
> Hi Kevin,
>
> Is there any way provide RPF file access in AIL?
>
Dim objAIL As cAdvancedImagery
Dim hIMG As Long
Dim objIMG As StdPicture
' Show the form
Me.Visible = True
DoEvents
' Initialize the AIL library
Set objAIL = New cAdvancedImagery
' Load the image from file
If objAIL.IO_LoadImage("C:\TEST.BMP", hIMG) = True Then
' Convert the image to a format that the ImageList understands
If objAIL.Convert_ImageToPicture(hIMG, objIMG) = True Then
' Add the converted image to the ImageList control
ImageList1.ListImages.Add 1, "key", objIMG
' Display the picture from the ImageList control
Set Picture1.Picture = ImageList1.ListImages(1).Picture
Else
MsgBox "Error Converting Image: " & objAIL.Error_GetLast
End If
' Clean up the loaded file
objAIL.IO_DestroyImage hIMG
Else
MsgBox "Error Loading Image: " & objAIL.Error_GetLast
End If
' Deinitialize the AIL library
Set objAIL = Nothing
--- In AIL_Development@yahoogroups.com, "Kevin Wilson"
<kevinwilson1997@...> wrote:
>
> In what language? VB5 / VB6, or VB.NET 2003, or VB.NET 2005?
>
> - Kevin
Wow... I guess it would be hard to help without any information! I'm
using VB6. Sorry!
In what language? VB5 / VB6, or VB.NET 2003, or VB.NET 2005?
- Kevin
--- In AIL_Development@yahoogroups.com, "aksclm" <aksclm@...> wrote:
>
> What is one example of adding an image to an image list with AIL?
>
In VB5 and VB6, there's no way to load a transparent pictures into an
Image control because the Image control does not have a Device
Context handle (hDC) property that can be used to render to. So the
only way to load an image into it is to set the Picture property
equal to an StdPicture object... which is 24-bit and does not support
32-bit transparency. 8-bit transparency is supported for .GIF file
format only... but that doesn't help us with 32-bit transparent PNG
files.
The alternatives here are to use a PictureBox control which has an
hDC property to render transparently to (but PictureBox controls are
not transparent like Image controls).... or to render the picture
directly onto your form like this:
Dim objAIL As cAdvancedImagery
Dim objIMG As StdPicture
Dim hIMG As Long
Me.Visible = True
DoEvents
Set objAIL = New cAdvancedImagery
If objAIL.IO_LoadImage("C:\TEST.PNG", hIMG) = True Then
If objAIL.Render_Transparent(hIMG, Me.hDC) = True Then
Me.Refresh
MsgBox "Success!"
Else
MsgBox "Error rendering image: " & objAIL.Error_GetLast
End If
objAIL.IO_DestroyImage hIMG
Else
MsgBox "Error loading Image: " & objAIL.Error_GetLast
End If
Set objAIL = Nothing
In .NET, the PictureBox control is transparent (unlike VB5 and VB6).
So you can render to it by getting the DC from it's handle. However,
the problem with .NET PictureBox controls is there's no AutoRedraw
property... so you have to put some code in the PictureBox's Paint
event to redraw your image every time the PictureBox refreshes /
paints.
Here's the .NET code to render transparent .PNG image to a PictureBox
control:
Private Declare Function GetDC Lib "USER32.DLL" (ByVal hWnd As
Int32) As Int32
Private Declare Function ReleaseDC Lib "USER32.DLL" (ByVal hWnd As
Int32, ByVal hDC As Int32) As Int32
Dim objAIL As cAdvancedImagery
Dim hIMG As Int32
Dim hDC As Int32
Me.Visible = True
Me.Left = 0
Me.Top = 0
Application.DoEvents()
hDC = GetDC(PictureBox1.Handle.ToInt32)
objAIL = New cAdvancedImagery
If objAIL.IO_LoadImage("C:\TEST.PNG", hIMG) = True Then
If objAIL.Render_Transparent(hIMG, hDC) = True Then
MsgBox("Success!")
Else
MsgBox("Error rendering image: " & objAIL.Error_GetLast)
End If
objAIL.IO_DestroyImage(hIMG)
Else
MsgBox("Error loading Image: " & objAIL.Error_GetLast)
End If
objAIL = Nothing
Call ReleaseDC(PictureBox1.Handle.ToInt32, hDC)
--- In AIL_Development@yahoogroups.com, "Kevin Wilson"
<kevinwilson1997@...> wrote:
>
> Daniel asked:
>
> "how do you load the 32-bit transparent PNG image.
> it shows as normal when loaded in a image box"
>
Thanks, Kevin! Sorry for the delayed response.
Here is the image:
http://ccarboni.home.att.net/Moon_High_Res_Half.jpg
However, it doesn't seem to give the error every time, which
complicates things.
Would appreciate your thoughts!
Al
--- In AIL_Development@yahoogroups.com, "Kevin Wilson"
<kevinwilson1997@...> wrote:
>
> Can you please post the image that's giving you problems on the
> internet somewhere and I'll test it and let you know.
>
> Thanks!
>
> - Kevin
>
>
>
> --- In AIL_Development@yahoogroups.com, "asbaran333" <asbaran333@>
> wrote:
> >
> > This software is awesome!
> >
> > However, I am encountering a problem grabbing large images from the
> > clipboard using Clipboard_Get. It works fine with smaller images,
> but
> > large ones are returning hIMG = 0.
> >
> > What am I doing wrong? How can I get large images from the
> clipboard?
> >
> > Thanks!
> >
>
Can you please post the image that's giving you problems on the
internet somewhere and I'll test it and let you know.
Thanks!
- Kevin
--- In AIL_Development@yahoogroups.com, "asbaran333" <asbaran333@...>
wrote:
>
> This software is awesome!
>
> However, I am encountering a problem grabbing large images from the
> clipboard using Clipboard_Get. It works fine with smaller images,
but
> large ones are returning hIMG = 0.
>
> What am I doing wrong? How can I get large images from the
clipboard?
>
> Thanks!
>
This software is awesome!
However, I am encountering a problem grabbing large images from the
clipboard using Clipboard_Get. It works fine with smaller images, but
large ones are returning hIMG = 0.
What am I doing wrong? How can I get large images from the clipboard?
Thanks!
Thanks!
--- In AIL_Development@yahoogroups.com, "Kevin Wilson"
<kevinwilson1997@...> wrote:
>
> To render a loaded image to a VB5/VB6 PictureBox control, look at the
> HTML help file page for "Convert_ImageToPicture". It includes source
> code on how to use it. Set the PictureBox.Picture property equal to
> the result of the "Convert_ImageToPicture" function.
>
> Or, you can load the image using "IO_LoadImage" and then use
> the "Render_Transparent" function to render that image to a
> PictureBox. If you use this method, remember that the PictureBox.Image
> property contains the image once you render to it. See the HTML help
> file for these functions for more information and sample code.
>
> As far as keeping the images so that you can re-save them later without
> change... just store the resulting "hIMG" from the "IO_LoadImage"
> function... then use that to call the "IO_SaveImage" function. See the
> HTML help file for these functions for more information and sample code.
>
> - Kevin
>
>
>
>
> > Hello!
> >
> > I just obtained this great tool and can't wait to try it out, but I
> > have a very simple beginner's question:
> >
> > Can someone please tell me how to load an image into a picturebox in
> > VB6 usig AIL? For now, I just want to be able to load various image
> > types (one at a time) and then save them as the original file type
> > without any changes.
> >
> > If I load a JPG then save it again, will it be altered in any way? VB6
> > converts everything to bitmaps, but I'm not sure if this happens when
> > you just load into a picturebox. I think it is just when you save.
> >
> > Thanks!
> >
>
To render a loaded image to a VB5/VB6 PictureBox control, look at the
HTML help file page for "Convert_ImageToPicture". It includes source
code on how to use it. Set the PictureBox.Picture property equal to
the result of the "Convert_ImageToPicture" function.
Or, you can load the image using "IO_LoadImage" and then use
the "Render_Transparent" function to render that image to a
PictureBox. If you use this method, remember that the PictureBox.Image
property contains the image once you render to it. See the HTML help
file for these functions for more information and sample code.
As far as keeping the images so that you can re-save them later without
change... just store the resulting "hIMG" from the "IO_LoadImage"
function... then use that to call the "IO_SaveImage" function. See the
HTML help file for these functions for more information and sample code.
- Kevin
> Hello!
>
> I just obtained this great tool and can't wait to try it out, but I
> have a very simple beginner's question:
>
> Can someone please tell me how to load an image into a picturebox in
> VB6 usig AIL? For now, I just want to be able to load various image
> types (one at a time) and then save them as the original file type
> without any changes.
>
> If I load a JPG then save it again, will it be altered in any way? VB6
> converts everything to bitmaps, but I'm not sure if this happens when
> you just load into a picturebox. I think it is just when you save.
>
> Thanks!
>
Hello!
I just obtained this great tool and can't wait to try it out, but I
have a very simple beginner's question:
Can someone please tell me how to load an image into a picturebox in
VB6 usig AIL? For now, I just want to be able to load various image
types (one at a time) and then save them as the original file type
without any changes.
If I load a JPG then save it again, will it be altered in any way? VB6
converts everything to bitmaps, but I'm not sure if this happens when
you just load into a picturebox. I think it is just when you save.
Thanks!
Sometimes I feel veeeeeeery stupid.
I accidentally copied the freeimage3.dll in the system folder, so I
thought I don't have to distribute this too.
Head-->Table
But now it works as smooth as it should.
If you're using the COM version of AdvImgLib.dll within a .NET
environment, you'll need to distribute 3 files:
- AdvImgLib.dll (goes in Windows/System dir, and MUST be registered
with REGSVR32.EXE)
- Interop.AdvImgLib.dll (goes in your project's BIN dir)
- FreeImage3.dll (goes in Windows/System dir, does NOT need to be
registered)
In your post, you never mentioned Freeimage3.dll. Not distributing it
might be your problem.
Let me know if that doesn't work.
- Kevin
Hi guys.
I wrote a small application in C# and I wanted to run it on a other
computer with windows XP Pro.
What I did:
I copied the exe, the interop.advimglib.dll on the other machine and
the AdvImgLib.dll in the System folder. I registered the AdvImgLib.dll
with the regsvr32.exe.
Now when my program reaches the procedure which should: copy image
into temp, load the image, resize, add meta data and save the image
again, my program crashes with this error:"Creating an instance of the
COM component with CLSID{} from the IClassFactory failed due to the
following error: 800a0035"...
Note: there is a hex ID in the curved brackets which I didn't post.
here is the msdn help for this
error:"http://support.microsoft.com/kb/276011/da"(may not work with
firefox).
I am not quite sure why it crashes. On my computer my program works
smoothly, but not on the other two computers I tested.
I don't know if the error occurs in the AdvImgLib or in the command to
copy the image.
Can anyone help me or should I contact the Microsoft support?
best regards
Try reading the IPTC / EXIF data once the file is first opened, then
append your data to that original data... then when it's time to save
the file out, set the IPTC / EXIF data (original data with your new
data appended) into the picture, then save it.
Remember that if you try to save an image that is currently not a color
depth that is supported, it is automatically converted, and you lose
your metadata in the conversion process. A perfect example of this is
opening an image, applying an effect to it (which automatically
converts the image to 32-bit), then applying your metadata data to it,
then trying to save out the 32-bit image as a JPEG. 32-bit JPEG is
invalid, so it's automatically converted to 24-bit and you lose your
metadata. The workaround here is simple... convert the image to 24-
bit, then apply your metadata to the image, then save the image as a
JPEG.
Let me know if this does not work and i'll ask you for more
information, and dig deeper into this issue.
- Kevin
--- In AIL_Development@yahoogroups.com, "coreyinbend" <cbock@...> wrote:
>
> I use AIL to write IPTC metadata to photos. If a photo already has
> IPTC metadata instead of overwriting the metadata it is wiping out
> both the IPTC and EXIF data. Are there steps I should be following
> to successfully write IPTC metadata to a photo that already has
> metadata?
>
I use AIL to write IPTC metadata to photos. If a photo already has
IPTC metadata instead of overwriting the metadata it is wiping out both
the IPTC and EXIF data. Are there steps I should be following to
successfully write IPTC metadata to a photo that already has metadata?
you're right, it would look like crap. My theory was to try to render
a tga foreground animation in the image property of the picturebox and
a background (non transparent) in the background image property of the
picturebox. this is just because sometimes we run multiple passes on
shots and composite them up afterwards, so it would be good to preview
this before we send them to after effects. Since we normally
premultiply the background pixel color into the fg on composite it
probably wouldnt look great without that anyway, as you end up with a
black or white halo aroung the edge where the alpha overlay is.
anyway, the main thing is playback performance and i have that with
your library over any other.
at the moment for non transparent tga and jpg sequences i'm just
loading the file from IO_loadimage and converting and returning a
bitmap into an image collection. It is very fast to cache these and
the picturebox refresh is bound to a timer that fires 25 times a
second. it plays back realtime at the moment after about 5-10 seconds
of caching so i'll probably stick with it. it's better than what my
£3000 3d software can manage!
cheers!
If you want to squash the image to 16:9 before rendering to a
PictureBox, I would recommend resizing the image first, then
rendering it transparently using the "Render_Transparent" function.
If you are NOT trying to render transparently, just use
the "Render_Normal" function and specify the stretched size as
the "Dest_Width" / "Dest_Height" parameters. Rendering the 2nd way
will always be MUCH faster because it saves a resize operation, and
rendering normal is a quick BitBlt operation where rendering
transparent is a pixel-by-pixel operation (which can be slow for
large images).
If you want to use the transparent PNG approach but don't want to
save the images to the hard drive... you can always save them to
memory-based byte arrays using the "IO_SaveToBinary" function. Then
when it's time to render that "frame"... use the "IO_LoadFromBinary"
function and then call "Convert_ImageToPicture" to convert the hIMG
image handle to a System.Drawing.Image object to set the PictureBox
control. But again, this method uses a lot of conversion calls and
load/save functions. Speed will be an issue here for animation.
The bottom line is that if you're trying to do rapid loading and
displaying of images as part of an annimation sequence, using
the "Render_Normal" function once the images have been loaded will
work great for you. However, if you're trying to animate transparent
images, it will be very slow (unless you spend some time optomizing
the functions to do this a faster way, or change the source images to
allow a more "creative" way of rendering transparently).
P.S. - Rendering images transparently for annimation is highly
unusual because if you render 1 frame transparently, the background
for the transparent images will be the background color of the
PictureBox. Then when you go to render every other frame
transparently, the transparent regions of every other frame will show
the previously rendered frames behind them... which will look like
crap. Or maybe I'm not understanding fully what you're trying to do.
Hi kevin,
Thanks for your reply.
I am using vb.net and AIL to make an animation sequence player. I did
want to squash the image to 16:9 so does that make the render normal
function usable for a 32bit TGA and it's alpha? id assumed that was
for 24bit images only?
Converting the images to PNG for display is a great idea, but the only
method i can ework out from the help is to save the image to disk
first, meaning I would have masses of files for each sequence
playback, and i would have the slowdown of the disk save. Is there a
way of being able to temporarily place the converted PNG in memory
after the loadimage function so that i can compile my imagecache
collection for playback?
Lastly, I'd noticed that my render transparent directly to picturebox
is rather slow - it draws the image slowly from the bottom up,
and sometimes misses large sections of the image. Anything i'm doing
wrong? I was hoping that i'd get a faster output onto the picturebox.
My previous attempts with <ahem> the devil image library returned a
transparent image straight away to the picturebox. :-) (However the
loading and conversion functions are over 3x faster so i'm not
complaining!)
My hope is to be able to use the image and background image properties
of the vb picturebox to preview a composited FG/BG alpha overlay,
along with the ability to write out the composite to a JPG or other
format afterwards, but again, this is not a priority for the app, just
a wishlist!
1) Standard 24-bit BITMAP images do not support transparency... so
converting any 32-bit transparent image (including TGA) to a 24-bit
BITMAP would lose the transparency.
2) As the documentation states, always use "Render_Transparent" to
render images unless you have special needs for your rendering
that "Render_Transparent" doesn't support and another render function
does (i.e. - if you need to stretch your picture when you render
it, "Render_Normal" supports this, but "Render_Transparent" does not).
3) I would suggest loading the 32-bit transparent TGA file, and then
use the "Render_Transparent" function to render the image
transparently onto your PictureBox.
If you're using VB5 or VB6, set the PictureBox's "AutoRedraw"
property to TRUE.
If you're using VB.NET, C#.NET, or any other .NET language... the
PictureBox no longer has an "AutoRedraw" property... so when the
PictureBox is refreshed or redrawn, some or all of your rendered
image will be lost. If you're doing animation (rendering multiple
images onto a PictureBox quickly), this is not an issue. If you're
NOT doing animation, I might suggest storing the image handle and
then kicking off a call to the "Render_Transparent" function every
time the "Paint" event is called.
If you're using .NET, an alternative to this is converting the image
to a transparent PNG image and then setting the "Image" property of
the PictureBox to that PNG image. .NET PictureBoxes support
transparent PNG images.
Hope this helps.
- Kevin
--- In AIL_Development@yahoogroups.com, "bluescreenweasel"
<peteraddington@...> wrote:
>
> Hello all AIL users.
>
> I wanted to know what the quickest way would be to load a 32 bit tga
> so that the alpha transparency was preserved. Ideally i'd need my
> fuction to return a bitmap so that i can update a picturebox. There
> are a few methods pertaining to the use of alpha channels and
> transparency, but i am unsure of what one to use. I just need the
> fastest way of displaying the image. many thanks
>