Nem
Members-
Posts
21 -
Joined
-
Last visited
About Nem
- Birthday 01/01/1970
Nem's Achievements
-
Suppose I could, but I've been trying to adhere to the LGPL (even though I've released the source code to the plug-in). Anyhow, version 1.1.0 adds x64 support. Thanks Rick for all your help.
-
Using an IntPtr does work; interesting how [MarshalAs(UnmanagedType.LPStr)] did work before though... Anyways, I can use System.Runtime.InteropServices.Marshal.PtrToStringAnsi(Info.sName) to get the string. Thanks for all your help Rick. Everything seems to be working now.
-
VTFLIB_API vlBool vlImageGetImageFormatInfoEx(VTFImageFormat ImageFormat, SVTFImageFormatInfo *VTFImageFormatInfo) { if(ImageFormat >= 0 && ImageFormat < IMAGE_FORMAT_COUNT) { memcpy(VTFImageFormatInfo, &CVTFFile::GetImageFormatInfo(ImageFormat), sizeof(SVTFImageFormatInfo)); return vlTrue; } return vlFalse; } I tried changing the out to a ref to no avail (and creating an instance of ImageFormatInfo beforehand). This is the only function that doesn't seem to be working. Interestingly this nearly identical function does work: [DllImport("VTFLib.dll", CallingConvention = CallingConvention.Cdecl)] public unsafe static extern void vlImageCreateDefaultCreateStructure(out CreateOptions CreateOptions); The only significant difference I can see is that the problem function's struct has a string in it.
-
It doesn't give me one. Even with the debugger attached and visual studio set to break on all exceptions. All I get is a dialog that says that Paint.Net has stopped working. The debugger catches other exceptions just fine...
-
I first wrote the plug-in in .Net 2; the Pack attribute was added in .Net 3 so it wasn't an option. Interestingly, the following does not work: [structLayout(LayoutKind.Sequential, Pack=1, Size=34, CharSet=CharSet.Ansi)] //[structLayout(LayoutKind.Explicit)] public struct ImageFormatInfo { //[FieldOffset(0)] [MarshalAs(UnmanagedType.LPStr)] public string sName; //[FieldOffset(8)] public uint uiBitsPerPixel; //[FieldOffset(12)] public uint uiBytesPerPixel; //[FieldOffset(16)] public uint uiRedBitsPerPixel; //[FieldOffset(20)] public uint uiGreenBitsPerPixel; //[FieldOffset(24)] public uint uiBlueBitsPerPixel; //[FieldOffset(28)] public uint uiAlphaBitsPerPixel; //[FieldOffset(32)] [MarshalAs(UnmanagedType.U1)] public bool bIsCompressed; //[FieldOffset(33)] [MarshalAs(UnmanagedType.U1)] public bool bIsSupported; } [DllImport("VTFLib.dll", CallingConvention = CallingConvention.Cdecl)] [return:MarshalAs(UnmanagedType.U1)] public unsafe static extern bool vlImageGetImageFormatInfoEx(ImageFormat ImageFormat, out ImageFormatInfo ImageFormatInfo); VtfLib.ImageFormatInfo Info; if (VtfLib.vlImageGetImageFormatInfoEx(Token.eImageFormat, out Info)) // This line crashes. { } Using this C++ declaration: typedef char vlChar; typedef unsigned char vlBool; typedef unsigned int vlUInt; #pragma pack(1) typedef struct tagSVTFImageFormatInfo { vlChar *lpName; vlUInt uiBitsPerPixel; vlUInt uiBytesPerPixel; vlUInt uiRedBitsPerPixel; vlUInt uiGreenBitsPerPixel; vlUInt uiBlueBitsPerPixel; vlUInt uiAlphaBitsPerPixel; vlBool bIsCompressed; vlBool bIsSupported; } SVTFImageFormatInfo; #pragma pack() sizeof(SVTFImageFormatInfo) = 34 Go figure.
-
Thanks you all your help! The callstack was: mscorlib.dll!System.Reflection.Assembly.GetTypes() + 0xcd bytes PaintDotNet.exe!PaintDotNet.FileTypes.GetFileTypeFactoriesFromAssembly(System.Reflection.Assembly assembly) Line 54 + 0xc bytes C# PaintDotNet.exe!PaintDotNet.FileTypes.GetFileTypeFactoriesFromAssemblies(System.Collections.ICollection assemblies) Line 75 + 0x5 bytes C# PaintDotNet.exe!PaintDotNet.FileTypes.LoadFileTypes() Line 149 + 0x9 bytes C# PaintDotNet.exe!PaintDotNet.Controls.DocumentWorkspace.ChooseFiles(System.Windows.Forms.Control owner, out string[] fileNames, bool multiselect, string startingDir) Line 1788 + 0x19 bytes C# PaintDotNet.exe!PaintDotNet.Actions.OpenFileAction.PerformAction(PaintDotNet.Controls.AppWorkspace appWorkspace) Line 41 C# PaintDotNet.exe!PaintDotNet.Controls.AppWorkspace.PerformAction(PaintDotNet.Actions.AppWorkspaceAction performMe) Line 1844 + 0xc bytes C# PaintDotNet.exe!PaintDotNet.Controls.AppWorkspace.CommonActionsStrip_ButtonClick(object sender, PaintDotNet.EventArgs<PaintDotNet.CommonAction> e) Line 2555 C# PaintDotNet.exe!PaintDotNet.Controls.CommonActionsStrip.OnButtonClick(PaintDotNet.CommonAction action) Line 121 + 0x26 bytes C# PaintDotNet.exe!PaintDotNet.Controls.CommonActionsStrip.OnItemClicked(System.Windows.Forms.ToolStripItemClickedEventArgs e) Line 133 C# System.Windows.Forms.dll!System.Windows.Forms.ToolStrip.HandleItemClick(System.Windows.Forms.ToolStripItem dismissingItem) + 0x39 bytes System.Windows.Forms.dll!System.Windows.Forms.ToolStripItem.HandleClick(System.EventArgs e) + 0x90 bytes System.Windows.Forms.dll!System.Windows.Forms.ToolStripItem.HandleMouseUp(System.Windows.Forms.MouseEventArgs e) + 0x1f5 bytes System.Windows.Forms.dll!System.Windows.Forms.ToolStrip.OnMouseUp(System.Windows.Forms.MouseEventArgs mea) + 0xfa bytes System.Windows.Forms.dll!System.Windows.Forms.Control.WmMouseUp(ref System.Windows.Forms.Message m, System.Windows.Forms.MouseButtons button, int clicks) + 0x3e7 bytes System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m) + 0xd39 bytes System.Windows.Forms.dll!System.Windows.Forms.ToolStrip.WndProc(ref System.Windows.Forms.Message m) + 0x9d bytes PaintDotNet.SystemLayer.dll!PaintDotNet.SystemLayer.ToolStripEx.WndProc(ref System.Windows.Forms.Message m) Line 84 C# System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m) + 0x46 bytes System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.Callback(System.IntPtr hWnd, int msg = 514, System.IntPtr wparam, System.IntPtr lparam) + 0xb5 bytes [Native to Managed Transition] [Managed to Native Transition] System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(int dwComponentID, int reason, int pvLoopData) + 0x5c3 bytes System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason = -1, System.Windows.Forms.ApplicationContext context = {System.Windows.Forms.ApplicationContext}) + 0x578 bytes System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context) + 0x65 bytes PaintDotNet.exe!PaintDotNet.Startup.StartPart2(string mutexName) Line 397 + 0x9 bytes C# PaintDotNet.exe!PaintDotNet.Startup.Main(string[] args) Line 428 + 0xb bytes C# And the loader exception was: Could not load type 'ImageFormatInfo' from assembly 'VtfFileType, Version=1.0.5.0, Culture=neutral, PublicKeyToken=null' because it contains an object field at offset 4 that is incorrectly aligned or overlapped by a non-object field. I discovered that it does not like the following struct: [structLayout(LayoutKind.Explicit)] public struct ImageFormatInfo { [FieldOffset(0)] [MarshalAs(UnmanagedType.LPStr)] public string sName; [FieldOffset(4)] public uint uiBitsPerPixel; [FieldOffset(8)] public uint uiBytesPerPixel; [FieldOffset(12)] public uint uiRedBitsPerPixel; [FieldOffset(16)] public uint uiGreenBitsPerPixel; [FieldOffset(20)] public uint uiBlueBitsPerPixel; [FieldOffset(24)] public uint uiAlphaBitsPerPixel; [FieldOffset(28)] [MarshalAs(UnmanagedType.U1)] public bool bIsCompressed; [FieldOffset(29)] [MarshalAs(UnmanagedType.U1)] public bool bIsSupported; } This makes sense because the pointer is 8 bytes in x64. However, it poses an interesting question: How do I explicitly layout a struct in such a way that it works in both x64 and x86 when it contains pointers if the assembly fails to load when it's wrong (even if it's never used - e.g. I can't just define it both ways)? Perhaps [structLayout(LayoutKind.Sequential, Pack=1)] will work; I'll try that tomorrow... Also I noticed Paint.Net uses Assembly.GetTypes(); is there some reason it doesn't use Assembly.GetExportedTypes()? I have used the later to eliminated problems loading certain assemblies in the past.
-
Thanks for your help Rick. I just named the .dll with the x84/x64 extension for the .zip, I've been testing with the appropriate .dll for my system. However, as I mentioned before, if I completely remove all references to VTFLib from my code, the plug-in still does not work. (Thanks for the tip though; I'll use it in the final release.) I noticed today that Paint.Net does not attempt to load the file format plug-ins until you select open or save from the menu. When I do that I can now see that I am getting a System.Reflection.ReflectionTypeLoadException exception; however, I have no idea why. Is it possible to get Paint.Net to output more debug info? I get this exception even if I remove all references to VTFLib and make everything except for VTFFileTypes:IFileTypeFactory and VTFFileType:FileType internal.
-
I have; it odes not appear is if Paint.Net loads the .dll, however, the .dll is locked while Paint.Net is running, so it is finding it and doing something.
-
I'm trying to update an old file format plug-in I wrote to work with the latest version of Paint.Net. Unfortunately, not mater what I try, I cannot get the plug-in to show up in Paint.Net. I've updated my project to 2008 and targeted 3.5 and the latest Paint.Net assemblies. The plug-in makes use of a C .dll, but removing all code references to the .dll does not change anything. I am unable to find any log files indicating what may be wrong. My source code can be found here: http://nemesis.thewavelength.net//files/pdnvtfplugin1xx-source.zip Any help would be appreciated!
-
Apologies to everyone for leaving this so long. There is a laundry list of other things that need to be done to properly support x64 in VTFLib. I started last weekend with the conversion of HLLib and I will continue with VTFLib this weekend. Unfortunately it will have to stay with the Visual C++ 2005 SP1 x64 libraries as nVIDIA scrapped nxDXT in favor of a newer version which is missing many features VTFLib relies on (and they don't supply VS 2008 .libs). Once VTFLib is up to speed, I'm hoping this plug-in won't take too long.
-
I've released a new update (v1.0.4) that supports version 7.4 of the VTF format.
-
The Orange Box, which contains Team Fortress 2 and Half-Life 2: Episode Two, has hundreds of new textures available for the upcoming TF2 beta (starting Monday). These textures are of a new version (v7.3), as such, I just thought I'd let anyone interested know that v1.0.3 of my Paint.NET VTF Plugin has been released with full VTF v7.3 support. Nem
-
Image data allocation for animated files was done on the stack (I didn't know another way to do a unmanaged multi-dimensional arrays in C#). I've thought of a workaround however, care to give it a try (only the pointer array is done on the stack now)? Let me know if it works, otherwise, any useful error message you can send my way? Thanks, Nem
-
The plug-in uses a library I wrote called VTFLib which is a native 32-bit library. If I get a change I'll try to convert VTFLib to 64 bits and update the plug-in, but in the mean time its going to have to be 32-bit only (I'm quite bogged down with other projects). Sorry, Nem
-
I've released a small update (v1.0.1) to a bug where the user selected flags weren't being saved, just the generated flags. I also improved automatic flag selection (based on other options). Nem