Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
thedo  
#1 Posted : Sunday, October 4, 2009 11:51:11 PM(UTC)
thedo

Rank: Newbie

Groups: Member
Joined: 7/16/2009(UTC)
Posts: 7

I was wondering if there was an equivalent constructor to this one in the System.Drawing.Bitmap?

public Bitmap(
int width,
int height,
int stride,
PixelFormat format,
IntPtr scan0
)

in Aurigma?

My scenario is thus - In an effort to manage memory more efficiently weve been trying various techniques to minimise RAM usage, primarily by swapping things in and out of memory as much as possible (we're running into memory issues with 15Mpixel+ images).

So for example, when we want to process an image - say add a brightness filter, we

Load the Image (either from disk, or from a byte array holding the source jpeg bytes (therefore is quite small))
Process the Image (add the filters)
Copy the image to a WPF BitmapImage
Dispose of the Image

However, using the GDI+ constructor above we can load much larger images, as we can essentially map the data to a file. The Memory still shows as part of the process space, but takes up FAR FAR less private bytes (measured using Performance Counters).

So we

Load the image initially
Lock it
Copy the bytes to a file (essentially uncompressing the data to a flat file)
Discard the original image object
Call the unmanaged APIs CreateFileMapping and MapViewOfFile
Create a new System.Drawing.Bitmap object using the above constuctor, passing the result of MapViewOfFile to the scan0 parameter.

This seems to be dramatically helping our memory situation. However, Aurigma obviously has a lot of filters which we dont really want to re-implement!


Is there any way to support this scenario using Aurigma? I can see we can copy an Aurgima Bitmap to a Systm Bitmap directly, however the other way always seems to do a deep copy, which ends up loading the Aurigma version to RAM.

Any thoughts?
Alex Kon  
#2 Posted : Monday, October 5, 2009 7:48:35 PM(UTC)
Alex Kon

Rank: Advanced Member

Groups:
Joined: 1/31/2005(UTC)
Posts: 458

Was thanked: 5 time(s) in 5 post(s)
Hello,

Yes, I have to confirm that scenario with file mapping doesn't work with Graphics Mill. All our Bitmap objects are working only with buffers allocated inside Graphics Mill DLL.

The only way to apply Graphics Mill effects to such mapped bitmap is to map it part by part, convert each part to Aurigma Bitmap, transform and copy it back to mapped System.Drawing.Bitmap. It doesn't sound inspiring, but unfortunately I don't see any alternatives.

Best regards,
Alex Kon
thedo  
#3 Posted : Tuesday, October 6, 2009 12:16:11 AM(UTC)
thedo

Rank: Newbie

Groups: Member
Joined: 7/16/2009(UTC)
Posts: 7

Shame.

I was assuming that given you can make a System.Drawing.Bitmap based on the same block of memory as the Aurigma.GraphicsMill.Bitmap.

Unfortunately tiling wont work in my solution.

We're using WPF to display images, so using MapViewOfFile we are able to create a System.Drawing.Bitmap based on that memory chunk, and use an InteropBitmap to use the same memory chunk. By modifiying the Bitmap bits, we are able to directly modify the WPF image, as well as only store 1 copy, whereas other methods require 2 copies - a WPF copy and a GDI+ copy. The MapViewOfFile API effectively halved our bitmap memory usage - which is pretty handy with 15Mpixel+ images!

Hey ho.
Alex Kon  
#4 Posted : Wednesday, October 7, 2009 1:05:52 PM(UTC)
Alex Kon

Rank: Advanced Member

Groups:
Joined: 1/31/2005(UTC)
Posts: 458

Was thanked: 5 time(s) in 5 post(s)
Hello,

Hm, I think that maybe it is possible to create System.Drawing.Bitmap based on the same memory chunk, as Aurigma.Bitmap. But the converse is false, and that is the problem.

I'm sorry, but tiling is the only approach I can suggest.

Best regards,
Alex Kon
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.