Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
P

primem0ver

@primem0ver
About
Posts
34
Topics
8
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Incorporating values directly (as is/bytewise) into a string
    P primem0ver

    Geesh. Did you read my OP? Considering the rest of your post, I guess I shouldn't be that surprised. I already tried an Explicit layout. From my OP: "I tried using a generic with using StructLayout.Explicit but I got a runtime error stating that this is not supported". In other words currently, .NET doesn't allow using explicit layouts with generics. And just because YOU don't find anything valuable doesn't mean it isn't. You apparently don't understand the nature of efficient memory management; nor "robustness"; and your disregard for "oldtimers" is very revealing about both your experience and nature. I would change that attitude before you spend your life eating your words. FYI, my reply above to my own topic is a solution to the problem. What is more robust than not having to introduce a new data type?

    .NET (Core and Framework) csharp c++ performance help question

  • Incorporating values directly (as is/bytewise) into a string
    P primem0ver

    I was unable to create a structure that did this. However, I was able to create a generic extender that uses "unsafe" copying to perform the task. The code is below. Still not sure this is the most efficient way to accomplish the task, but it works. The code requires using System.Runtime.InteropServices

    public unsafe static string ToBytewiseString(this T item) where T : struct
    {
    Type t = typeof(T);
    int size = t.GetSize();
    GCHandle pinnedHandle = GCHandle.Alloc(item, GCHandleType.Pinned);
    IntPtr ptr = pinnedHandle.AddrOfPinnedObject();
    StringBuilder result = new StringBuilder();
    int increment;
    if ((size % 2) == 1)
    increment = 1;
    else
    increment = 2;
    for (int offset = 0; offset < size; offset += increment)
    {
    char* c = (char*)((byte*)ptr + offset);
    if (increment == 1)
    {
    ushort c_ = *c;
    result.Append((char)(c_ >> 4));
    --offset;
    increment = 2;
    }
    else
    result.Append(*c);
    }
    pinnedHandle.Free();
    return result.ToString();
    }

    .NET (Core and Framework) csharp c++ performance help question

  • Incorporating values directly (as is/bytewise) into a string
    P primem0ver

    I know this may seem arbitrary to some, but the nature of the project that I am currently working on makes this capability an easy way to solve several problems. I want an efficient, seamless way to integrate values into a stream of characters. I have done this in the past by just converting byte values into chars or even using value.tostring() but it would be more efficient if the characters could be read directly from the memory containing the values. (Examples: an integer is read as 2 characters, a long is read as 4 characters and a GUID is read as 8 characters). This would be really simple in C++. In c# it is turning out to be a huge challenge. I tried using a generic with using StructLayout.Explicit but I got a runtime error stating that this is not supported. Using non-generics doesn't work either because strings and arrays are classes while values are structs and mixing them also doesn't work for the simple reason that the non zero terminated strings used in .NET track data that is probably inconsistent with this layout. Is there any way to directly read (or even copy) data from numeric value bytes into a string? I can think of one possibility using unsafe copying but was wondering if I had any other better (more efficient) options.

    .NET (Core and Framework) csharp c++ performance help question

  • C# reading multiple files by multiple thread issue
    P primem0ver

    If I were you and for some reason I needed to read/write multiple files in parallel (though Gerry is right when it comes to writing files to traditional hard disk drives), instead of the methods you use, I would simplify things by using the Parallel.For or the Parallel.Foreach method.

    C# help csharp question career

  • Derived Treeview override not being called at all.
    P primem0ver

    Alright. Thanks

    C# graphics debugging

  • C# regarding running multiple task
    P primem0ver

    If I were you and for some reason I needed to read/write multiple files in parallel (though Gerry is right when it comes to writing files to traditional hard disk drives), instead of the methods you use, I would simplify things by using the Parallel.For or the Parallel.Foreach method.

    C# csharp tutorial question

  • Derived Treeview override not being called at all.
    P primem0ver

    So what method would I override to add the overlay no matter what draw mode is being used? I can't find one, except perhaps OnPaint... but I would think Microsoft would have included a default drawnode method to use regardless of the draw method. Since the point of my class is to add the overlay, I wouldn't want a potential user of the class to have to specify a draw mode. (I know there are workarounds... but to me forcing us to use them doesn't make a whole lot of sense to me, especially considering the complexity of drawing a tree node).

    C# graphics debugging

  • File delete permission problem
    P primem0ver

    This seems to be the cause of my problem as well. I close the antivirus software and it works fine. Wow. How are you dealing with this?

    .NET (Core and Framework) csharp html help question learning

  • File delete permission problem
    P primem0ver

    Ok. I am following you. I realize that permissions inherited from the user make sense. However, having an application run with fewer permissions than the user is not a safety hazard in terms of security and my experience is that this can happen. Another example (which is incidentally timely, and appropriate for this thread) is that permissions are an issue with certain virtual system accounts on which older versions of this program run. (The creation and deleting of jpgs is a new, unreleased, feature). I have isolated the old issue to something in the way permissions are granted to newer versus older users. The following code causes the application to crash for newer users only. The folder being searched (directoryInfo) is the Downloads folder for the user:

    FileInfo[] fileInfos = directoryInfo.GetFiles("GeniusExport*.*", SearchOption.TopDirectoryOnly); // CAUSES CRASH ON VM

    For all users, the user profile directory is a mapped drive. Perhaps directoryInfo resolves to something non-existent for newer users and perhaps I should test that; however this is a Windows 10 environment. I know for a fact that the people I have worked with who have this problem have a Downloads folder that is being used.

    .NET (Core and Framework) csharp html help question learning

  • File delete permission problem
    P primem0ver

    Regardless, the enumeration resolves to a location determined by the .NET implementation for the specific OS. I am using the enumeration by default so whatever that returns is what I am using. The user has the option to change this but it doesn't matter in context as user specific considerations would not be an issue in a custom folder unless those permissions are altered to something other than the default (which is beyond my control).

    .NET (Core and Framework) csharp html help question learning

  • File delete permission problem
    P primem0ver

    It is an app run by the user that ls logged in. IT seems to be working now but it crashed previously. From my experience, applications have their own permission sets. Are you saying this is not the case? I have had several experiences that would suggest otherwise; the latest being that on Windows 10 a downloaded Excel document opened by the user in excel will allow itself to be read because I have overridden the default behavior. However, if the user launches my application to do the same thing, it will crash with a COM error that appears to be related to the fact that downloaded files are not allowed to be read under the current permissions. This is unique to Windows 10 as it does not happen under Windows 7. I had to import a non-COM Excel reader when I ported to Windows 10 in order to get it to read excel files without crashing (or without me personally opening the files myself in debug mode).

    .NET (Core and Framework) csharp html help question learning

  • File delete permission problem
    P primem0ver

    Did you read my post? I already specified that. Specifically the program saves an Excel file "as an html file in the user's document folder. This automatically generates the [excel_file_name]_files subfolder... The program ALSO auto-generates jpg images every time... and saves those images in this sub-folder." If that is too confusing, it is a subfolder of %USERPROFILE%\Documents created by Excel. This is BEFORE the application exports any excel files to html so the folder is not in use... and my application checks to make sure the folder exists before attempting any file operations; just in case the user has not ever used the program before.

    .NET (Core and Framework) csharp html help question learning

  • File delete permission problem
    P primem0ver

    I know why I am having the problem but I need a solution/workaround. I have a c# program that generates excel output and saves it as an html file in the user's document folder. This automatically generates the [excel_file_name]_files subfolderwhich is used to store specific info used by the html file. The program ALSO auto-generates jpg images every time it is run based on historic data that is taken from the spreadsheet each time it is run and saves those images in this sub-folder. The program needs to be able to delete the files it creates within this folder but of course the user's folder makes sure to keep programs from simply deleting arbitrary files within the user's folder so that prevents me from deleting them as I do not have permission to delete a users files. Is it possible for me to programmatically grant the application OS permissions to delete/change files it creates within a user's subfolder? Or will the user need to run the program with admin rights each time (if they can even get such rights).?

    .NET (Core and Framework) csharp html help question learning

  • 16bit grayscale png export? (and import?)
    P primem0ver

    Thanks. I hadn't heard of SkiaSharp. I will look into them. I mentioned my problem with Magick.NET in the OP but it turns out that the link for the runtime is just hard to find. Apparently I don't have to compile Magick.NET myself (which I was unable to do because their format is for VS 2017... they don't have any downloads for earlier versions of VS). As is, I have a working solution since I found the Magick.NET dll and while inefficient, I have a work-around. To clarify, I will probably still look into SkiaSharp for this, or future reference, as Magick.NET doesn't appear to have an efficient way of modifying pixel values directly.

    .NET (Core and Framework) help question csharp c++ visual-studio

  • 16bit grayscale png export? (and import?)
    P primem0ver

    Hmm... well it appears that either you don't understand colorspaces and how color values work, or you didn't realize that I am trying to display the picture while working on it (which to me is a given). Doing what you suggest will not produce a grayscale picture as assigning a pixel in ARGB format the value of 65535 will give the G (green) channel a value of 255 and a blue channel value of 255 (making yellow) and an ARGB pixel value of 255 will give solid blue. Furthermore, when .NET reads a 16bit grayscale picture, it DOES use the ARGB (specifically the 32bbpARGB) format and it DOES loose the data because it truncates the 16 bit value to an 8 bit value, losing the less significant bits (so 65535 is read as 255 and 255 is read as zero). You can find documentation about this issue all over the internet. It has the same effect as dividing the 16 bit values by 256. It then fills each of the color channels (RGB) with this 8 bit value so that they are all the same, giving a grayscale picture. Otherwise, you would not see a grayscale picture. If you then try to save the file, it will result in an 8bit grayscale picture. If you try using the 16bbpGrayscale pixel format and then try to save it, .NET throws an exception because 16 bit grayscale picture loading and saving are not supported by .NET (hence the need for this thread).

    .NET (Core and Framework) help question csharp c++ visual-studio

  • 16bit grayscale png export? (and import?)
    P primem0ver

    Yes... been doing what you describe for years. However GDI+ does not import 16 bit greyscale as a 16 bit grayscale and does not export 16 bit grayscale. When it imports, it imports as a 32bit bgra which makes dealing with 16 bit grayscale values impossible because of the loss of information when converting 16 bit grayscale values to 8 bit rgb values. Exporting through the standard .NET drawing libraries is impossible as I have already read in several posts on this topic. My application needs to use grayscale values from 0-65535 in order to avoid a "shelved" appearance in the heightmaps I generate.

    .NET (Core and Framework) help question csharp c++ visual-studio

  • 16bit grayscale png export? (and import?)
    P primem0ver

    Thanks for your quick reply. That looks like a native library. Not necessarily a problem but I am curious if there is a .NET wrapper. Also, is that a dll separate from the software or will I need to run GIMP? Is there any documentation on the class formats and uses? I am noticing things like "image_id" and other proprietary data types. One problem I may run into is that I currently need a 64 bit library as my project requires enough memory to produce extremely large bitmaps for illustrating data (I need around 2,061,341,604 bytes available for a 22701 x 22701 image in addition to the regular memory used by the application which is not small by itself).

    .NET (Core and Framework) help question csharp c++ visual-studio

  • 16bit grayscale png export? (and import?)
    P primem0ver

    Hopefully this forum is appropriate for this question. No one seems to visit the graphics forum very often. I need to be able to both import and export a 16 bit grayscale png file. I have found some help with importing but exporting is a big problem. I have found stack overflow references to Magick.NET but I cannot get this source to compile in VS 2012 as it requires build tools 141 and setting it to 110 results in errors, one of which is a missing dll that I cannot find using internet resources. I have already tried installing runtimes for later versions and for some reason they cannot be used. Probably because I use Windows 7. Are there any other alternatives? Or advice on how to get a runtime of Magick.NET? I need to be able to read, manipulate (on an individual basis), and save 16 bit grayscale pixel values to a heightmap for importing into various terrain editors. In terms of manipulating, I can probably use the native 48 bit rgb pixel format (please correct me if I am wrong) for display, convert, and then just read/write to the image directly but I still need to find a runtime that supports reading and writing to the 16 bit format. It would be nice however, if there was a library that did this automatically.

    .NET (Core and Framework) help question csharp c++ visual-studio

  • Creating a Designer Compatible ToolStripControlHost?
    P primem0ver

    I created a numeric up down control that can be placed in a toolstrip using the ToolStripControlHost. Now I want to be able to use it in designer. This article explains why it can't be done strictly using the ToolStripControlHost but it doesn't explain how to make it Designer compatible... at least not explicitly. The problem is that I am already inheriting from ToolStripControlHost. As far as I know, c# does not allow inheriting from more than one class. So how do I make my ToolStripControlHost control Designer compatible? I have researched and found that there is a DocumentDesigner class that I could subclass and reference. However, I don't want this control to be added to the Toolbox. I only want it to show up on the ToolstripItem designer interface, so I am allowed to add it as shown in the example in the linked article (The "Month Calendar" in the dropdown for adding another control to the toolstrip). How would I do this?

    .NET (Core and Framework) tutorial question csharp com help

  • Prevent adding of nodes to a TreeNode?
    P primem0ver

    Ok. That actually sounds fine. It won't be a big deal because the hiding of nodes is not depending on searching which can change as you type. It is dependent on what kind of nodes the user is trying to view... (almost like a file type filter) so changing that is not something that happens every second.

    C# csharp c++ css data-structures json
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups