|
I had a first look at the stuff, and I sure see one problem, which as you thought is related to the Format24bppRgb format.
This format requires three Byte s for each pixel (red, green, blue), while you provide three UInt32 .
Try to make your RGBArray a Byte array, and you'll probably be done.
I'll have a deeper look anyway, and see if what I said is ok and if there's anything else to fix.
2+2=5 for very large amounts of 2
(always loved that one hehe!)
modified on Friday, August 7, 2009 6:16 AM
|
|
|
|
|
Thanks for looking - I just came home from work and changed what you suggest.
The result is an overflow exception in the lines "RGBArray(i) = (buff And &H3FF)" etc., in which I then try to put a 10-bit value (held in buff which is UInt32, right?) into a single byte (8 bits). How would I correctly downconvert the result of the line into a byte? My silly approach to return 8/10th of course lead to an overflow exception, too...
BTW: I hope you had enough other stuff to do today and didn't drown in all the possibilities to fix
|
|
|
|
|
In order to convert your 10 bits values to 8 bits, you must simply lose the two least significant bits (which is the same as dividing the value by 4):
RGBArray(i) = (buff And &H3FF) >> 2;
RGBArray(i + 1) = (buff And &HFFC00) >> 12;
RGBArray(i + 2) = (buff And &H3FF00000) >> 22;
Try this and you should be doing fine with a Byte array.
2+2=5 for very large amounts of 2
(always loved that one hehe!)
|
|
|
|
|
Hello Michael,
I did not read the whole document about the Cineon File Format, but did a similar research about a image format of a vision mixer's still store (Kahuna) recently. There where the colors also 10 bit (this is common in broadcasting video) but the color was not in RGB but in YUV-format. If you have strange colors, when you are done, start investigating in this direction.
By the way: you should not open your cineon file as a bitmap, but as a byte-array (as suggested), then you could get the three 10-bits out of the 32-bit integer, without GDI+ confuses you. Then alocate a 24-Bit (RGB) Bitmap and use something like setpixel (for testing only, is very slow) to write your converted RGB-values to the bitmap.
To get around the slow setpixel look for articles about manipulating bitmap directly using 'dirty-buffers', but not before you see a picture with the slow method...
Hope to help you find your way, good luck:
Didi
|
|
|
|
|
Thank you, Didi!
I could't open dpx as bitmap anyway, so creating a byte array was my only solution. I had some strong support from Moreno (off-forum) explaining me how to extract the bits in the right way. When allocating 24-Bit RGB Bitmap, as you suggest, a somehow recognizable picture shows up at least...
Here's where we're stuck at the moment. The resulting RGB values make sense in some way (a certain pixel we analyzed e.g. has 132/176/134 while correct RGB values are supposed to be 33/44/33), but the picture shown is completely false colored... a bit like taken by a thermal sensor but heavily green in addition DPX has so many different possibilities to hold a bitmap: it could be YUV, RGB, LIN, LOG and much more... Obviously the Cintel scanner puts 'transfer = 3' (meaning LOG) into the header despite the operators SWEAR it can only be a linear RGB in the data, coz they didn't even install the hardware needed to scan LOG format.
Confusion is resulting about the proper interpretation of the data. Moreno thinks I'll have to take it as a fact that it's LOG data and go compute a LUT. I still wish I could avoid it, believing the operators... because doing that I might have to dig into C++ which scares me a bit - all I want to do is convert a particular source picture, finally, and not analyze all the different kinds of DPX.
Did you probably find a way in your project how to erase that kind of doubts and clearly determine which colorspace and type the dpx is?
Regards
Mick
|
|
|
|
|
Hi Mick,
my project was not DPX, but a internal format of a Vison mixer, but it used also 10 bit...
I looked at google to see, if there is an open source library to read DPX files and found GraphicsMagick[^] probably this could be a solution, there are different bindings including a COM object, that you should be able to use from VB.NET.
Regards: Didi
|
|
|
|
|
Hi Didi,
yeah, I'm trying with the GM Source also - the problem is
a) it's C++ which I'm fully unable to understand and
b) in the needed conversion function it's considering so many details like e.g. all the different formats and colorspaces that even for understanding I have to jump from one function to the other trying to read it --> problem a
Thank you still, and have a nice day
Mick
|
|
|
|
|
Hi Mick,
would not try to go into the sources, just use ImageMagick in VB.NET[^] should be enough.
Regards: Didi
|
|
|
|
|
Hi Didi,
I had played around with that one some time ago (before trying to convert the file data myself) and gave up after a while because I didn't get the source compiled. Now I see they obviously added the DLLs, so probably I'll use it (i.e. try again). At least much more realistic to get a grip on than starting C++ studies and that makes me happy
Thanks for the reminder, anyway!
Have a nice weekend
Mick
|
|
|
|
|
Hi again, Didi!
Stepping through the instructions I managed to build the dll and have the path to the other dll's corrected, so an image is shown in my picturebox. Unfortunately, after approx. 30 seconds, the solution throws an 'OutOfMemoryException' without any additional hint where exactly it would happen. The same effect occurs running the sample solution included with the article, so I figure it happens somewhere in the wrapper dll.
I found a respective question from 2008 in the posts of the article, but it remained unanswered. Did you by any chance solve that problem OR successfully update the wrapper as described with a subsequent version of ImageMagick? It might be an older bug of IM that's been erased for a long time, but despite of many attempts I didn't manage to compile with an updated source.
Thanks for now,
Mick
EDIT: After some experiments I found that this error doesn't happen loading standard size (1920 * 1080) DPX files, only when loading 2k-DPX (2048 * 1536 or 2048 * 1556)!
modified on Sunday, August 16, 2009 4:51 AM
|
|
|
|
|
Hi Mick,
actualy I must say, that I did no use the library myself, just googled it for you as an idea to easier find your way...
Probably you can try the .NET bindngs here[^] it says, that it is a continuation of the work on code project...
Good luck: Didi
P.S. Wo in Deutschland wohnst Du? Ich bin aus der Schweiz...
|
|
|
|
|
|
With some strong support I figured out the necessary changes. Here they are for others who might be interested:
1. The displayImage function has to be slightly changed: The former function 'MakePixelArray' has been replaced by a function that returns a byte array, holding 3 bytes for each pixel (RGB). As a consequence, the PixelFormat has to be adapted:
Public Sub DisplayImage(ByVal PicFile As FileInfo, ByVal ImageOffset As UInteger, ByVal Width As UInteger, ByVal Height As UInteger)
Dim arrayImage() As Byte = MakeRGBArray(PicFile, ImageOffset) <--- changed routine
Dim gch As GCHandle = GCHandle.Alloc(arrayImage, GCHandleType.Pinned)
Dim pBuf As IntPtr = gch.AddrOfPinnedObject
PictureBox1.SizeMode = PictureBoxSizeMode.Zoom
PictureBox1.Image = New Bitmap(Width, Height, 3 * Width, Imaging.PixelFormat.Format24bppRgb, pBuf) <--- changed pixel format
gch.Free()
End If
End Sub
2. MakeRGBArray reads a UInteger for each Pixel and swaps the bytes first. With a bit-mask and a bit-shifting operation, the padding of the Uinteger (32 bits for 3 * 10 bits RGB) is eliminated, the 10-bit-values read and converted to 8-bit:
Private Function MakeRGBArray(ByVal PicFile As FileInfo, ByVal ImageOffset As UInteger) As Array
Dim ft As FileStream = New FileStream(PicFile.FullName, FileMode.Open)
Dim brh As BinaryReader = New BinaryReader(ft)
ft.Position = ImageOffset ' start with first pixel after the header
Dim RGBArray(CInt((PicFile.Length - ft.Position) / 4 * 3) - 1) As Byte
For i = 0 To (RGBArray.Length - 1) Step 3
Dim buff As UInt32 = SwapDWORD(brh.ReadUInt32)
' bit-shifting operation
RGBArray(i) = (buff And &HFFC) >> 4
RGBArray(i + 1) = (buff And &H3FFFFC) >> 14
RGBArray(i + 2) = (buff And &HFFFFFFFC) >> 24
Next i
ft.Close()
brh = Nothing
ft = Nothing
Return RGBArray
End Function
Maybe it helps someone else. Special thanks to Moreno for the basic idea and perfect offline support!
|
|
|
|
|
hi guys,
im trying to develop an application in which i used a combobox and datagridview in visual basic. I want to clear old content of datagridview before i populate with new ones when combobox.selecteditem changes.i add data to datagridview manually(programmatically). I don't use datagridview datasource property.
when i tried to use datagridview1.rows.clear or dataset.tables.clear, it doesnot clear. rather it duplicates data by adding old and new data to datagridview.i searched on web but i couldn't find an answer, any help? thank you so much in advance for any help. My sample code looks like the following
DataGridView1.Rows.Clear()
c.da = New SqlDataAdapter(userdata,userconn)
c.da.Fill(c.ds, "usertable")
'c.ds.GetChanges()
c.custView = New DataView(c.ds.Tables("usertable"), "", "studid", DataViewRowState.CurrentRow For c.rowIndex = 0 To c.ds.Tables("usertable").Rows.Count - 1
Dim row0 As String() = {c.custView(c.rowIndex)("column1").ToString, c.custView(c.rowIndex)("column2").ToString, c.custView(c.rowIndex)("colum3").ToString, c.custView(c.rowIndex)("colum4").ToString}
With Me.DataGridView1.Rows
.Add(row0)
End With
Next
modified on Thursday, August 6, 2009 10:25 AM
|
|
|
|
|
Set the DataSource of the DataGridView to null.
You should update the Filter property of the BindingSource in the SelectedIndexChanged event of the ComboBox if you you have a single datasource and filtering out the records to display on the basis of the user selection.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
hi d@nish
i am not setting the data source of datagridview using the datasource property, rather i am setting manually(programmatically), so i can't use bindingsource control. sorry may be 'cause i am stupid.
|
|
|
|
|
Try Remove method of the datagridview row.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
thank u guys,
i got the solution to my problems
|
|
|
|
|
I was Completed my program. when I try to build setup package then below error was appeared now I can't run program please help me.
I copied from Error list Clip board. It not mention Line and Column.
The "ResolveComReference" task failed unexpectedly.
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Server stack trace:
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Microsoft.Build.Framework.ITask.Execute()
at Microsoft.Build.BuildEngine.TaskEngine.ExecuteTask(ExecutionMode howToExecuteTask, Hashtable projectItemsAvailableToTask, BuildPropertyGroup projectPropertiesAvailableToTask, Boolean& taskClassWasFound)
|
|
|
|
|
In my experience the quickest solution to problems like this, is to delete the setup project from your solution, and add a new one.
My advice is free, and you may get what you paid for.
|
|
|
|
|
Hi All,
I have a question for Monitoring E-Mail Account (like : Gmail,Yahoo etc).
I wanaa try to monitor my E-mail Account and other Email account. How can it possible pls suggest ?
Thanks
If you can think then I Can.
|
|
|
|
|
What do you mean by monitor?
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
Here's a start[^]
If at first you don't succeed ... post it on The Code Project and Pray.
|
|
|
|
|
Hello everyone
this is my first time here and i am very new to VB
I have a temperature Sensor and i got that to work
but my question is how can i have it disply 1 number after the deciaml like this 25.5oC insted of 25.345oC
i have been all day on this and i just cant get this one please help
Thare is my code for the Temp Sensor
Private Sub phidgetIFK_SensorChange(ByVal sender As Object, ByVal e As Phidgets.Events.SensorChangeEventArgs) Handles phidgetIFK.SensorChange
Dim temperature As String
phidgetIFK.sensors(0).Sensitivity = 2 '
temperature = ((phidgetIFK.sensors(0).Value * 0.2222) - 61.111)
txtNumSensors.Text = temperature.ToString()
End Sub
Thanks in advance
Y
|
|
|
|
|
You can use the Format method on the string class to specify how many decimal places to use.
Dim strPrice As String = dblPrice.ToString("0.0")
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|