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
T

terradtc

@terradtc
About
Posts
12
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Bitmaps
    T terradtc

    This is a Compact framework question... I'm building this application that deals with a lot of images coming from the network (~30 k a piece). I am starting to see serious memory issues arise after a while. While my images are mostly cached and the cache is cleaned up if you play with the app for long enough you get an out of memory exception. I can see the app running with up to 25 megabytes of memory in use, the problem is I'm not entirely sure what is causing this. My best guess is that the bitmap caches the decompressed version of the image after its been shown on the picturebox, either that or the picturebox does. Is there a way to reduce the memory footprint while still having that amount of images (roughly 30) in memory, the only way I can think of is to not put the actual bitmap on the display but rather a copy and after the bitmap has been shown to let the garbage collector handle the copy, however I'm pretty sure that thats going to hurt performance. Any other idea's?

    C# question performance graphics sysadmin help

  • Regarding the tool for finding functions and decalaration syntax in windows dll
    T terradtc

    To see what functions are available you might be able to use the built in function of Visual studio, but it does depend on how the dll has been built, I would try that first though because its the easiest way. There's also depends, it allows you to see whats going on in the dll http://www.dependencywalker.com/[^]

    C# question csharp database

  • Winform KeyPress
    T terradtc

    Sounds like you're trying to create an accellerator, have a look at this: http://www.codeguru.com/columns/experts/article.php/c4639[^]

    C# question database help

  • How to convet the text into your Handwriting using table PC in .Net
    T terradtc

    Hi, The idea you have is pretty cool, however it would be a lot of work if you want to do it correctly. The problem with handwriting is that no 2 characters are usually the same, it usually depends on the letter before, the position in the line you are trying to write the length of the word you write (long words require you to move your hand while writing causing the letters to be written differently), the speed at which you are writing (scratching something down or writing a proper letter), the texture of the paper and finally the type of pen used. Although the ligature functions on the opentype font specification would allow you to do some of these things, it would be a heck of a lot of work. The easy way out is to just create a Bitmap font[^] of your handwriting, the result would not be stunning but its the easiest way to go if you don't want to spend a lot of time on it

    C# csharp mobile design regex

  • reading pixel's value in an image
    T terradtc

    You'll want to do some filtering and maybe change the average a bit since this is very sensitive to minor color differences on space images but the basic idea here works. It also doesn't deserve a beauty prize but for 10 minutes of work, I wasn't expecting it to. Furthermore this code will fail on any image that's not 24 bits per pixel. class StarGazer { // this function works on pictures of up to 1.3 billion pixels in width public bool[,] toBool(Bitmap bitmap) { Rectangle rect = new Rectangle(0, 0, bitmap.Width, bitmap.Height); System.Drawing.Imaging.BitmapData bmpData = bitmap.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb); bool[,] boolBitmap = new bool[ bitmap.Height,bitmap.Width]; unsafe {//first we calculate the average value of a pixel byte* ptr = (byte*)(bmpData.Scan0); ptr--; ulong overallAvg = 0UL; for(int y = 0;y<bitmap.Height;y++) { ulong lineAvg = 0UL; for (int x = 0; x < bitmap.Width; x++) { lineAvg+= *(++ptr); lineAvg+= *(++ptr); lineAvg+= *(++ptr); } overallAvg += lineAvg /(ulong) bitmap.Width; } overallAvg /= (ulong)bitmap.Height; int average = (int)overallAvg; //we've got the average value a collection of three pixels needs to have to become an object ptr = (byte*)(bmpData.Scan0); ptr--; for (int y = 0; y < bitmap.Height; y++) { for (int x = 0; x < bitmap.Width; x++) { boolBitmap[y, x] = (*(++ptr) + *(++ptr) + *(++ptr) > average); } } } bitmap.UnlockBits(bmpData); return boolBitmap; } public Bitmap boolBitmap(bool[,] boolBitmap) { Bitmap temp = new Bitmap(boolBitmap.GetLength(1),boolBitmap.GetLength(0)); System.Drawing.Imaging.BitmapData bmpData = temp.LockBits(new Rectangle(0, 0, boolBitmap.GetLength(1), boolBitmap.GetLength(0)), System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format24bppRgb);

    C#

  • Client/Server TCPClient
    T terradtc

    Alternatively you can also use the asynchronous methods of TCP client to make your connection, BeginConnect and EndConnect

    C# sysadmin help question

  • Client/Server TCPClient
    T terradtc

    You will want to start running your TCPClient on a different Thread so it doesn't lock up the GUI thread while waiting for a timeout or connection refused. So do the following ThreadPool.QueueUserWorkItem(new WaitCallback()); Keep in mind that the Drawing of items can only be done on the thread they were created on (usually the main thread) so setting text and that sort of thing should be done by invoking the functions using the Invoke function

    C# sysadmin help question

  • automatic byte conversion?
    T terradtc

    Thanks a lot! Since the size of the pictures I'm dealing with is fairly large (up to 5MP on current devices) and the ammount of memory and CPU power is generally low (PPC's are not that fast), I have had to really keep down on the CPU load and memory usage. I've found your comments to be very helpful.

    C# help csharp tutorial question

  • automatic byte conversion?
    T terradtc

    Thanks for your input! I expected the byte to still behave as a true (8 bits) byte, does this also mean that ints work faster on a 32-bit machine then bytes do since a byte has to be processed to behave as a byte, example: byte b = (byte)0x04 + (byte)0x10; would be roughly translated to: int b = 0xff &((byte)0x04+(byte)0x10); And would a byte[12] take up the same amount of memory as an int[12] would, or would a byte array simply be a pointer to a field thats of the size int[3]

    C# help csharp tutorial question

  • Searching randomly
    T terradtc

    Be aware that most examples available through a search on google can and probably will result in an PathTooLongException, be sure to use the FindFirstFile function in kernel32.dll

    C# question csharp algorithms help

  • reading pixel's value in an image
    T terradtc

    You're actually thinking the wrong way, you should not compare the pixels to the ones of their neighbours because the stars can be bigger then x pixels. The easiest way to do this is to convert the image to a binary image first. What you should do is calculate the average pixel value of the image and then creating a bool array of the same size of the image, anything higher then the average becomes true, anything lower becomes false. Then you'll want to do something like labelling to differentiate between different stars so you can cut them out or do whatever you need to do with them. A tip in advance: Don't use the getPixel and setPixel methods of the Bitmap, use the LockBits and UnlockBits functions, they are a lot faster..

    C#

  • automatic byte conversion?
    T terradtc

    I was working on some image filtering when I saw a problem in my output. After a little while I noticed two possible problems with the code after fixing one of them the output was, strangely enough, correct. Here's a part of the code: public struct Pixel { public byte r; public byte g; public byte b; public static bool operator >(Pixel p1,Pixel p2) { return p1.r + p1.g + p1.b > p2.r + p2.g + p2.b; } } Now my thought here was that since the r,g and b values are bytes, adding them could cause an overflow of the byte. For example: 128,128,128 would add up to 128 and would cause 64+64+64 to be greater then the second example since it adds up to 192 (192>128). However this does not seem to be the case, 128,128,128 seems to add up to 384 which would be impossible with a byte, so is the + operator actually changing my byte to a (u)long, (u)int or (u)short internally. Has anyone found any documentation on this issue, and can I expect this to work on any implementation of c#?

    C# help csharp tutorial question
  • Login

  • Don't have an account? Register

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