Aurigma Forums
»
Legacy Products
»
Archive
»
Other Products
»
Converting from JPEG to "raw", then from "raw" to JPEG
Rank: Member
Groups: Member
Joined: 8/31/2004(UTC) Posts: 4
|
Please pardon my ignorance/inexperience
I'm attempting to use Graphics Mill in conjunction with the Digimarc (digital watermarking) SDK to embed digital watermarks in JPEG files. The problem is that my original is in JPEG format but the Digimarc SDK will only accept raw/uncompressed image data. Here is what I think I have to do:
1. load the JPEG file into memory 2. uncompress the JPEG 3. save the uncompressed version to a memory buffer 4. pass the memory buffer to the Digimarc SDK (to embed the watermark) 5. save the watermarked, uncompressed buffer back to a JPEG
Can anyone point me to the proper Graphics Mill methods for steps 1,2,3 and 5?
Thanks
|
|
|
|
Rank: Advanced Member
Groups: Member, Administration Joined: 8/2/2003(UTC) Posts: 876
Thanks: 2 times Was thanked: 27 time(s) in 27 post(s)
|
Graphics Mill provides two ways to get uncompressed data: 1. You can use high-level Pixels(column, row) property to get pixel by coordinates. Of course it is extremely slow, but easy to use. The usage is simple: Code:objBitmap.Data.Pixels(i, j) = lngColor ' Writing color into pixel
lngColor = objBitmap.Data.Pixel(i, j) ' Getting color from pixel
2. You can get a pointer to the pixels and manipulate directly on memory. These properties can be used: Code:objBitmap.Data.Scan0 ' Pointer to the beginning of the pixel data.
objBitmap.Data.Stride ' Offset between bitmap rows (in bytes)
objBitmap.Data.Height ' Number of bitmap rows (height)
objBitmap.Data.Width ' Number of bitmap columns
objBitmap.Data.MemoryUsed ' Size of buffer which is needed to keep a copy of pixels (in bytes)
Here is a link to a sample of using of these properties: Creating Custom EffectsAs for steps 1/2 and 5 - it is simple, just use LoadFromFile and SaveToFile methods. What language are you writing on? Is it C++ or VB (or anything else)? Edited by user Tuesday, December 15, 2009 10:54:20 AM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Member
Groups: Member
Joined: 8/31/2004(UTC) Posts: 4
|
Thanks Andrew - I'm going to try the Scan0 approach. I'm actually using C# and calling Graphics Mill via the COM Interop mechanism of .NET> Edited by user Monday, December 24, 2007 4:52:20 PM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Advanced Member
Groups: Member, Administration Joined: 8/2/2003(UTC) Posts: 876
Thanks: 2 times Was thanked: 27 time(s) in 27 post(s)
|
By the way, you may be interested in beta testing upcoming Graphics Mill 3.0 for .NET. Unlike Graphics Mill 2.0, this one is a pure .NET component, thus it does not require to use COM Interop for this...
|
|
|
|
Rank: Member
Groups: Member
Joined: 8/31/2004(UTC) Posts: 4
|
Thanks for the head's up on the .NET version. We may be interested in a month or two. Regarding Scan0, am I correct in thinking that it returns the address of the first byte in the image? I'm writing a C++ wrapper around the Digimarc API so that I can call the Digimarc routine from C#. Digimarc wants to refrence the image data via "unsigned char *" and I'm thinking I should just be able to pass the Scan0 result into the Digimarc api, but its not working (I get a null reference exception). I realize Digimarc is not your product, but I'm hoping you could give me some info on how to get from the long value returned by Scan0 to the "unsigned char *" required by the Digimarc API. Thanks for any help you can provide //C# client Code:GraphicsMill.BitmapClass gmImageIn = new GraphicsMill.BitmapClass();
gmImageIn.LoadFromFile ("myPic.jpg");
int imPtr = gmImageIn.Scan0;
int err = DigimarcWrapper (imPtr, gmImageIn.Stride);
//C++ wrapper Code:int DigimarcWrapper (int pDataPointer, int pBytesPerRow)
{
...
typedef struct _dwm_imagedesc
{
unsigned char *pData;
short BytesPerRow;
...
} DWM_IMAGEDESC
DWM_IMAGEDESC ImgDesc;
ImgDesc->pData = (unsigned char *) pDataPointer;
ImgDesc->BytesPerRow = (short) pBytesPerRow;
return DWM_Embed (&ImgDesc); //<<-- null reference exception occurs here
}
Edited by user Monday, December 24, 2007 4:52:43 PM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Advanced Member
Groups: Member, Administration Joined: 8/2/2003(UTC) Posts: 876
Thanks: 2 times Was thanked: 27 time(s) in 27 post(s)
|
This simple code snippet fills all pixels with 0 (black): Code: GraphicsMill.BitmapClass bmp = new GraphicsMill.BitmapClass();
bmp.LoadFromFile(@"d:\[test files]\pictures\andrew.jpg");
unsafe
{
//System.IntPtr ptr = new System.IntPtr(bmp.Data.Scan0);
int ptr = bmp.Data.Scan0;
for (int i=0;i<bmp.Data.MemoryUsed;i++)
{
((byte*)bmp.Data.Scan0)[i] = 0x00;
}
}
bmp.SaveToFile(@"d:\1.jpg");
I just tested this code and it worked properly. As for your code, try to check other fields of the ImgDesc structure. Probably it requires some other pointer there. BTW, what DWM_Embed is? Is it a Digimarc function or your one? Could you send an extract from this function reference (if it is not forbidden with license agreement for Digimarc of course)? Edited by user Monday, December 24, 2007 4:52:56 PM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Member
Groups: Member
Joined: 8/31/2004(UTC) Posts: 4
|
One more question on this - Digimarc has an attribute called "BytesPerRow" which they define as "the offset between rows of the image data". I assume that this is the same thing as Aurigma's "stride" property, but maybe that's not correct?
BTW the DWM_Embed is a Digimarc function. I spoke with Digimarc and if you're willing to sign a non-disclosure agreement they will permit me to send you the documentation.
|
|
|
|
Rank: Advanced Member
Groups: Member, Administration Joined: 8/2/2003(UTC) Posts: 876
Thanks: 2 times Was thanked: 27 time(s) in 27 post(s)
|
> One more question on this - Digimarc has an attribute called "BytesPerRow" which they define as "the offset between rows of the image data". I assume that this is the same thing as Aurigma's "stride" property, but maybe that's not correct?Yes, stride is a number of bytes per one scanline. In fact it is an offset between beginnings of rows. > BTW the DWM_Embed is a Digimarc function. I spoke with Digimarc and if you're willing to sign a non-disclosure agreement they will permit me to send you the documentation.Please submit case for this. Edited by user Friday, May 23, 2008 3:51:08 PM(UTC)
| Reason: Not specified
|
|
|
|
Aurigma Forums
»
Legacy Products
»
Archive
»
Other Products
»
Converting from JPEG to "raw", then from "raw" to JPEG
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.