Something about read bmp file
I want to read a part of a picture,for example ,a picuture ,what I only want to display in the front palette is that the center region of it?Which vision function
should I use?Thank you so much!
Hi
You can do this with the use of IMAQ Extract function
Sasi.
Certified LabVIEW Associate Developer
If you can DREAM it, You can DO it - Walt Disney
Similar Messages
-
Read BMP File Requires Absolute Path
I noticed something today regarding the Graphics Formats, Read JPG File, Read PNG File and Read BMP File vi's. It seems that when reading a JPG or PNG file, a relative path is OK, but when reading a BMP file, an absolute path is required. When the path only contains the filename, it returns:
Error 1430
"Open/Create/Replace File in Read BMP File Data.vi->Read BMP File.vi->ReadImageFileTest.vi"
I tried a simple test that uses either the relative or absolute path, trying to read 3 different files in the same directory as the VI. Only the Read BMP File errors. Of course, the simple work around is to always use the full pathname to a file. Is this only on my system? Is this a known bug or feature or expected behavior?
I'm using LabVIEW 8.2 on Windows XP.
Thanks!
B-)
Message Edited by LabViewGuruWannabe on 11-05-2007 11:06 PM
Attachments:
ReadImageFileTest-FPgood.PNG 30 KB
ReadImageFileTest-FPbad.PNG 26 KB
ReadImageFileTest-BD1.PNG 48 KBMissed this on the first post:
Message Edited by LabViewGuruWannabe on 11-05-2007 11:10 PM
Attachments:
ReadImageFileTest-BD.PNG 48 KB -
I am trying to send a photo in an email and the file is huge. I remember something about reducing the size of the file but of course can't remember how.
Use a utility such as Graphic Converter to change the image to a jpeg using options to reduce the size of the converted image.
-
Problem in reading BMP file .....
I've facing some inconsistency in reading BMP headers. There are two of them, and I've outlined them below....
Here's a description of the BMP headers, just for refreshing ....
1.
typedef struct {
BITMAPFILEHEADER bmfHeader;
BITMAPINFOHEADER bmiHeader;
GLubyte *image_data;
} BITMAP_IMAGE;
typedef struct tagBITMAPFILEHEADER {
WORD bfType; // 2B
DWORD bfSize; // 4B
WORD bfReserved1; // 2B
WORD bfReserved2; // 2B
DWORD bfOffBits; // 4B
} BITMAPFILEHEADER, *PBITMAPFILEHEADER;
typedef struct tagBITMAPINFOHEADER{
DWORD biSize;
LONG biWidth;
LONG biHeight;
WORD biPlanes;
WORD biBitCount;
DWORD biCompression;
DWORD biSizeImage;
LONG biXPelsPerMeter;
LONG biYPelsPerMeter;
DWORD biClrUsed;
DWORD biClrImportant;
} BITMAPINFOHEADER, *PBITMAPINFOHEADER;
2. The file I'm reading test2.bmp has the following parameters
File Type Windows 3.x Bitmap (BMP)
Width 4
Height 4
Horizontal Resolution 96
Vertical Resolution 96
Bit Depth 24
Color Representation True Color RGB
Compression (uncompressed)
Size 102 bytes
Size on disk 4.00 KB (4,096 bytes)
3. Output of the program is....
File Headers are...
bfType :424d
bfSize :102
bfReserved1 :0
bfReserved2 :0
bfOffBits :54
File Info Headers are...
biSize :40
biWidth :4
biHeight :4
biPlanes :0
biBitCount :1
biCompression :1572864
biSizeImage :48
biXPelsPerMeter :196
biYPelsPerMeter :234881220
biClrUsed :234881024
biClrImportant :0
4. readInt() 4
Reads four input bytes and returns an int value.
readUnsignedShort() 2
Reads two input bytes and returns an int value in the range 0 through 65535.
readByte()
Reads one Byte
5. The bfType fields value should be 'BM' whose Hex is 0x4D42 according to this link
http://edais.earlsoft.co.uk/Tutorials/Programming/Bitmaps/BMPch1.html
But the Hex I get is 424d.How come ?
6. When reading bfSize (see ## ), we should read 4 bytes as per the above structure. But I don't
get the answer of 102 when I do readInt() (which reads 4B). On the contrary, when I do
readByte(), thats when I the right file size of 102.
Why ?
Rest all the output look ok.
import java.io.*;
class BMPReader{
private byte data[];
private DataInputStream dis = null;
public BMPReader(String fileName){
readFile(fileName);
private void readFile(String fileName){
try{
dis = new DataInputStream(new FileInputStream(new File(fileName)));
catch(Exception e){
System.out.println(e);
public void printFileHeader(){
System.out.println("File Headers are...");
try{
// converting the 2 bytes read to Hex
System.out.println("bfType :" + Integer.toString(dis.readUnsignedShort(),16));
System.out.println("bfSize :" + dis.readInt());
//System.out.println("bfSize :" + dis.readByte());// ## identifier, should read 4B here instead of 1B
System.out.println("bfReserved1 :" + dis.readUnsignedShort()); // bfReserved1
System.out.println("bfReserved2 :" + dis.readUnsignedShort()); // bfReserved2
System.out.println("bfOffBits :" + dis.readInt()); // bfOffBits
catch(Exception e){
System.out.println(e.toString());
public void printFileInfoHeader(){
System.out.println();
System.out.println("File Info Headers are...");
try{
System.out.println("biSize :" + dis.readInt()); //DWORD
System.out.println("biWidth :" + dis.readInt()); //LONG
System.out.println("biHeight :" + dis.readInt()); //LONG
System.out.println("biPlanes :" + dis.readUnsignedShort()); //WORD
System.out.println("biBitCount :" + dis.readUnsignedShort()); //WORD
System.out.println("biCompression :" + dis.readInt()); //DWORD
System.out.println("biSizeImage :" + dis.readInt()); //DWORD
System.out.println("biXPelsPerMeter :" + dis.readInt()); //LONG
System.out.println("biYPelsPerMeter :" + dis.readInt()); //LONG
System.out.println("biClrUsed :" + dis.readInt()); //DWORD
System.out.println("biClrImportant :" + dis.readInt()); //DWORD
catch(Exception e){
System.out.println(e.toString());
public class BMPReadForum{
public static void main(String args[]){
String fName = "test2.bmp";
BMPReader bmpReader = new BMPReader(fName);
bmpReader.printFileHeader();
bmpReader.printFileInfoHeader();
}I stumbled across this thread while messing with numbers coming out of my palm (via pilot-xfer) that are unsigned 32 bit values read into a 4 element byte array. I would very much like to turn these things into longs. I looked over the above posted code (for which I am most grateful) and made some alterations that seemed prudent, would someone be so kind as to verify that this is doing what I would like it to do?
private long makeUInt(byte[] b) {
// Convert a four byte array into an unsigned
// int value. Created to handle converting
// binary data in files to DWORDs, or
// unsigned ints.
long result = 0;
int bit;
int n = 0; // I assumed this was the power to take the base to - 0 for lsb
// I further assumed that we need to move backwards through this array,
// as LSB is in the largest index, is this right?
for (int a=3; a >= 0; a--) {
// Similarly, I need to step through this backwards, for the same
// reason
for (int i=7; i >= 0; i--) {
bit = b[a] & 1;
result += bit * Math.pow(2, n++);
b[a] >>>= 1;
return result;
}So, as you see - I assumed the "n" term was a count for what power of 2 we were in in the bit string, and I further assumed that, since for me the MSB is in the byte array element with the largest index, I needed to work backwards through this thing.
Does this seem reasonable?
Thanks a lot
Lee -
Question about reading csv file into internal table
Some one (thanks those nice guys!) in this forum have suggested me to use FM KCD_CSV_FILE_TO_INTERN_CONVERT to read csv file into internal table. However, it can be used to read a local file only.
I would like to ask how can I read a CSV file into internal table from files in application server?
I can't simply use SPLIT as there may be comma in the content. e.g.
"abc","aaa,ab",10,"bbc"
My expected output:
abc
aaa,ab
10
bbb
Thanks again for your help.Hi Gundam,
Try this code. I have made a custom parser to read the details in the record and split them accordingly. I have also tested them with your provided test cases and it work fine.
OPEN DATASET dsn FOR input IN TEXT MODE ENCODING DEFAULT.
DO.
READ DATASET dsn INTO record.
PERFORM parser USING record.
ENDDO.
*DATA str(32) VALUE '"abc",10,"aaa,ab","bbc"'.
*DATA str(32) VALUE '"abc","aaa,ab",10,"bbc"'.
*DATA str(32) VALUE '"a,bc","aaaab",10,"bbc"'.
*DATA str(32) VALUE '"abc","aaa,ab",10,"b,bc"'.
*DATA str(32) VALUE '"abc","aaaab",10,"bbc"'.
FORM parser USING str.
DATA field(12).
DATA field1(12).
DATA field2(12).
DATA field3(12).
DATA field4(12).
DATA cnt TYPE i.
DATA len TYPE i.
DATA temp TYPE i.
DATA start TYPE i.
DATA quote TYPE i.
DATA rec_cnt TYPE i.
len = strlen( str ).
cnt = 0.
temp = 0.
rec_cnt = 0.
DO.
* Start at the beginning
IF start EQ 0.
"string just ENDED start new one.
start = 1.
quote = 0.
CLEAR field.
ENDIF.
IF str+cnt(1) EQ '"'. "Check for qoutes
"CHECK IF quotes is already set
IF quote = 1.
"Already quotes set
"Start new field
start = 0.
quote = 0.
CONCATENATE field '"' INTO field.
IF field IS NOT INITIAL.
rec_cnt = rec_cnt + 1.
CONDENSE field.
IF rec_cnt EQ 1.
field1 = field.
ELSEIF rec_cnt EQ 2.
field2 = field.
ELSEIF rec_cnt EQ 3.
field3 = field.
ELSEIF rec_cnt EQ 4.
field4 = field.
ENDIF.
ENDIF.
* WRITE field.
ELSE.
"This is the start of quotes
quote = 1.
ENDIF.
ENDIF.
IF str+cnt(1) EQ ','. "Check end of field
IF quote EQ 0. "This is not inside quote end of field
start = 0.
quote = 0.
CONDENSE field.
* WRITE field.
IF field IS NOT INITIAL.
rec_cnt = rec_cnt + 1.
IF rec_cnt EQ 1.
field1 = field.
ELSEIF rec_cnt EQ 2.
field2 = field.
ELSEIF rec_cnt EQ 3.
field3 = field.
ELSEIF rec_cnt EQ 4.
field4 = field.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
CONCATENATE field str+cnt(1) INTO field.
cnt = cnt + 1.
IF cnt GE len.
EXIT.
ENDIF.
ENDDO.
WRITE: field1, field2, field3, field4.
ENDFORM.
Regards,
Wenceslaus. -
'Read JPEG File.vi' does not seem to work on PXI with real-time OS
I am trying to read a jpeg file on a PXI system with LabVIEW real-time on it. To test I created a very simple VI (attached) with only 4 objects: 'Path' --> 'Read JPEG File.vi' --> 'Draw Flattened Pixmap.vi' --> 'Picture'.
This VI works fine on my Windows XP host machine, but it does not work on the PXI system. The error code 1 occurs in 'Read JPEG File.vi'.
The jpeg picture is in the same directory as the VI. I don't think I got the path or filename wrong because if I change the file or path name I get another error: 7: 'File/Directory Info in Check Path.vi->Read JPEG File.vi->test.vi'.
Maybe reading jpeg files is not supported on realtime systems? I could not find anything about it. Sol
utions or workarounds are of course welcome!
Attachments:
Test_Read_JPEG.vi 23 KB'Read JPEG File.vi' is not supported on LabVIEW RT. I believe it has to do with special functions or libraries need to be called due to the JPEG image type. Instead you can use a Bitmap and the 'Read BMP File.vi', which I believe is completely implemented in G code.
Keep in mind that the RT System doesn't really have a front panel and that the front panel is only 'available' when LabVIEW is connected to the target such as being targeted or having a remote panel to it. Generally, a deployed RT system doesn't have a UI and just communicates to a Host VI which acts as the UI. Having said that, the BMP file worked when I tested.
Regards,
JR A. -
Hello
i have a question. if you want to read a text file and then write to another text file within java, how do you pick what to send over ot the writing text file. for instance if i have from a text file goodbad.txt
i am good
i am baad
i wish to read this inside java (which i know how to do) but then i want to only write i am baad to another text file.
How do i do this
thanksTradeoff wrote:
okay so theprogram requires the following:
you have a text file with averaes for students with student number, class name and class average. you need to class name and class average of all entries and then splitt them into two text files as outputs depending on whether the average is 50 or more. So my question is, how do i only target the class name and average as the one the program will read from the text file and how do i assign the input of the mark to a double??
ThanksThis will all depend very much on the format of the text file.
Anyway. I think you are going to fail your assignment. What code have you written thus far? Any? Would you like to tell us about the format of the file? Are you reading it now line by line.
The answer is something like, read the file line by line, split, take the results of the split and determine the class name (by index) and then parse the average value as a double and examine that, and then write it all out to another file.
That's it. Your entire homework problem solved for you. So is that enough? If not then you need to back to the tutorials found here [http://java.sun.com/docs/books/tutorial/java/index.html] -
Is reading local file possible?
Hi,
My intention is to use Flash 8 Pro as a tool allowing to
upload large files
into the server (something like FTP client). Unfortunately a
lot of servers
have tight restrictions for transmition time (sometimes
limited to 30s).
Work around to this could be a Flash. I couldn't find any
information in
Flash documentation about reading binary files selected by
user by
HTML-like file field. I would like to read selected file,
split it into
severeal smaller parts and then upload every part separately
into the
server. Is it possible?
Regards,
Marek> Czesc Marek
Hi! It seems you speak my native language :-)))
> Flash itself has no FTP capabilities. The only thing you
can do is use
> middle ware
> like php or asp and server side to upload stuff to
server and use flash to
> prompt
> the Browse for File dialog, and than upload your files.
Flash itself has
> no way of
> doing it at all unless with middle ware.
Yes, I know that. That is the reason why I have written
'somethig like FTP'.
Ok, once again... I can create PHP script to receive POST
uploads. This is
no problem to me. The problem is that iddle time for scripts
on this
particular server is set to 30 seconds only. It means that I
can't upload
files for which transfer time will be longer then 30s. To
work around this
issue it is necessary SPLIT uploaded file into the chunks
then transfer it
to the server and join using e.g. PHP script. I need a tool
embeded on web
page which allows me to select large file (large sometimes
means 1MB) and
send into the server jumping over server time limitations.
Flash contains
build-in FileReference class but there is no described in the
documentation
how to send selected file as e.g. 4 separate parts of it.
> There is an upload samples which comes with
> flash and can be located under the SAMPLE directory on
your C drive in the
> Macromedia
> folder. This is as far as it goes.
It is also described in Flash help under FileReference class
description. -
Photoshop 7 can no open .bmp files?
Hi:
When I try to open a .bmp file using the PS7 file open method with the file dialog window set for all formats, no .bmp files appear in the list of files.
If in Windows Explorer a .bmp file is selected then the right click option of open with PS7 is used PS7 gives an error message.
I've read other posts about saving .bmp files in 8 bit mode but can find nothing in the forum or manual about opening a .bmp file.
How to do it?
Have Fun,
Brooke Clarke-------SOLUTION------
Thanks to Ed pointing to the file BMP.8BI I've found the solution.
That file was missing from the folder at:
C:\Program Files\Adobe\Photoshop 7.0\Plug-Ins\Adobe Photoshop Only\File Formats
so PS7 could not work with .bmp files. The reason it was missing was an earlier version had a security bug. Adobe came out with a new version the top of the page looks like:
Photoshop CS2, Photoshop CS3 and Photoshop Elements 5 updates to address security vulnerabilities
Release date: July 10, 2007
Vulnerability identifier: APSB07-13
CVE number: CVE-2007-2244, CVE-2007-2365
Platform: All Platforms
Affected software versions: Photoshop CS2, Photoshop CS3, and Photoshop Elements 5.0
http://www.adobe.com/support/security/bulletins/apsb07-13.html
I downloaded the patch zip file for Photoshop Elements 5.0:
http://download.macromedia.com/pub/security/bulletins/apsb07-13/win/ps_security_update.zip
and after unziping it moved BMP.8BI into the File Formats folder and it seems to work fine in PS7.
Have Fun,
Brooke Clarke -
To read text file using utl_file
I would like to read test_file_out.txt which is in c:\temp folder.
create or replace create or replace directory dir_temp as 'c:\temp';
grant read, write on directory dir_temp to system;
then when i execute the below code i get the error .
// to read text file using utl_file
DECLARE
FileIn UTL_FILE.FILE_TYPE;
v_sql VARCHAR2 (1000);
BEGIN
FileIn := UTL_FILE.FOPEN ('DIR_TEMP', 'test_file_out.txt', 'R');
UTL_FILE.PUT_LINE (FileIn, v_sql);
dbms_output.put_line(v_sql);
UTL_FILE.FCLOSE (FileIn);
END;
ERROR:
invalid file operation
i would like to use ult_file only and also can you let me know to read the text file and place its contents in tmp_emp table?Are you trying to read the contents of the file into the local variable? Or write the contents of the local variable to the file?
Your text talks about reading the file. And you open the file in read mode. But then you call the UTL_FILE.PUT_LINE method which, as SomeoneElse points out, attempts to write data to the file. Since the file is open in read-only mode, you cannot write to the file.
If the goal is really to read from the file, replace the UTL_FILE.PUT_LINE calls with UTL_FILE.GET_LINE. If the goal is really to write to the file, you'll need to open the file in write mode ('W' rather than 'R' in the FOPEN call).
Justin -
How to find a BMP file included with Applicatio​n in LabView?
I have a VI that I would like to build into an application (.EXE). The VI has a Picture indicator, whose source is a BMP on my local hard drive. Using "Read BMP File.vi" and a Path constant, it's relatively easy to read the BMP and display it in the indicator. I know how to include the file with the distribution (Build App or DLL -> Installer Settings -> Files), but how does one determine the location of the file after users install the EXE? I tried using just the filename of the picture in the path constant, hoping it would look in it's current directory, but I received an error. With the full path in the path constant, everything works just fine.
Thank you,
...jerryYou can reconstruct the path. Use the "Current VI's path" to get the
path of the caller VI. Then use the "Build path" and Strip path" to
build the path to your file.
Note that in an executable, the VIs path includes the executable, like
the following: C:\directory_name\my_exec.exe\main.vi
The attached code (image) should do it (or at least give you a start).
Regards;
Enrique
www.vartortech.com
Attachments:
path_to_file.gif 2 KB -
Case management - read attached file info
Dear Experts,
I have a requirement to read the atatched file information of a CASE.
Is the information present in any table or there any standard method in SCASE for this purpose ?
Thanks
Ikshula'Read JPEG File.vi' is not supported on LabVIEW RT. I believe it has to do with special functions or libraries need to be called due to the JPEG image type. Instead you can use a Bitmap and the 'Read BMP File.vi', which I believe is completely implemented in G code.
Keep in mind that the RT System doesn't really have a front panel and that the front panel is only 'available' when LabVIEW is connected to the target such as being targeted or having a remote panel to it. Generally, a deployed RT system doesn't have a UI and just communicates to a Host VI which acts as the UI. Having said that, the BMP file worked when I tested.
Regards,
JR A. -
Can't open pdf. files something about patch package
Can't open PDF files something about patch package verification.error.
I am having the same issue. Unable to open ANYTHING related to adobe (PDF, downloads), as well as unable to delete and reinstall or even change or correct.
-
Updated itunes - windows quickly shuts it down and says something about "Data Execution Prevention". I followed the instrucxtions to a dead end. I have re downloaded it twice and used the repair files once but get the same result. It worked fine before I updated it to death.
Try updating your QuickTime to the most recent version. Does that clear up the DEP errors in iTunes?
-
3 ?'s:
1 Message today warning lack of memory when using Word (files in Documents) something about "idisc not working"
2. Message week ago "Files not being backed up to Time Capsule";
3. When using Mac Mail I'm prompted for password but none work
Thanks - JThanks Allan for your quick response to my amateur questions.
Allan: I'm running version Mac OS X Version 10.6.8 PS Processor is 2.4 GHz Intel core 15
Memory 4 gb 1067 MHz DDr3 TN And @ 1983-2011 Apple Inc.
I just "Updated Software" as prompted.
Thanks for helping me! - John Garrett
PS.
Hardware Overview:
Model Name: MacBook Pro
Model Identifier: MacBookPro6,2
Processor Name: Intel Core i5
Processor Speed: 2.4 GHz
Number Of Processors: 1
Total Number Of Cores: 2
L2 Cache (per core): 256 KB
L3 Cache: 3 MB
Memory: 4 GB
Processor Interconnect Speed: 4.8 GT/s
Boot ROM Version: MBP61.0057.B0C
SMC Version (system): 1.58f17
Serial Number (system): W8*****AGU
Hardware UUID: *****
Sudden Motion Sensor:
State: Enabled
<Edited By Host>
Maybe you are looking for
-
I need to customize the AR customer statements report. The standard report fires a pro*c program 1. It populates data in ar_statement_headers and AR_STATEMENT_LINE_CLUSTERS. 2. Then it calls the XMLP to generate report 3. Waits for XMLP to complete,
-
Hi: Is it possible to configure the idocs to send it from XI to SAP in mode synchronous? Thanks
-
FaceTime not working on Ipad Mini
Hi. Hoping someone cn help. Currently travelling in Asia. My Ipad Mini has stopped working with FaceTime. Have been in communication with home for months with no issue and suddenly it will not answer or dial out. Simply gives a busy signal!!!. Will
-
File Adapter - Archived file name issue
Hello all. I am using an 11g composite application to read from the file system and move/archive the files to a "Backup" subdirectory. Everything works well, but the archived file name has the original filename plus an extra long guid. E.g. File_1.DA
-
Web service call fails - type mismatch
Hi All I hope someone can help, as I have been struggling with this issue for a few days. If I have missed any useful information off of this post, please ask and I will try to supply. I am trying to call a web service, but contantly receiving the er