Bmp image array, how to draw it on page
I do not mess arround with Flex all to much so forgive the poor question title.
I do not use Flex to open a socket connetion to an embedded device. From there i send and get information.
I need to display a 320x240 image. I cannot use the typical way for getting an image like i have see you guys use for nabing it from a server. I have to send the data up through this socket connection. I can handle all that. So to make things simple lets say i have created an array of the image data in RGB or BGR format. How can i draw out this data.
When you do any displayable graphic manipulation in Java it's usually going to be through an override in your paint/paintComponent (awt/swing). You need to read the Java tutorial on how to do graphics--here is a rough on how:
I'll assume you want to have a graphic object to save when you are done--
get the graphic context of your image (look in the API under BufferedImage--I suggest using BufferedImages)
make a change to the graphic context of the image
call repaint()
Graphics2D biGraphics = bi.createGraphics();
//your code here to make changes to the image
//by manipulating the Graphics context biGraphics
repaint();Now your override for paintComponent (I'll assume you are using SWING for this and your image name is bi).
public void paintComponent(Graphics g){
super.paintComponent(g);
g.drawImage(bi, 0, 0, this);
}
Similar Messages
-
How to display BMP image.
Hai
I have a problem in displaying bmp image and I came to know that BMP format is not supported by java se 1.4.
How can i display the image?
OR
Is there any third party tool (open source) that can solve my problem
Thank youhey
i need to display the an image.
I am using apache commons codec for encoding and decoding.
I have base64 encoded image data, i am decoding this and trying to create an image icon object by passing decoded byte array.
That encoded and decoded byte array is BMP formatted data.
or Is it possible to convert BMP data to any other format like png, jpg ....
thanks -
How do i turn a single bmp image in to seperate objects so i can make seperate symbols?
Hi, I am new to adobe flash pro cs6. I have been sent this image and i have been asked if i can make the tails of the mice move and their heads etc. My problem is that i dont know how to seperate or select individual parts of the image so that i can use the bone tool on them. From what i read i need to seperate each part in to a symbol and then add to a sperate layer so i can animate them. Is there a way of using flash pro to select and seperate each part so i can make symbols? Thank you for your time and help in advance.
If you only have a flat image, then no matter where you turn to work with it will be more tedious than if your image was a layered drawing such as an original Photoshop image.
If you create the objects in a Photoshop image where the pieces reside on separate layers, then you can import that file into Flash with the layers intact and convert the pieces to objects that you animate.
How you create the pieces you wish to animate is your call, it will probably be as much work to do it in Photishop as it would be in Flash, though I cannot say for sure since I don't use Photoshop too often... not my first choice for drawing software. I would probably just follow the tedious process Rob mentioned at the end and create the tail by taking a copy of the image, breaking it apart (using the Break Apart command) and then erase everything but the tail.
As far as integrating the moving pieces with the original image goes, I would edit the image to have the tail removed, otherwise you end up with two tails... one moving and one beneath it. -
How to view BMP images in JFileChooser.. for previewing..
Friends,
I was trying to open JFileChooser with preview of BMP images.. but remain unsuccessful.. it was showing JPG and GIF perfectly.. but in case of BMP it does not show anything.. am not using any filter though!!
how to acheive this!!
Thanking in advance
gervinicamickr.. i think u missed one point..
The Image I/O system in JAVA 5 has readers and writers for BMP and WBMP formats... so cant I upload BMP image by ImageIO and put them in icons to display... in JFileChooser.. ??
I want to display just like.. as given at
http://java.sun.com/docs/books/tutorial/uiswing/components/filechooser.html#advancedexample -
How to draw 2D shapes on the image generated by JMF MediaPlayer?
Hello all:
IS there any way that we can draw 2D shapes on the image generated by JMF
MediaPlayer?
I am currently working on a project which should draw 2D shapes(rectangle, circle etc) to
mark the interesting part of image generated by JMF MediaPlayer.
The software is supposed to work as follows:
1> first use will open a mpg file and use JMF MediaPlayer to play this video
2> if the user finds some interesting image on the video, he will pause the video
and draw a circle to mark the interesting part on that image.
I know how to draw a 2D shapes on JPanel, however, I have no idea how I can
draw them on the Mediaplayer Screen.
What technique I should learn to implement this software?
any comments are welcome.
thank you
-DanielIf anyone can help?!
thank you
-Daniel -
URGENT! : how to draw images?
new to swing, wanna create an app using jframes but how do i draw my images? added 2 jpanels to my jframe to split the window into 2, 1 side for text, the other is for my images. but how do i draw them on the jpanel? read the java tutorial but it only shows me class xxx extends jpanel. must i do this? if i must, where shld my jframe be? really need some help right away cos i'm doing it for a project n deadline's coming soon...
i attached the source code as following:(made by jbuilder)
package untitled3;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Frame1 extends JFrame {
private JPanel contentPane;
private BorderLayout borderLayout1 = new BorderLayout();
private JSplitPane jSplitPane1 = new JSplitPane();
private JTextArea jTextArea1 = new JTextArea();
private JPanel jPanel1 = new JPanel();
//Construct the frame
public Frame1() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
catch(Exception e) {
e.printStackTrace();
//Component initialization
private void jbInit() throws Exception {
//setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]")));
contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(borderLayout1);
this.setSize(new Dimension(400, 300));
this.setTitle("Frame Title");
jTextArea1.setText("jTextArea1");
contentPane.add(jSplitPane1, BorderLayout.CENTER);
jSplitPane1.add(jTextArea1, JSplitPane.LEFT);
jSplitPane1.add(jPanel1, JSplitPane.RIGHT);
//Overridden so we can exit when window is closed
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
package untitled3;
import javax.swing.UIManager;
import java.awt.*;
public class Application1 {
private boolean packFrame = false;
//Construct the application
public Application1() {
Frame1 frame = new Frame1();
//Validate frames that have preset sizes
//Pack frames that have useful preferred size info, e.g. from their layout
if (packFrame) {
frame.pack();
else {
frame.validate();
//Center the window
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = frame.getSize();
if (frameSize.height > screenSize.height) {
frameSize.height = screenSize.height;
if (frameSize.width > screenSize.width) {
frameSize.width = screenSize.width;
frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
frame.setVisible(true);
//Main method
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
catch(Exception e) {
e.printStackTrace();
new Application1();
} -
How to draw transparent image?
i'm developing a java game, i wonder how to draw a transparent image, i'm using Image class, and Graphics class.
http://search.java.sun.com/search/java/index.jsp?qp=forum%3A20&nh=10&qt=%2Btransparent+%2Bimage&col=javaforums
-
Could any one tell me how to divide a BMP image into pixel blocks
I am new in Java, Could anyone please show me how to block an BMP image into segmented blocks. Please help.
could you be a bit more specific? What segmented blocks are you talking about? Is the width and the height of these segmented blocks givenby the user or does it have to be equal blocks of the whole image?
-
How to read 32 bit depth .bmp image
How to read 32 bit depth .bmp image using LabVIEW?
@nk
Solved!
Go to Solution.A "standard" image, by which I mean an image type most typically encountered, stores image data in RGB format with 8 bits per colour, making them 24-bit images (24bbp - bits per pixel). A 32-bit image normally includes an additional 8 bits for the alpha channel, but in BMP files this format is complex (see wiki article), and it appears the LabVIEW Read BMP function does not support it.
Do you have the IMAQ toolkit? I can't test the theory, but perhaps the IMAQ functions for reading image files are more advanced and can read your images?
Thoric (CLA, CLED, CTD and LabVIEW Champion) -
Crop bmp image into 2 pieces and 3 pieces
Hi!
1. I want to crop a bmp image into 2 pieces and show the two cop image in 2 picturebox.
2. I want to crop a bmp image into 3 pieces and show theme in 3 picturebox.
Can anyone help me?Hi,
put three pictureboxes to a Form named Form1
public Form1()
InitializeComponent();
//create an image
Bitmap bmp = new Bitmap(1024, 768);
//draw something to it
using (Graphics g = Graphics.FromImage(bmp))
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
g.Clear(Color.Green);
g.FillEllipse(Brushes.Yellow, new Rectangle(0, 0, bmp.Width, bmp.Height));
//and crop ionto the array
Bitmap[] bmps = CropIntoThree(bmp);
this.pictureBox1.SizeMode = this.pictureBox2.SizeMode = this.pictureBox3.SizeMode = PictureBoxSizeMode.Zoom;
if(bmps[0] != null)
this.pictureBox1.Image = bmps[0];
if(bmps[1] != null)
this.pictureBox2.Image = bmps[1];
if(bmps[2] != null)
this.pictureBox3.Image = bmps[2];
private Bitmap[] CropIntoThree(Bitmap bmp)
Bitmap[] bmps = new Bitmap[3];
//get a third of the width
int third = (int)Math.Ceiling(bmp.Width / 3.0);
for (int i = 0; i < 3; i++)
//if the last third should be smaller (by 1 or 2 pixels, you could use the modulo operator here too)
if (i * third + third > bmp.Width)
third = bmp.Width - i * third;
bmps[i] = bmp.Clone(new Rectangle(i * third, 0, third, bmp.Height), bmp.PixelFormat);
return bmps;
[And dont forget to Dispose the bitmaps when you do not need them anymore, e.g. in the FormClosing event.]
Regards,
Thorsten -
I have being trying to input an array and turn it to a 1 bit bmp image.However, whatever the input, the generated bmp file is either all black or all white and I can't get the images supposed to be generated.
Can someone please show me how to fix that or provide any other way that can generate a "grayscale bmp image"?
I've been working on it but still not able to figure it out
The attached file is the program I been working on.
Please help me! Any advice and suggestions will be greatly appreciated!!
Attachments:
boolean array to bmp.vi 15 KBone of the attached files is in 2011 ,and the other is in 8.0 version.
Thank you a lot!!!!
Attachments:
boolean array to bmp 11.vi 10 KB
boolean array to bmp 8.0.vi 18 KB -
Hi,
I upload two bmp images in se78. I maintained the image name in zreport. Using select qry i fetch the name and i want to diaplay those images one of the column in my alv report.
Need Source Code for this.
plz assist ,
Thanks.
Edited by: abap.m on May 1, 2010 12:16 PMHai Kanwardeep Singh,
Now i have some image in excel sheet i want to upload those images in r/3.
Because of i'll go to create one alv report to display the images.
For example:
in material master they maintained the machine model number,machine name etc.
Now their req is they need a report
SeqNo Mch_ No Mch_Name Mch_Img
1 100 heat image
2 200 pump image
.(In Mch_Img Column i need a image related to that particular machine how)
Like that i need a report in alv
Edited by: abap.m on May 1, 2010 1:26 PM -
IGS COnverted BMP Image upload problem in SE78
HI Friends,
I Converted the JPEG image into BMP ormat by using IGS. It is converting properly. i am able to see the BMP image. When i am trying to upload it through the SE78 i am getting the short dump.
If convert it manually, i am able to upload the image. i did not get the any difference between these two including file size, width and height.
I attached the shortdump and converted image file as an attachment. Can anyone give me inputs where i am missing the target.
Runtime error : COMPUTE_INT_TIMES_OVERFLOW
Exception : CX_SY_ARITHMETIC_OVERFLOW
Thanks ,
Srinivas BhavanamHi Oisin,
Sorry for the Late Reply. I am using IGS 6.40 with solaris system.
If i am converting the image from my desktop i am getting 96DPI resolution. Where as if i am doing it from IGS i am getting 30682172 DPI resolution.
I am using SAP 4.7. Is it the latest patch level or latest IGS supported.
Short Dump :
Runtime Error COMPUTE_INT_TIMES_OVERFLOW
Exception CX_SY_ARITHMETIC_OVERFLOW
Occurred on 03.03.2010 at 11:04:30
Whole number overflow on multiplication.
What happened?
Error in ABAP application program.
The current ABAP program "SAPLSTXBITMAPS" had to be terminated because one of
the
statements could not be executed.
This is probably due to an error in the ABAP program.
What can you do?
Print out the error message (using the "Print" function)
and make a note of the actions and input that caused the
error.
To resolve the problem, contact your SAP system administrator.
You can use transaction ST22 (ABAP Dump Analysis) to view and administer
termination messages, especially those beyond their normal deletion
date.
Error analysis
An exception occurred. This exception is dealt with in more detail below
. The exception, which is assigned to the class 'CX_SY_ARITHMETIC_OVERFLOW',
was neither
caught nor passed along using a RAISING clause, in the procedure
"FILL_BMFILE_FROM_BMP" "(FORM)"
Since the caller of the procedure could not have expected this exception
to occur, the running program was terminated.
The reason for the exception is:
In the current program "SAPLSTXBITMAPS", multiplying the numbers 1207959552 and
100 (using the operation * or 'MULTIPLY') resulted in a value
greater than 2147483647 or smaller than -2147483648. This
results in a whole number overflow.
How to correct the error
The exception must either be prevented, caught within the procedure
"FILL_BMFILE_FROM_BMP"
"(FORM)", or declared in the procedure's RAISING clause.
To prevent the exception, note the following:
You may be able to split the process into separate components, so that
the values generated are smaller.
If the error occurred in one of your own programs or in an SAP program
that you modified, try to correct it yourself.
If you cannot solve the problem yourself, please send the
following documents to SAP:
1. A hard copy print describing the problem.
To obtain this, select the "Print" function on the current screen.
2. A suitable hardcopy prinout of the system log.
To obtain this, call the system log with Transaction SM21
and select the "Print" function to print out the relevant
part.
3. If the programs are your own programs or modified SAP programs,
supply the source code.
To do this, you can either use the "PRINT" command in the editor or
print the programs using the report RSINCL00.
4. Details regarding the conditions under which the error occurred
or which actions and input led to the error.
System environment
SAP Release.............. "620"
Application server....... "EWR0R3DEV002"
Network address.......... "10.20.32.13"
Operating system......... "SunOS"
Release.................. "5.9"
Hardware type............ "sun4u"
Character length......... 16 Bits
Pointer length........... 64 Bits
Work process number...... 0
Short dump setting....... "full"
Database server.......... "EWR0R3DEV002"
Database type............ "ORACLE"
Database name............ "I07"
Database owner........... "SAPRGG"
Character set............ "C"
SAP kernel............... "640"
Created on............... "Mar 9 2009 21:04:19"
Created in............... "SunOS 5.8 Generic_117350-38 sun4u"
Database version......... "OCI_920 "
Patch level.............. "274"
Patch text............... " "
Supported environment....
Database................. "ORACLE 9.2.0.., ORACLE 10.1.0.., ORACLE
10.2.0.."
SAP database version..... "640"
Operating system......... "SunOS 5.8, SunOS 5.9, SunOS 5.10"
User, transaction...
Client.............. 999
User................ "SREDDY"
Language key........ "E"
Transaction......... "SE78 "
Program............. "SAPLSTXBITMAPS"
Screen.............. "SAPLSTXBITMAPS 4001"
Screen line......... 8
Information on where terminated
The termination occurred in the ABAP program "SAPLSTXBITMAPS" in
"FILL_BMFILE_FROM_BMP".
The main program was "SAPMSSCH ".
The termination occurred in line 1959 of the source code of the (Include)
program "LSTXBITMAPSF03"
of the source code of program "LSTXBITMAPSF03" (when calling the editor 19590).
Processing was terminated because the exception "CX_SY_ARITHMETIC_OVERFLOW"
occurred in the
procedure "FILL_BMFILE_FROM_BMP" "(FORM)" but was not handled locally, not
declared in the
RAISING clause of the procedure.
The procedure is in the program "SAPLSTXBITMAPS ". Its source code starts in
line 1843
of the (Include) program "LSTXBITMAPSF03 ".
Source code extract
019290 endcase.
019300 * compression
019310 perform bmptab_getdword_ofs tables bitmap_file
019320 using ofs bmp_compression.
019330 case bmp_compression.
019340 when c_bmp_compr_rgb. "BI_RGB, uncompressed
019350 when c_bmp_compr_rle8. "BI_RLE8, 256 colors colormap, rle encoding
019360 when c_bmp_compr_rle4. "BI_RLE8, 16 colors colormap, rle encoding
019370 when others. message e872 raising bmperr_unsup_compression.
019380 endcase.
019390 * size of image
019400 perform bmptab_getdword_ofs tables bitmap_file
019410 using ofs bmp_sizeimage.
019420 * pix per meter X
019430 perform bmptab_getlong_ofs tables bitmap_file
019440 using ofs bmp_xpelspermeter.
019450 * pix per meter Y
019460 perform bmptab_getlong_ofs tables bitmap_file
019470 using ofs bmp_ypelspermeter.
019480 * colors used
019490 perform bmptab_getdword_ofs tables bitmap_file
019500 using ofs word.
019510 * colors important
019520 perform bmptab_getdword_ofs tables bitmap_file
019530 using ofs word.
019540 ofs_rgbquad = ofs_bitmapinfoheader + bmp_bisize.
019550 * now we have OFS_RGBQUAD -> color table
019560 * OFS_BITMAPDATA -> bitmap bytes
019570 otf_bminfo-new_rd_format = c_false.
019580 otf_bminfo-is_resident = c_false.
> otf_bminfo-dpi = ( bmp_xpelspermeter * 100 ) / 3937.
019600 perform bmp_adjust_dpi using otf_bminfo-dpi.
019610 otf_bminfo-w_pix = bmp_width.
019620 otf_bminfo-h_pix = abs( bmp_height ).
019630 otf_bminfo-w_tw = ( 1440 * otf_bminfo-w_pix ) / otf_bminfo-dpi.
019640 otf_bminfo-h_tw = ( 1440 * otf_bminfo-h_pix ) / otf_bminfo-dpi.
019650 case bmp_bitcount.
019660 when 1.
019670 otf_bminfo-bitsperpix = 1.
019680 otf_bminfo-bytes_per_row = otf_bminfo-w_pix div 8.
019690 rest = otf_bminfo-w_pix mod 8.
019700 when 4.
019710 otf_bminfo-bitsperpix = 4.
019720 otf_bminfo-bytes_per_row = otf_bminfo-w_pix div 2.
019730 rest = otf_bminfo-w_pix mod 2.
019740 when 8.
019750 otf_bminfo-bitsperpix = 8.
019760 otf_bminfo-bytes_per_row = otf_bminfo-w_pix.
019770 rest = 0.
019780 when 24.
Thanks & Regards,
Srinivas Bhavanam -
Need urgent help ..save BMP image
I have a BMP image .I m extracting its pixels (using PixelGrabber)and formatting those values as per requirements.
Now,I have to create an image using this pixels array again.
Image img;
img = createImage(new MemoryImageSource(iw,ih,pixels,0,iw)) ;This is creating an[b] image "img" of type Image.
Now,I have to save this image as BMP.
for this I am using
ImageIO.write(img,"BMP",new File("a.bmp"));The problem is this[b] write method require an image of type Buffered Image.
I am not able to typecast an object of type Image into BufferedImage.
BufferedImage is subclass of Image class..
I just hope i m making sense..
Please help me..
Is there any other way too to save an BMP image created by createImage()Thnx a lot for help I used a method u told me ...
here is the code i hve:
import java.io.*;
import java.awt.*;
import javax.swing.*;
import javax.imageio.*;
import java.awt.image.*;
import java.awt.image.PixelGrabber;
import javax.imageio.ImageIO;
public class RecreateImage2
public static void main(String args[])
ImageFrame frame = new ImageFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
class ImageFrame extends JFrame
public ImageFrame()
Toolkit kit=Toolkit.getDefaultToolkit();
Dimension screenSize=kit.getScreenSize();
int screenHeight=screenSize.height;
int screenWidth=screenSize.width;
setSize(screenWidth/2,screenHeight/2);
setLocation(screenWidth/4,screenHeight/4);
setTitle("Centered Frame");
ImagePanel1 panel=new ImagePanel1();
add(panel);
class ImagePanel1 extends JPanel
Image img;
public ImagePanel1()
try
Image image;
Dimension d;
int iw,ih;
image = ImageIO.read(new File("bug_apple.bmp"));
iw = image.getWidth(null);
ih = image.getHeight(null);
int pixels[] = new int[ih*iw];
PixelGrabber pg = new PixelGrabber(image,0,0,iw,ih,pixels,0,iw);
pg.grabPixels();
img = createImage(new MemoryImageSource(iw,ih,pixels,0,iw));
BufferedImage bi = new BufferedImage(iw,ih,BufferedImage.TYPE_INT_ARGB)
Graphics2D g2d = bi.createGraphics();
g2d.drawImage(img, 0, 0, null);
g2d.dispose();
img=bi;
ImageIO.write(img,"BMP",new File("a.bmp")) ;
catch(InterruptedException e)
catch(IOException e)
e.printStackTrace();
}Its giving error ...saying
cannot find method write(java.awt.Image,java.lang.String,java.io.File)But If i use Method
ImageIO.write((BufferedImage)img,"BMP",new File("a.bmp")) ;It saves the Image as "a.bmp" but preview of image is not available...
Please help me..I really dono whr the proplem is..
richa_sharma -
How to draw symbol for avalanche diode in multisim ?
Hello all,
I have to include a symbol for diode array in multisim... SP0503BAHT, can anyone please suggest how to draw it? I am very new to multisim...
thanks,
Now on LabVIEW 10.0 on Win7
Solved!
Go to Solution.Hi,
The easiest approach to do this is to copy the symbol of a diode from the Master Database and then edit the symbol to fulfill your needs.
In the Component Wizard, when you are prompted to Enter symbol information, click on Copy from DB and choose a diode symbol that you like. Click on Edit and then you can edit the symbol.
Hope this helps.
Regards,
Tayyab R,
National Instruments.
Maybe you are looking for
-
Asa 5505 sub interface plus ports
I have never used 5505 I gave used higher firewalls and all of them can do sub interfaces normally we make sub interfaces and vlans are assigned to them I m trying to config 5505 can someone tell me how I can create sub interfaces ? As I saw few conf
-
My screen is cracked I can only see some things, I was using a HDMI cord connected to another screen. I factory reset my laptop and now I can't get the images to appear on the other screen.
-
DEQUEUE_MSGID column in a queue table
There are three msgid-related columns in a queue table: MSGID, CORRID, DEQUEUE_MSGID I know the meaning of the columns MSGID and CORRID. But what is the column DEQUEUE_MSGID for?
-
OIM (Xellerate) Provisioning Functionality with Web Services
Hi, Has anyone had any experience with needing to issue user provisioning requests to Oracle Identity Manager (formally Xellerate) using web services? I envision that it would most likely involve using SPML as the standard communication protocol with
-
I am purchasing certification vouchers by today. I am preparing for SCJP 6. Do I need to select a particular voucher for it or any voucher will do for any version?