|
Lookup "Automation: Overview" in MSDN.
|
|
|
|
|
I will also be venturing into exactly this in a little while with my app.
Have a look at the Automation[^] section here at CP. The articles should give you a good intro on whats involved.
[EDIT]must remember to reply to original sender!! Sorry Josh![/EDIT]
I Dream of Absolute Zero
|
|
|
|
|
see prev ^ post.
I Dream of Absolute Zero
|
|
|
|
|
Hi all,
I am working on converting some images into BMP format and the given images are in *.LL1 and *.LT1 formats. After converting them into BMP I have to display them in an interface that I am goin to build. (i.e when I select an Image file of any of those two formats fromt he 'open' menu item then it should display the image on a seperate window after doing all the process of changing the format into BMP.
Anybody having ideas or suggestions of how to convert an image format in VC++, plz lemme know and I appreciate ur help.
I hope I am clear in problem description.
thanks in advance,
Pavan.
Pavan
|
|
|
|
|
There are image libraries such as devIL (a.k.a openIL), FreeImage and this one:
[^]
Some of these are hard to set up, I haven't been having much luck anyway but it's a place to start. Also will parse and load many files and allow saving, but I haven't seen if they support *.LL1. I used openIL to convert formats.
As far as displaying images there are many ways to do that. From the Doc\View architecture you can override the OnDraw() method and draw the image if you have access to the raw pixels (which you have loaded with some image library). If you have a bitmap you can also use the Picture Control and I believe you can call .SetBitmap() but I don't remember the details.
That's my attempt.
|
|
|
|
|
Hi,
thanks a lot on providing that info and I will try to use it.
In the meanwhile can you tell me how we can read an image in vc++, not just reading it, but wht i am talking abt is after reading how can we access the data in the image (like in Matlab, where we can read the image and can access the intensity value for any pixel directly) in an array format. Becos i want to do some image processing techniques on the image I am reading where i need each pixel's info.
thanks,
Pavan.
Pavan
|
|
|
|
|
Read my GDI+ articles here on Code Project. They tell you all you need to know. If you can't use GDI+, use a DIBSection wrapper, there are several on the site as well.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hi,
Thanks for ur valuable info ... actually I am not able to find the file 'psdk-common.11.cab ' at the microsoft ftp site. can u tell me from where i can get it.
thanks,
Pavan.
Pavan
|
|
|
|
|
The cab is inside the SDK. What compiler do you have ? Any .NET compiler has the GDI+ headers and libs in it's default SDK. otherwise, you need to download and install a platform SDK to get them for VC6.
I strongly advise against trying to install just the GDI+ part of the SDK, you should install the whole thing.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hi,
I have downloaded whole SDK and installed it on my PC and i am working on it.... in the meanwhile can you tell me anything abt my previous message
"how we can read an image in vc++, not just reading it, but wht i am talking abt is after reading how can we access the data in the image (like in Matlab, where we can read the image and can access the intensity value for any pixel directly) in an array format. Becos i want to do some image processing techniques on the image I am reading where i need each pixel's info."
thanks,
Pavan.
Pavan
|
|
|
|
|
Like I said, read my articles on GDI+. The image processing ones are probably all in C#, but the syntax for C++ will be similar, and the methods you call will be the same.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hi all,
thank you very much Mr.Graus, the information u have provided really helped me a lot.
Here is another problem that I am having, I am working on converting some images into BMP format and the given images are in *.LL1 and *.LT1 formats. After converting them into BMP I have to display them in an interface that I am goin to build. (i.e when I select an Image file of any of those two formats fromt the 'open' or 'Load' menu item then it should display the image on a seperate window after doing all the process of changing the format into BMP.
Anybody having ideas or suggestions of how to convert an image format in VC++, plz lemme know and I appreciate ur help.
I hope I am clear in problem description.
thanks in advance,
Pavan.
|
|
|
|
|
I have no idea what an LL1 or an LT1 format looks like, you need to get ahold of a specification of those formats, then you can work out how to decode them.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hi Mr.Graus,
Hmm, actually I don't know what information we need inorder to convert the format. But, I am having some information of those header files and it is as under
IFFCL_GRAY {
bits: 12
byte: @0=0x00
byte: @1=0x00
byte: @2=0x00
byte: @3=0x00
width:[@6=ishort]/2
height:@4=ishort
start_offset:128
line_offset:width*2
datatype: lsb_msb
}
this is wht I am having about them. If u need a sample file of those formats I can send u to ur mail if u can provide me with it (their size is around 8MB to 10MB each). If u know, if anymore details would help us in converting the formats.
One more doubt is, in your application of CSharpFilters, in Form1.cs I am not understanding how u r defining the Zoom menu items as
private void OnZoomXY(object sender, System.EventArgs e)
while for other menu items u r defining as
private void menuitem_menusubitem(object sender, System.EventArgs e)
thanks a lot,
Pavan.
Pavan
|
|
|
|
|
The names of the menu items is irrelevant. I just didn't prettify them all when I was putting the code together
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hi Graus,
Sorry to disturb u again... I am having a problem while writing a program on image processing and I did refer your articles on them and they r very helpful. But, wht i am having is I ahve to read an image (which I did) and then I ahve to scan the image from 2nd row, second pixel (imagine the image as an 3D array of values [RGB]) and I have to consider all its neighbouring pixels (means we get a total of 9 pixels considering the center pixel) and then I have to some image processing techniques on it.
Especially can u tell where u r reading the 3X3 matrix ( i hope it is ConvMatrix class and u r creating an instance of that in each technique, but i didn't get how u r using one instance of that clas and performing the operation on whole image) in your program and how u r applying any image processing method on the matrix for the whole image (passing over the image from right to left and then top to bottom), I mean how u r updating ur convolution matrix for each pixel.
I hope I am bothering u very much and i am vey sorry for that.
thanks a lot,
Pavan.
Pavan
|
|
|
|
|
The matrix is applied to each pixel in the image in the nested loop that steps through the x and y values. Each iteration of the loop is stepping through the matrix, working out pixel locations relative to the core pixel being modified, which is decided by the two x and y loops.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hi Graus,
Thanks a lot and I have figured out ur code and understood. U did a great job in writing those tutorials which helped me a lot and I am waiting for this kind of tutorials from atleast 2-3 months.
Have u got any idea or figured out how to change the image format. Did u get any sense from the header info that i have given (I am not getting wht it is). Actually I dont know how images r converted from one format to another (not talkin abt the formats tht i am having). If u have any general idea let me know.
thanks a lot for ur help,
Pavan.
Pavan
|
|
|
|
|
Pavan Kumar N Tiruveedhula wrote:
Actually I dont know how images r converted from one format to another
Well, they are converted by code. A bitmap is raw data, it's stored exactly the way I iterate over it. Different formats compress that data, or add extra data, or store the data differently. So you need to know how a format works in order to write code that translates it into another known format. I have no ideas with regard to the format you're looking at, sorry. Have you tried to google it ? Where do these files come from ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
thanks for ur instant reply. Actaully how do we know how a format works?..
My images are some medical images.. as far as I know they r X-ray images of spine and i beleive they r taken froms ome x-ray machines and the format may be some proprietery format.
The only data they have given to me is the one that I have given in my previous message.
I have already tried google in many ways, but of no use. It not even giving me atleast one site relating to this.
If u think I should have some more data to convert them or to know how they works, lemme know i would try to know some more data if possible. If u want i can send u a sample file.
thanks,
Pavan.
Pavan
|
|
|
|
|
I'm sorry, I really don't have time to look at a sample file.
IFFCL_GRAY {
bits: 12
byte: @0=0x00
byte: @1=0x00
byte: @2=0x00
byte: @3=0x00
width:[@6=ishort]/2
height:@4=ishort
start_offset:128
line_offset:width*2
datatype: lsb_msb
}
This looks to me like the image is 12 bit greyscale, which means that there are 4096 shades of gray. Given that the line offset is twice the width, each pixel must be stored in 2 bytes, which is fine, given that this gives you 16 bits to play with, it's a case of figuring out which 4 bits are ignored. It also looks like there is a 128 byte header at the top of the file, image data would follow after that. It looks like byte 6 of the header is the width, and btye 4 is the height.
All of this is a wild guess.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hi Graus,
I am writing a program for this (image format conversion) and i need some advice from u.... as this is a 12 bit greyscale image... can we say tht it is having only 1 layer of data (like tht of tiff images) if tht is the case... using this data how can we convert it into a 24 bit bitmap image (i hope we have to use tht 12 bit information and fill up the 24 bit for each pixel in BMP) if this is correct then how can we generate a 24 bit information from a 12 bit information (i hope we have to do some padding work over here, but how can we perform it).
sorry if i bother u askin these many questions...
thanks in advance,
Suman
|
|
|
|
|
Suman Niranjan wrote:
sorry if i bother u askin these many questions...
Not at all, that's what I invite by writing articles.
Given that the image is greyscale, the red, green and blue components will be the same. Therefore I'd assume that each pixel is defined by all 12 bits, which gives them a range of 4096 values. I'd shift the values by 4, so that you use the 8 most significant bits to define your grey level, then you need to shove that value into each of the red, green and blue values for your 24 bit image.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Hi Graus,
thanks for ur inspiration and suggestion. Here is wht I am plannin to proceed...
1) I would read the file byte by byte using System.IO namespace.
2) As we know tht the width - value at (byte6)/2
and height - value at byte4 and the starting offset of the actual data is from byte 128. So, after reading the width and height , directly i would jump to 128 offset and starting reading the data.
3) Now the actual scene comes in to play... now the data is 12bpp means they used 2 bytes but they actually used 12 bits in it (am i right?), now the problem is, in which direction we have to consider... since they have given data_type: lsb_msb (means the data is written from lsb to msb [right to left]... so should we have to consider the last 12 bits and now here i didn't get how to shift the bits..and which 8 bits to use to define our new greylevel. if this is cleared then i can proceed with creating a bitmap image with correcsponding RGB channels.
please help me out if u can....and guide me if i am goin in wrong direction..
thanks in advance,
Pavan.
Suman
|
|
|
|
|
Hi Graus,
Here is the problem, I am writing a program to find the cornor pixels in an image and i am turnin those cornor pixels to red. I have written my method as below and i have tried it in different ways like using (int)pSrc[..], (byte)255 in if loops, but of no use. I am not able to turn the cornor pixels to red.(Basically for finding the cornor pixels i am checking with it neighborhood pixels whether they are white(255) or not in some fashion. Since the return type is BGR i have tried the reverse order of assignment too (0,0,255).
public static bool Cornors(Bitmap b)
{
Bitmap bSrc = (Bitmap)b.Clone();
BitmapData bmData = b.LockBits(new Rectangle(0, 0, b.Width, b.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
BitmapData bmSrc = bSrc.LockBits(new Rectangle(0, 0, bSrc.Width, bSrc.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
int stride = bmData.Stride;
int stride2 = stride * 2;
System.IntPtr Scan0 = bmData.Scan0;
System.IntPtr SrcScan0 = bmSrc.Scan0;
unsafe
{
byte * p = (byte *)(void *)Scan0;
byte * pSrc = (byte *)(void *)SrcScan0;
int nOffset = stride - b.Width*3;
int nWidth = b.Width - 2;
int nHeight = b.Height - 2;
for (int y=0;y < nHeight;++y)
{
for (int x=0; x < nWidth; ++x )
{
if (pSrc[3+stride]==255)
{
if ((pSrc[3]==(byte)255 && pSrc[0+stride]==(byte)255)||(pSrc[3]==(byte)255 && pSrc[6+stride]==(byte)255)||(pSrc[3+stride2]==(byte)255 && pSrc[6+stride]==(byte)255)||(pSrc[0+stride]==(byte)255 && pSrc[3+stride2]==(byte)255)||(pSrc[3+stride2]==(byte)255 && pSrc[6+stride]==(byte)255)
||(pSrc[3]==(byte)255 && pSrc[0+stride]==(byte)255 && pSrc[6+stride]==(byte)255)||(pSrc[0+stride]==(byte)255 && pSrc[3+stride2]==(byte)255 && pSrc[6+stride]==(byte)255)
||(pSrc[3]==(byte)255 && pSrc[0+stride]==(byte)255 && pSrc[3+stride2]==(byte)255)||(pSrc[3]==(byte)255 && pSrc[6+stride]==(byte)255 && pSrc[3+stride2]==(byte)255)
||(pSrc[3]==(byte)255 && pSrc[0+stride]==(byte)255 && pSrc[6+stride]==(byte)255 && pSrc[3+stride2]==(byte)255))
{
pSrc[3 + stride]= (byte) 255;
pSrc[4 + stride]= (byte) 0;
pSrc[5 + stride]= (byte) 0;
}
}
p += 3;
pSrc += 3;
}
p += nOffset;
pSrc += nOffset;
}
}
b.UnlockBits(bmData);
bSrc.UnlockBits(bmSrc);
return true;
}
If there is any mistake in my cod ecan u plz lemme know abt it.
thanks in advance,
Pavan.
Pavan
|
|
|
|