topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Sunday May 18, 2025, 1:23 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Recent Posts

Pages: prev1 ... 341 342 343 344 345 [346] 347 348 349 350 351 ... 438next
8626
Developer's Corner / Re: GarageGames: $99 Game Engines (with Source!)
« Last post by Renegade on January 20, 2011, 10:17 PM »
Well, we'll see...

http://www.garagegam...ms/viewthread/123860

Cross fingers...
8627
Developer's Corner / Re: GarageGames: $99 Game Engines (with Source!)
« Last post by Renegade on January 20, 2011, 10:04 PM »
Wow. Very interesting. And dirt cheap! I'm very tempted just to buy a license to play with~! :P

All the money I make from the gaming industry is from other people's games. Never done any game stuff for myself before.

I'm thinking about it too :)  If I didn't already have a hobby project, I probably would now... but I'll wait until I have time to play with it.  But it's very interesting- especially looking at the games made with it.  Thanks!  :Thmbsup:

It should be noted that the $99 price point is only temporary, but how long the "sale" lasts and what the price will be afterward are still unknown.

@Everyone, the "limited time" language is sort of up to you. We want to see how the community reacts to such a low price. We would like it to stay around for a while since we think that the price ( or some number near it) is really beneficial for our community. We're in this together ;)

Thanks for posting this clarification.  So now I *really* have to think about it.


Grrr...  >:(

Just when I thought I could put this off for a bit... Hmmm... Looks like I need to s*** or get off the pot...

Well, if I can use C# (easily), I'll buy. Need to figure that one out...

Off to let my ADHD make me slightly less productive for the next 30 minutes while I fart around and contemplate whether I wasted 30 minutes or should have just fallen off my wallet 30 minutes ago and bought a license... I'm babbling now... Time to goof-off for a bit before getting back to work... :D

8628
Developer's Corner / Re: GarageGames: $99 Game Engines (with Source!)
« Last post by Renegade on January 20, 2011, 08:43 PM »
Wow. Very interesting. And dirt cheap! I'm very tempted just to buy a license to play with~! :P

All the money I make from the gaming industry is from other people's games. Never done any game stuff for myself before.
8629
Living Room / Re: Miss America Hates Wikileaks, Might Be An Idiot =D
« Last post by Renegade on January 20, 2011, 08:28 PM »
However you do make a good point about the down-side of putting people under a microscope.

We all do things that are really stupid sometimes. I know I have.

...and I think that was the case.  :tease:  :eusa_dance:
8630
Developer's Corner / Re: C# GDI+ Problem with byte[] and Bitmap - Memory Issues
« Last post by Renegade on January 20, 2011, 08:12 PM »
I've been using my DCDisplay database which is doing 1 image a second (on average, since it has to extract them from archive), and that has been running for 24 hours. I think you should probably decode the images on 1 thread, and do the checksum on a second thread so you would only ever have 1 image being decoded at once.

I found a problem with Texture2D.FromFile (it failed with CYMK format jpg files) so when that fails I use the code below

if (imageCache == null)
{
  memory.Seek(0, SeekOrigin.Begin);   //Probably safest to do this
  using (System.Drawing.Image image = SD.Bitmap.FromStream(memory))
  using (MemoryStream bitmapStream = new MemoryStream())
  {
     image.Save(bitmapStream, System.Drawing.Imaging.ImageFormat.Bmp);
     bitmapStream.Seek(0, SeekOrigin.Begin);
     imageCache = Texture2D.FromFile(context, bitmapStream);
     bitmapStream.Close();
  }
}                           

But for your case you can just use the bitmap stream to calculate the checksum (BMP is a really simple format, and it means all the exif data has been stripped)

Neil Harding

The current code (refactored massively for brevity) looks like this:

Code: C# [Select]
  1. private void GetHashForItem(object state)
  2. {
  3.         HashWorkItem hwi = (HashWorkItem)state;
  4.         ImageConverter converter = new ImageConverter();
  5.         Bitmap bmp = (Bitmap)Bitmap.FromFile(hwi.FileName);
  6.         byte[] bytes = new byte[1];
  7.  
  8.         // 1 - Get byte[] data from file or pixels
  9.         if (!hwi.CompareExactImageData) // file
  10.         {
  11.                 bytes = (byte[])converter.ConvertTo(bmp, bytes.GetType());
  12.         }
  13.         else if (hwi.CompareExactImageData) // pixels
  14.         {
  15.                 bytes = GetBytesFromBitmap(bmp);
  16.         }
  17.  
  18.         // 2 - The hashing
  19.         SuperFastHashUnsafe sfh = new SuperFastHashUnsafe();
  20.         hwi.ItemHash = sfh.Hash(bytes);
  21.  
  22.         try
  23.         {
  24.                 // 3 - invoke the delegate to store the results
  25.                 this.Invoke(new StoreHashResultsDelegate(StoreHashResults), hwi);
  26.         }
  27.         catch
  28.         {
  29.         }
  30. }

Which boils down to 3 steps:

1) Get bytes
2) Do hash
3) Queue to store results

The hashing has presented no problems so far. I'd be concerned that there would be a performance hit by spinning that off into another thread as I'd be passing a large byte[] array. While it is a reference type, I just don't really like the idea of throwing references around like that. Not sure why. It just strikes me as "out of scopishly odd". :) The method that it's in would go out of scope while the thread is running. Dunno... It just seems like I could start getting null references there if the byte[] were collected (GC'd) before the hashing had completed. Am I too worried?

The one method there is using the bitmap stream already. It saves to the memorystream, then gets the byte[] from there. It must be a byte[] as the memorystream itself can't be hashed.

But either way, I'm still not much closer to solving the problem. The only things I have on my plate left to try out are:

1) MemoryFailPoint -- Try to determine if there is enough memory available, then handle the situation -- http://www.codeproje...ects____Trouble.aspx
2) Single threading -- get rid of the threadpool and do them all sequentially

I just don't like either. I want things to work as you would expect them to work... I hate work arounds. Well, except for working around work arounds... :) :D  :o
8631
Living Room / Re: Miss America Hates Wikileaks, Might Be An Idiot =D
« Last post by Renegade on January 20, 2011, 07:36 PM »
I'm quite sure there are many governments with major abuse.

I thought "government" and "abuse" were synonyms~! :P
8632
This is a bit old of a topic, but I have a Mac now and... I don't use it. It's simply not very good at anything in comparison to my desktop PC. They both cost about the same, and my desktop PC is simply far better at everything. Would I swap? Not a snowball's chance in Hell. And the only thing I need to do is move my hands from one keyboard and mouse to the other.

8633
Living Room / Re: Miss America Hates Wikileaks, Might Be An Idiot =D
« Last post by Renegade on January 20, 2011, 06:33 PM »
Apologies in advance to my American friends  Wink

http://www.youtube.c.../watch?v=fJuNgBkloFE


Why the subtitles?  I guess they figured that people who watched the video would be just as lost as the people in it.

it is all pretty confusing...
but it does bother me that the makers obviously set out with an agenda - the maps have the countries all mislabeled - that way you can laugh at the people even if they're just reading the map...

In my experience people from bigger countries, especially better off countries, tend to be very ignorant of the rest of the world, even if it is on their doorstep, and you dont get much bigger than the US of A, but, OTOH, as KatyKaty says: of course we have no way of knowing how many smart people they had to edit out...



I find that pretty much no matter where you go, you'll find brilliance and idiocy, good and bad.

The thing with American ignorance, is that when you go to other places, the ignorance is just different. I remember years ago it was very common for people to tell me all about how Korea had 4 seasons, and how special that was... Ummm... Ok. They really thought that it was special. (The comparison being to places like SE Asia where you basically have a wet and dry season.) That was the product of an education system under a few dictators that ingrained a massive degree of patriotism and nationalism in people to motivate them to work harder "for the good of the country". But wherever, while the reasons for some ignorant behavior may change, it is what it is.

The rest of the world looks to the US for policy, fashion, trends, entertainment... etc. etc. So they also seem to get closer scrutiny than other places. But on closer examination... I'm sure you'll find the same things wherever you are and wherever you go.

e.g. Australia would be perfect it it weren't for all the Australians.

Now sub in <country> and <nationality> there and you'll see it works for anywhere and any people. (I love that joke~!)

The "ugly American" is pretty much a cliche, but you get the same from every place.

My dad overheard a woman from the southern US on a trip to the Caribbean as she looked at some souvenir calendars, "Oh... Is it January here too?" Yep... Stereo-typical and trite cliche.

Canadians can be pretty ugly as well. A pet peeve of mine is how insecure and petty so many Canadians can be when it comes to being compared to Americans/the US. You see this a lot in Canadians overseas that haven't been out of Canada for long. (Newbies!) It's embarrassing to hear someone go on about how they hate to be confused with Americans... Sigh... While Canadian and American accents are almost identical, they differ in only very subtle ways. Americans around Fargo in Wisconsin speak pretty much the exactly same consonants and vowels as Canadians (same accent), but that's really nit-picking. (Particularly the vowels in "about" let you pick out a Canadian accent.)

I've heard the same confusion for Aussies and Brits. A quick way to tell the difference is to listen to the way people speak with an upswing at the end of their sentences. If they do, chances are they are Australian.

Those "stupid American" videos really aren't very accurate portrayals of Americans. You could do the same thing anywhere. However, in other places you'd likely run into serious problems with people hating you for it. Americans seem to be pretty thick-skinned when it comes to the topic. I've seen national news coverage and nation-wide outrage over late night talk-show jokes. Some people are pretty thin-skinned.

The world is just hyper-aware of the US. It would likely do a lot of people a little bit of good to reflect on themselves for a few moments. :)

People in different places have different quirks. It's just a matter of figuring out what they are.
8634
Developer's Corner / Re: C# GDI+ Problem with byte[] and Bitmap - Memory Issues
« Last post by Renegade on January 20, 2011, 08:37 AM »
"Bitmap bmp = null;" :)

DOH~!

I've got bada on my brain, and thinking in terms of 2-phase construction...

If what you're saying about GDI+ is right, I may end up doing it all consecutively in a single thread. I hope not...
-Renegade
Well, I've heard of people resorting to running one process per CPU core in order to parallelize GDI/GDI+ operations - it's per-process re-entrant, but not per-thread-in-process.

I'd really like to avoid that as I'm not sure that it's worth the overhead to start a new process for each photo. Though a process per core that ran long and returned a result set might be good...

Still... that error is pissing me off and I'd like to see it go away rather than run away from it and do a work around. I hate working around problems if I can avoid it. In other words, I'd rather work around having to do work arounds. :)


http://www.codeproje...ects____Trouble.aspx
8635
Developer's Corner / Re: C# GDI+ Problem with byte[] and Bitmap - Memory Issues
« Last post by Renegade on January 20, 2011, 08:15 AM »
For why the bitmap is constructed, and not just having memory allocated, I have that 2 posts above. (Catching up here...)
-Renegade
Yes, and I commented that you don't need to construct the object, since you have a null-check before disposing it... so just set it to null instead of wasting time on constructing a never-used object :)

As for disposing the MemoryStream, I took a look at in in reflector, and it doesn't look like there's apparent memory leaks if you don't dispose it (but there's some async I/O event cancelling in it's base Stream class) - but since it implements IDisposable, not disposing of it is an error, no matter what the current implementation does.

As for the threading: I'm not sure about the re-entrancy of GDI+, but GDI definitely wasn't re-entrant, and I have a recollection of GDI+ not being, either. This means you should never have more than one thread issuing GDI+ code... when you throw background tasks on a Threadpool, multiple tasks may run in parallel.

Wouldn't be surprised if your issues are because of two threads entering GDI+ at the same time and fucking up some internal state.

Ah... that check should come out actually...

Changing:

Bitmap bmp;// = new Bitmap(1, 1);

Results in this:

if (bmp != null)

Throwing a "Use of unassigned local variable 'bmp'" compiler error (won't compile like that).

If what you're saying about GDI+ is right, I may end up doing it all consecutively in a single thread. I hope not...
8636
Developer's Corner / Re: C# GDI+ Problem with byte[] and Bitmap - Memory Issues
« Last post by Renegade on January 20, 2011, 07:59 AM »
Mind you common sense is telling me to shutup ... But I just gotta ask...

In lines 37 - 43, why is hwi.CompareExactImageData being evaluated (basically) twice?

...

Wouldn't that tend to spike the work load?

It's unclear code. Unless it is a property with very expensive processing behind it, it will do next to nothing except cost a few more processor cycles. And I somehow expect the CLR to be smart enough to recognise that case.

It's actually a very simple struct:

Code: C# [Select]
  1. public struct HashWorkItem
  2.     {
  3.         public HashWorkItem(string directory, string file, bool isOriginal, int total, bool exactImageDataComparison)
  4.         {
  5.             _itemHash = 0;
  6.             _index = -1;
  7.             _fileName = file;
  8.             _directoryName = directory;
  9.             _isOriginal = isOriginal;
  10.             _total = total;
  11.             _compareExactImageData = exactImageDataComparison;
  12.         }
  13.  
  14.         private UInt32 _itemHash;
  15.  
  16.         public UInt32 ItemHash
  17.         {
  18.             get { return _itemHash; }
  19.             set { _itemHash = value; }
  20.         }
  21.  
  22.         private int _index;
  23.  
  24.         public int Index
  25.         {
  26.             get { return _index; }
  27.             set { _index = value; }
  28.         }
  29.  
  30.         private int _total;
  31.  
  32.         public int Total
  33.         {
  34.             get { return _total; }
  35.             set { _total = value; }
  36.         }
  37.  
  38.         private string _fileName;
  39.  
  40.         public string FileName
  41.         {
  42.             get { return _fileName; }
  43.             set { _fileName = value; }
  44.         }
  45.  
  46.         private string _directoryName;
  47.  
  48.         public string DirectoryName
  49.         {
  50.             get { return _directoryName; }
  51.             set { _directoryName = value; }
  52.         }
  53.  
  54.         private bool _isOriginal;
  55.  
  56.         public bool IsOriginal
  57.         {
  58.             get { return _isOriginal; }
  59.             set { _isOriginal = value; }
  60.         }
  61.  
  62.         private bool _compareExactImageData;
  63.  
  64.         public bool CompareExactImageData
  65.         {
  66.             get { return _compareExactImageData; }
  67.             set { _compareExactImageData = value; }
  68.         }
  69.     }

Nothing special there.
8637
Developer's Corner / Re: C# GDI+ Problem with byte[] and Bitmap - Memory Issues
« Last post by Renegade on January 20, 2011, 07:58 AM »
GetBytesFromBitmap() doesn't dispose of the MemoryStream?

I agree with Worstje you shouldn't allocate the 1x1 bitmap, just set it to null - you already have a null-check in your finally-block before disposing, anyway.

Also, iirc GDI+ is not properly re-entrant, so you'll have to be pretty careful there; dunno if it has to run on the UI thread, though.

The actual code right now is this:

Code: C# [Select]
  1. /// <summary>
  2. /// Get a byte array of pixel data from a Bitmap.
  3. /// </summary>
  4. /// <param name="bmp">The bitmap to get the pixel data from.</param>
  5. /// <returns>A byte array of pixel data from a bitmap.</returns>
  6. private static byte[] GetBytesFromBitmap(Bitmap bmp)
  7. {
  8.         byte[] result = null;
  9.         if (bmp == null)
  10.                 return result;
  11.         // Create a memory stream to hold the bitmap.
  12.         Thread.Sleep(500);
  13.         MemoryStream ms = new MemoryStream();
  14.         bmp.Save(ms, ImageFormat.Bmp);
  15.  
  16.         if (true)
  17.         {
  18.                 byte[] tmp = ms.ToArray();
  19.                 result = new byte[tmp.Length];
  20.                 tmp.CopyTo(result, 0);
  21.                 ms.Close();
  22.                 ms.Dispose();
  23.                 ms = null;
  24.                 bmp.Dispose();
  25.                 bmp = null;
  26.                 //GC.Collect();
  27.         }
  28.         else
  29.         {
  30.                 result = ms.ToArray();
  31.         }
  32.  
  33.         return result;
  34. }

I was trying to see if disposing of the MemoryStream worked to help fix things, but it makes no difference. The error still pops up in the same place.

For why the bitmap is constructed, and not just having memory allocated, I have that 2 posts above. (Catching up here...)

Also, iirc GDI+ is not properly re-entrant, so you'll have to be pretty careful there; dunno if it has to run on the UI thread, though.

I'm not sure what you mean.

But it's not running on the UI thread. Everything above is running from a threadpool like you can see in the QueueHashWorkItem method. Loop through and queue work items. Lots of them. Then sit back and wait for them... to crash~!  :'(  :o  :huh:

8638
Developer's Corner / Re: C# GDI+ Problem with byte[] and Bitmap - Memory Issues
« Last post by Renegade on January 20, 2011, 07:52 AM »
Mind you common sense is telling me to shutup ... But I just gotta ask...

In lines 37 - 43, why is hwi.CompareExactImageData being evaluated (basically) twice?

I'm reading it as:
if(condition = false) do bla
else if(same condition is not false) do bla

Wouldn't that tend to spike the work load?

Also being that there is no trailing else, then if condition is neither true or false (which granted should be impossible) Just ignore it. < I'm guessing that part was cut out for clarity)


It's a boolean, and doesn't make much difference. I simply put it there so that I could just type an else if I needed. The additional overhead is effectively nothing.
8639
Developer's Corner / Re: C# GDI+ Problem with byte[] and Bitmap - Memory Issues
« Last post by Renegade on January 20, 2011, 07:51 AM »
That makes no sense to me, sorry. FromFile() constructs a new bitmap object and returns it for as far I can see. If it weren't ever constructed, then how could you ever use the image you loaded? Unless I am a really big noob at .NET, there is no such thing as a reference to an object that isn't constructed. There's just 'null'.

(I think I messed up that post above a bit.)

Take a quick look back. You'll see the original bitmap is defined outside the try catch. In order to dispose of it, it must not be null, and must be constructed.

Bitmap bmp; only allocates memory, which at that point is just allocated memory and null. So I have to use "Bitmap bmp = new Bitmap(1, 1);" so that it's not null.

Here, like this:


Code: C# [Select]
  1. Bitmap bmp = new Bitmap(1, 1); // I actually release the bmp below with bmp.Dispose(), so init here
  2.  
  3. #region TRY block
  4. try
  5. {
  6.         bmp = (Bitmap)Bitmap.FromFile(hwi.FileName); // zero problems here
  7.         //
  8. }
  9. catch (OutOfMemoryException memEx)
  10. {
  11.         //
  12. }
  13. finally
  14. {
  15.         if (bmp != null)
  16.         {
  17.                 bmp.Dispose(); // ********* can't dispose of null
  18.                 bmp = null;
  19.                 GC.Collect(); // this makes no difference it seems
  20.         }
  21. }


But you're right - Bitmap.FromFile() returns a fully constructed Bitmap object.
8640
Developer's Corner / Re: C# GDI+ Problem with byte[] and Bitmap - Memory Issues
« Last post by Renegade on January 20, 2011, 05:20 AM »
I can't really test it, but assuming fragmentation is your problem, I think I see the problem you are dealing with. Mind you, I do not usually use GDI+, especially not in .NET, but I assume you have a good reason for using GDI+ as opposed to the System.Drawing classes. Hell, I have no clue how the GDI+ stuff is defined in that context.

Anyhow, on to what I think causes your problem. On line 29, you create a new Bitmap of 1x1 dimensions. The moment you go into the try {} block, you immediately call Bitmap.FromFile() and re-assign the value. In other words: you are creating an object you never use, and the garbage collector only collects that stuff when it feels like it - but at the same time extra objects mean less available continuous blocks. You do not need to create a Bitmap object in order to call FromFile as it is a static function. (See MSDN.) So, the solution ought to be as simple as initializing bmp to null.

I am not sure what all of your GC calls and the likes do. However, GDI+ is not managed, so I doubt tuning/prodding/abusing the GC will do very much for you in this case. But I could be wrong - I'm no .NET expert. :)

Thanks for taking a stab at it.

Underneath the hood, the System.Drawing.Bitmap uses GDI+... ;( So that's why it's there... ;(

The new Bitmap(1, 1) makes no difference. I put that in so that I could use the try... catch... finally... block because I'm having such a miserable time with this (normally I'd do it like you mention). i.e. In order to to dispose of bmp, it must be constructed first, and not just assigned -- see line 75 there.

I'm still no closer to solving this.

It plugs along fine, then all of a sudden just spins out of control and memory goes boom boom bang bang while I go boo hoo cry cry~! ;(

8641
Developer's Corner / Re: C# GDI+ Problem with byte[] and Bitmap - Memory Issues
« Last post by Renegade on January 20, 2011, 02:41 AM »
I think I'm closing in on a solution...

http://stackoverflow...t-heap-fragmentation

8642
Developer's Corner / Re: Skynet meets the Swarm: A fascinating article about AI.
« Last post by Renegade on January 20, 2011, 02:33 AM »
That was interesting. (The 'DC game' thread would benefit.)
8643
Site/Forum Features / Re: List of DC-SMF features?
« Last post by Renegade on January 20, 2011, 02:05 AM »
Interesting... There's quite a bit of nifty stuff in there.

(Testing the characters here:)

    • SMF
    • YaBB SE
    • SMF
    • YaBB SE
    • SMF
    • YaBB SE
    • SMF
    • YaBB SE
    • SMF
    • YaBB SE
    • SMF
    • YaBB SE
    • SMF
    • YaBB SE
    • SMF
    • YaBB SE
    • SMF
    • YaBB SE
    • SMF
    • YaBB SE
    • SMF
    • YaBB SE
    • SMF
    • YaBB SE
8644
Developer's Corner / C# GDI+ Problem with byte[] and Bitmap - Memory Issues
« Last post by Renegade on January 20, 2011, 12:58 AM »
Well, I'm still working on some requests for Duplicate Photo Finder, but I'm encountering some odd memory problems.

I'm getting "Out of memory" exceptions, and in particular, "A generic error occurred in GDI+".

If the above sounds interesting, read on, otherwise don't because it gets ugly.

I'm running through photos and processing them in threads in a threadpool. I basically queue up several hundred, then let it go.

What happens is that it very happily rips through the photos, then all of a sudden, memory usage spikes real quickly (over say 1~5 seconds), and then I get the GDI+ error. What's happening there is that I run out of memory. The application sucks up 200~500 MB while running (I have 8 GB of RAM), but when it spikes, it dies at 1 GB to 1.4 GB of RAM (from Task Manager).

During those few seconds when the program begins to blow up, the number of threads that it's working on triples out of the blue. It goes from 6~8 threads to BOOM! 24, 26, 28, 30, 31 CRASH~! It hits the GDI+ error.

I've run "memprofiler" and cannot locate any memory leaks. It tells me:

Disposed instance (Ignore...)
5 types have instances that have been disposed but not GCed.
Investigate the types below for more information.
System.Drawing.Bitmap, System.Drawing.Graphics, System.Drawing.Region, DeviceContext, WindowsFont

Instance queued for finalization (Ignore...)
One type has instances that are queued for finalization. This can indicate that a Finalizer method is stuck, which will prevent instances from being finalized and cause memory leaks.
Investigate the type below for more information.
DeviceContext

Pinned instance (Ignore...)
3 types have instances that are pinned in memory.
Investigate the types below for more information.
System.Object, System.Object[], System.String

Instance indirectly rooted by finalizer queue (Ignore...)
2 types have instances that are indirectly rooted by the finalizer queue. This can indicate that a Finalizer method is stuck, which will prevent instances from being finalized and cause memory leaks.
Investigate the types below for more information.
System.Collections.Stack, System.Object[]

Large instance (Ignore...)
2 types have instances that are located in the large object heap.
Investigate the types below for more information.
System.Byte[], System.Object[]

Undisposed instances (unclassified) (Ignore...)
16 types have instances that have been garbage collected without being properly disposed.
Investigate the types below for more information.
SafeTokenHandle, SafeWaitHandle, System.Drawing.Bitmap, System.Drawing.Font, System.IO.BinaryReader, System.IO.MemoryStream, UnmanagedMemoryStream, ResourceReader, RuntimeResourceSet, ExecutionContext, (...)


Here's enough code to see what's going on. I've edited it somewhat to make it shorter (e.g. remove Console.WriteLine & debugging stuff.)

Code: C# [Select]
  1. private void QueueHashWorkItem(DirectoryInfo di, bool isOriginal, int count, bool exactImageDataComparison)
  2. {
  3.         int indexer = -1;
  4.         foreach (FileInfo fi in di.GetFiles())
  5.         {
  6.                 if (fi.Extension.ToLower() == ".jpg")
  7.                 {
  8.                         indexer++;
  9.                         // HashWorkItem is a struct to hold info
  10.                         HashWorkItem hwi = new HashWorkItem(di.FullName, fi.FullName, isOriginal, count, exactImageDataComparison);
  11.                         hwi.DirectoryName = di.FullName;
  12.                         hwi.FileName = fi.FullName;
  13.                         hwi.Index = indexer;
  14.                         hwi.IsOriginal = isOriginal;
  15.  
  16.                         // get hashes in threads
  17.                         ThreadPool.QueueUserWorkItem(new WaitCallback(GetHashForItem), hwi); // see below
  18.                 }
  19.         }
  20. }
  21.  
  22. private void GetHashForItem(object state)
  23. {
  24.         // do the work
  25.         HashWorkItem hwi = (HashWorkItem)state; // This is a struct to hold information.
  26.         ImageConverter converter = new ImageConverter();
  27.         long pressure = new FileInfo(hwi.FileName).Length;
  28.         GC.AddMemoryPressure(pressure);
  29.         Bitmap bmp = new Bitmap(1, 1); // I actually release the bmp below with bmp.Dispose(), so init here
  30.  
  31.         #region TRY block
  32.         try
  33.         {
  34.                 bmp = (Bitmap)Bitmap.FromFile(hwi.FileName); // zero problems here
  35.                 byte[] bytes = new byte[1];
  36.  
  37.                 if (!hwi.CompareExactImageData)
  38.                 {
  39.                         // ****************************************************************
  40.                         bytes = (byte[])converter.ConvertTo(bmp, bytes.GetType()); // #0 THIS IS WHERE I GET THE GDI+ ERROR
  41.                         // ****************************************************************
  42.                 }
  43.                 else if (hwi.CompareExactImageData)
  44.                 {
  45.                         // ****************************************************************
  46.                         bytes = GetBytesFromBitmap(bmp); // #1 THIS IS WHERE I GET THE GDI+ ERROR -- See method below
  47.                         // ****************************************************************
  48.  
  49.                 }
  50.  
  51.                 SuperFastHashUnsafe sfh = new SuperFastHashUnsafe();
  52.                 hwi.ItemHash = sfh.Hash(bytes);
  53.  
  54.                 try
  55.                 {
  56.                         // invoke the delegate to store the results
  57.                         this.Invoke(new StoreHashResultsDelegate(StoreHashResults), hwi);
  58.                 }
  59.                 catch
  60.                 {
  61.                         // NEVER happens
  62.                 }
  63.         }
  64.         catch (OutOfMemoryException memEx)
  65.         {
  66.                 Console.Write("***** Out of memory: " + hwi.FileName + " *** " + memEx.Message);
  67.                 Thread.Sleep(2000);
  68.                 // queue the item again...
  69.                 ThreadPool.QueueUserWorkItem(new WaitCallback(GetHashForItem), hwi);
  70.         }
  71.         finally
  72.         {
  73.                 if (bmp != null)
  74.                 {
  75.                         bmp.Dispose();
  76.                         bmp = null;
  77.                         GC.Collect(); // this makes no difference it seems
  78.                 }
  79.         }
  80.         #endregion
  81.  
  82.         GC.RemoveMemoryPressure(pressure);
  83. }
  84.  
  85.  
  86. public delegate void StoreHashResultsDelegate(HashWorkItem hwi);
  87.  
  88. public void StoreHashResults(HashWorkItem hwi)
  89. {
  90.         // blah - here for reference - zero problems here
  91. }
  92.  
  93. /// <summary>
  94. /// Get a byte array of pixel data from a Bitmap.
  95. /// </summary>
  96. /// <param name="bmp">The bitmap to get the pixel data from.</param>
  97. /// <returns>A byte array of pixel data from a bitmap.</returns>
  98. private static byte[] GetBytesFromBitmap(Bitmap bmp)
  99. {
  100.         byte[] result = null;
  101.         if (bmp == null)
  102.                 return result;
  103.         // Create a memory stream to hold the bitmap.
  104.         MemoryStream ms = new MemoryStream();
  105.         // ****************************************************************
  106.         bmp.Save(ms, ImageFormat.Bmp);  // #2 THIS IS WHERE I GET THE GDI+ ERROR
  107.         // ****************************************************************
  108.         result = ms.ToArray();
  109.  
  110.         return result;
  111. }

Does anyone have any ideas how to troubleshoot that?

I've spent about 2 days on this and I'm not getting anywhere.

I've run around looking into everything I can, including LHO (Large Heap Objects), but so far no joy.

BTW - I'm running through directories of photos that are around 4~7 MB each (10 MP camera JPGs) with around 500 photos per directory. The program craps out randomly, sometimes ripping through 200, or 300 or 400 or 500 before dying. Directories are around 3 GB.

Any ideas, pointers or whatever would be appreciated.

Hey, and just for fun, I'll put a $10.00 donation bounty on it for the first person to point me to a solution~! :D

8645
Sim, puzzle, TD, racer, platform... so many choices...

http://www.visual3d.net/

http://www.devmaster.net/engines/  <<< EVERYTHING is listed here.

http://vortex2d.codeplex.com/
http://www.vortex2d.net/

http://about.wildtangent.com/partner

http://unity3d.com/

There are a LOT of options out there...

8646
Yeah, RPG is probably a bad idea. But what about other smaller-scale projects?

Platformer, racing games, Metroidvania (kind of a platformer), Adventure (think Zelda), etc.? (FYI I'm thinking of all of these as 2D games)

I think you're bang on there.

The best course of action, as I see it, is to look into game engines first. Developing a new game engine is just a really, really stupid idea. Why reinvent the wheel?

There are lots out there.
8647
TD lets you start small. A full RPG is simply a bad idea. A smaller game to start with lets you get a team working well first. Later, a bigger project is more reasonable.

i.e. Make sure your first goal is to touch the tree-tops while you're reaching for the stars.
8648
In what way(s) could people contribute to a tower defense game? Obviously coders could help program, artists could make graphics, and musicians could help with music or maybe sound effects, but in what other ways would someone be able to contribute to a TD game?

Level design. Game mechanics. There's lots.

On the coding side, there are a lot of different skill sets here at DC. How would/could/should things be setup to let the maximum number of people participate?

I am a bit bias, but .NET would let anyone write in any language and the core game could then consume libraries (DLLs). It would also allow for specialized things like DSP or math-heavy stuff to be done in a functional language like F#, while other things were done in C++ or whatever.

Just an idea anyways.
8649
You can have your buttons, just don't take away my syntax!  It's easier for me to keep typing inline rather than have to highlight a phrase and click a button.
I don't think that's a true statement.  You are more COMFORTABLE typing inline, or you PREFER to type like that.  But it's not easier by any means for you, him, or any other person.  There's no argument you can make to convince me that it's easier to type a word with brackets or whatever vs. clicking a single button.

At the risk of sounding rude, I've heard from programmers that they use all this text editing stuff because it's easier for them.  This is not true.  you can't say that because the alternative (buttons) doesn't even exist!  You can't say one way is easier or better when the other way is not even available!  So, in my opinion, the programmers sort of lie to themselves by saying it's better this way, but it's not.  What they are really saying is that it's not worth the trouble to create a button, which is true in a lot of ways.  It is easier to write code (if you know it) than it is to create a button, which is essentially writing a LOT of code and going through the whole troubleshooting of it, etc.  So yes, text-editing is easier compared to writing the code for a button.

But text-editing is definitely NOT easier than clicking a button.  Two different things.

OOOOOOOO~! A challenge~!

Ok... let's convince you...

Ever see someone that's a whiz with vi? Well, in addition to being socially inept and sexually frustrated, they're also blistering fast. There isn't a hope in hell that you could possibly hope to accomplish the same tasks with a mouse.

Now, if I'm going to post an image here, it's FAR easier for me to type the [ img ] tag and paste a URL than it is to click a button, fart around with some interface and whatever else I need to do. In both cases I'll end up pasting the image URL, so those make no difference to the procedure. So... Consider:

THE GUI WAY:
1) Move hand from keyboard to mouse.
2) Figure out WTF the cursor is on the screen
3) Locate "image" button on toolbar
4) Move mouse cursor to toolbar image button
5) Click image button
6) Wait for some window to pop up
7) Locate URL field in popup for image URL
8) Move mouse to URL field
9) Click URL field to give it focus
10) *** Paste image into URL field
10.1) Since typing is hard, make things further painful, but avoid pain of moving hand between keyboard and mouse
10.2) Right-click in URL field
10.3) Click "Paste" option in context menu
11) Click OK button in popup

THE KEYBOARD WAY
1) Type img open tag
2) CTRL + V to paste image URL
3) Type img close tag

Clicking buttons is often more difficult because you have to move your hand from the keyboard to the mouse, find the cursor, look around, and by that time your ADHD has kicked in and you're thinking about lunch or going out for a cigarette!

***  cig =========:::~  ***

Back...

Now where was I?

Oh yeah...

Try this experiment... Tweet 5 times however you normally do, then try tweeting 5 times with my little Twiddle Twittle Tweeter for Twitter:

Twiddle Twittle Tweeter for Twitter

When you tweet with it, use the keyboard shortcuts:

In your browser (Firefox) -- use F6 to focus on the address bar then CTRL + C to copy it all.

From anywhere at all, like your browser, you can use T4 like this:

CTRL + ALT + S ==> Show/focus
Type whatever.
CTRL + ALT + B ==> Paste a shortened URL
CTRL + ALT + T ==> Tweet

Tell me which is faster then. (Don't include time to download, installation, or starting the program. :) )

Here's the help info:

http://renegademinds...19/Default.aspx#help

You simply can't move your hand between the keyboard and your mouse fast enough. It's just not possible for simple things.

If you know what you want to do, the keyboard is MUCH faster, and hence, easier. If you're waffling on what you're doing, it makes no difference, and likely then the mouse is easier.

Q.E.D. ??? ;)

I use both the keyboard and mouse, but it really all depends on what you want to do. Very often the keyboard *IS* much faster and easier.

ED: Typos :P
8650
Living Room / Re: How to Get the Most Out of Your Laptop with Linux
« Last post by Renegade on January 19, 2011, 05:40 AM »
Timely!

I've been thinking about doing something with my laptop as I use it rarely now.
Pages: prev1 ... 341 342 343 344 345 [346] 347 348 349 350 351 ... 438next