Creating a .jpg image from with in the J2ME app

Hi,
I want to send a document to the printer over bluetooth to print.
For that I searched on net, but couldn't find any APIs supported by J2ME to print it. I also found a link http://www.hcilab.org/documents/tutorials/Brother/ where I found that I can send the data by creating an image and then writing data (text or image ) in to it, and then sending that image to print.
Image img = Image.createImage(816, 40);
Graphics g = img.getGraphics();
g.setColor(0, 0, 0);
g.setFont(Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_BOLD,Font.SIZE_LARGE));
g.drawString("Printing test from "
                         + System.getProperty("microedition.platform") + " on "
                         + new Date(), 10, 10, 0);
driver.print(img, btAddr);This code is working fine on this printer.
I am using HP 460cb printer, and I tried the same thing, but am not getting any results. Can any one of you tell me what mistake am I making.
                Image blankImage = Image.createImage(SpotBilling.MAX_IMG_WIDTH, SpotBilling.MAX_IMG_HEIGHT);
                Graphics g = blankImage.getGraphics();
                g.setColor(0,0,0);
                g.setFont(Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_PLAIN, Font.SIZE_SMALL));
                g.drawString("Printing test on Wednesday - 18th Jan, 2006", 10, 50, Graphics.TOP|Graphics.LEFT);
                g.drawImage(imgTest, 60, 150, Graphics.HCENTER | Graphics.VCENTER);
                int width = blankImage.getWidth();
                int height = blankImage.getHeight();
                int y = 0;
                os.write(CMD_UNIVERSAL_EXIT);
                for(int i = 1; i<=height; i++){
                         blankImage.getRGB(temp, 0, width, 0, y, width, 1);
                         byte[] pixels = new byte[width];
                         for (int x = 0; x < temp.length; x++) {
                              pixels[x] = (byte) ((((temp[x] & 0x00FF0000) >> 16)
                                   + ((temp[x] & 0x0000FF00) >> 8) + (temp[x] & 0x000000FF)) / 3);
                         // Transfer Raster Graphics
                         os.write(TRANSFER_RASTER_DATA);
                         byte[] len = numToDecimal(pixels.length);
                         os.write(len);
                         os.write(DATA);
                         os.write(pixels);
                         y++;
                    }I have another query, if I can not do this. Is there any way I can create a .jpg image from with in the J2ME application.
I have some text and an image that I get by invoking camera from the code and then capturing a picture. I need to combine them both, and then send it to the printer.
If there is any way, I can convert this blankImage mentioned above (containing both text and Image), please provide me the solution.
Any document or any source code is appreciated.
regards,
Ashish

I have succeeded in creating a mutable image that contains text and image (.png), through
                     Image img;
                     img = Image.createImage(50, 60);
     protected void paint(Graphics g){
          g.drawImage(img, getWidth()/2, getHeight()/2, Graphics.HCENTER | Graphics.VCENTER);
          Graphics graph = img.getGraphics();
          graph.setColor(0, 0, 0);
          graph.setFont(Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_BOLD,
                         Font.SIZE_LARGE));
          graph.drawString("Printing test from "
                                   + System.getProperty("microedition.platform") + " on ", 10, 10, 0);
          graph.drawImage(image, img.getWidth()/2, img.getHeight()/2,Graphics.HCENTER|Graphics.VCENTER);
          graph.fillArc(0,0,10,10,0, 360);
     }Now I want to create a .jpg image of this img image(Mutable image).
What I am doing is that,
1. I am converting this image in to int array, using getRGB() method.
2. Then I am converting int array in to byte array.
3. And then I am opening a file(extension is .jpg)
4. Then I am sending this byte array in to the file which is .jpg
The .jpg file is getting created, but the data in it is very absurd, like yyyyyyyyyyyyyyyyyyyyyyyy.
Please help me in this matter.
Regards,
Ashish

Similar Messages

  • How do I create a JPG image from a clip

    I need to create a jpg image from a movie clip. Is making a freeze frame the same and creating a jpg?

    A jpg image is saved by FCE in a new file, while a freeze frame in FCE is a still picture used for a sequence in a project, but not saved separately.
    To make a jpg, position the playhead in the timeline on the frame you want to save and Export/Using QuickTime Conversion and select Format: Still Image.
    You are asked for a file name.
    To make a freeze frame, position the playhead in the timeline on the frame you want to reuse within the project and Modify/Make Freeze Frame. This leaves a new still in the viewer: you can drag it to the timeline, drag it to the browser, etc.. - However this does not create a separate file but stays embedded in the project where it is used.
    Piero

  • I suscribe to create pdf (convert images to pdf) but the iphone app doesnt work

    I paid the suscription to use the tool, it shows a message that it saids that i currently suscribed for the next month, but i can't use it!  And still appear the option to buy it!!

    Hello jeanluckpickard,
    It may help to force close all applications and reset your iPhone.
    iOS: Understanding multitasking
    http://support.apple.com/kb/HT4211
    iPhone, iPad, iPod touch: Turning off and on (restarting) and resetting
    http://support.apple.com/kb/HT1430
    If you're still not getting any audio from your iPhone, the next step would be restoring the device.
    iOS: Back up and restore your iOS device with iCloud or iTunes
    http://support.apple.com/kb/HT1766
    Cheers,
    Allen

  • IMac (27-inch, Mid 2011) 2.7 GHz Intel Core i5 4 GB 1333 MHz DDR3 running10.10.2 (14C1514). Trying to install Windows 7 64 bit from an install disc. When attempting to create an ISO image I can save the file in disk utility but can convert cdr to iso

    iMac (27-inch, Mid 2011) 2.7 GHz Intel Core i5 4 GB 1333 MHz DDR3 running10.10.2 (14C1514). Trying to install Windows 7 64 bit from an install disc. When attempting to create an ISO image I can save the file in disk utility but can convert cdr to iso. I select the file and the hit return as in step 8 of the Creating an
    iSO image document but the box that should open to select use iso does not open. How should I proceed?

    The Mac SuperDrive built into your Mac is the Optical drive.
    1. Insert your Windows DVD in Optical drive. Disconnect any external storage.
    2. Insert a USB2 Flash drive. This will be used to hold the BC drivers.
    3. Start BCA. Check the options to download software and Install Windows. You do not need to download Windows. The BCA will download the BC drivers to the USB.
    4. Partition your drive.
    5. You can see the Windows installer screens at https://help.apple.com/bootcamp/mac/5.0/help/#/bcmp173b3bf2.

  • When playing a home video DVD using DVD Player I tried to use the "Controls, Use current frame as jacket picture" facility to create a printable image but with no success. Can anybody point me in the right direction?

    When playing a home video DVD (created on my Panasonic DVD/Hard Disc recorder)  using the Mac DVD Player, I tried to use the "Controls, Use current frame as jacket picture" facility to create a printable image but with no success. I assume that any file created by this action would be stored somewhere in a common format but cannot find any such file. Can anybody point me in the right direction?

    Hi Sinious,
    Interesting to know about 10.8 and Flash. I'll hold off upgrading until they work together. Currently using 10.6.8 at home and same on the Universtity's computers.
    Haven't verified on Windows but shall do later in the week if I can get access to a Windows machine.
    Both the Flash player and the Projector come up not full screen, and if I leave it that way then things work OK as long as I don't make the video full screen (using the full screen button on the skin).
    However if I make the swf or projector full-screen (by using CMD-F or the menu option) then when I click on the menu item to take me to the page with the video on it, instead of a page with a smallish video and back button I get a black screen with no obvious controls. If I then press Escape I get my normal screen back and I am in the page that should have the video but there is not video and the back button does not work. So something wierd is going on here.
    If I make a file without any videos with a similar navigation structure everyting works ok except that when I go full screen I lose the finger cursor when I roll over my buttons (which is also wierd).

  • How to create an Average Image from Gray Scale (8 bits) JPEG Images

    I�m trying to create a mean image from 9 JPEG Images, but this mean image has lots of "noise", is distorced, and doesnt�resemble at all the original ones.
    I need this mean image so I�ll correlate each of the original ones to find out the best image I�m going to choose ussing NCC (normalized cross correlation coeficient).
    When I use setRGB(x,y,rgb), it returns diferent "images" according to the number of zeros, for ex.: rgb = 028028028 is different from 28028028 and from 282828. I can�t find a way to work it out.
    My algorithm is the folowing:
            File f;
            double [] [] pixels = null;
            Color [] [] tempPixel = null;
            Integer [] [] byte0 = null;
            Integer [] [] byte1 = null;
            Integer [] [] byte2 = null;
            Integer [] [] byte3 = null;
         Integer [] [] tempPixels = null;
            mean = null;
            int w,h;
            fileNames = new String[numFrames];
            for (int i=1; i<numFrames; i++){
                fileName = path + "Frame#" + i + ".jpg";
                fileNames[i-1] = fileName;
            // just for getting width, height, for configuring pixels array and
            // buffered images - mean & best.
            fileName = path + "Frame#8.jpg";
            f= new File(fileName);
            try{
                temp = ImageIO.read(f);
            }catch(IOException io){ return false;}
            w = temp.getWidth();
            h = temp.getHeight();
            mean = new BufferedImage(w, h, BufferedImage.TYPE_BYTE_GRAY);
         pixels = new double [w][h];
            byte0 = new Integer [w][h];
            byte1 = new Integer [w][h];
            byte2 = new Integer [w][h];
            byte3 = new Integer [w][h];
            tempPixel = new Color[w][h];
              tempPixels = new Integer[w][h];
            f=null; temp = null;
            //reset pixels values.
            for(int x = 0; x < w; x++){
                for(int y = 0; y < h; y++){
                    byte0[x][y] =0;
                    byte1[x][y]=0;
                    byte2[x][y]=0;
                    byte3[x][y] = 0;
                    pixels[x][y] = 0;
            // read each file (image), and according to W & H and collects the
            // pixels values.
            for(int j=0; j<numFrames-1; j++) {
                f = new File(fileNames[j]);
                try{
                    temp = ImageIO.read(f);
                }catch(IOException io){ return false;}
                if(temp!=null)
                    for(int x=0 ; x< temp.getWidth(); x++){
                    for(int y=0; y<temp.getHeight(); y++){
                        tempPixel[x][y] = new Color(temp.getRGB(x,y));
                  pixels[x][y] = pixels[x][y] + temp.getRGB(x,y) / 16581375;
                        //BLUE
                        byte0[x][y] = byte0[x][y] + (tempPixel[x][y].getBlue());//tempPixel[x][y].getBlue(); //& 0xff;
                        //GREEN
                        byte1[x][y] = byte1[x][y] + (tempPixel[x][y].getGreen());// >>8 & 0xff;
                        //RED
                        byte2[x][y] = byte2[x][y] + (tempPixel[x][y].getRed()); //>>16 & 0xff;
                        //ALPHA
                        byte3[x][y] = byte3[x][y] + (tempPixel[x][y].getAlpha()); //>>24 & 0xff;
                f=null;
            }//end of loop for j<numFrames
            String t0, t1, t2, t3;
            for(int x=0 ; x< temp.getWidth(); x++){
                for(int y=0; y< temp.getHeight(); y++){
                     byte0[x][y] = byte0[x][y] / numFrames;
                    if((byte0[x][y])<10)
                             t0= "0" + byte0[x][y].toString();
                    //else if((byte0[x][y])>=10 & ((byte0[x][y])<100))
                    //    t0 = "0" + byte0[x][y].toString();
                    else
                        t0 = byte0[x][y].toString();
                    byte1[x][y] = byte1[x][y] / numFrames;
                    if((byte1[x][y])<10)
                             t1=  "0" + byte1[x][y].toString();
                    //else if((byte1[x][y])>=10 & ((byte1[x][y])<100))
                    //    t1= "0" + byte1[x][y].toString();
                    else
                        t1 = byte1[x][y].toString();
                    byte2[x][y] = byte2[x][y] / numFrames;
                    if((byte2[x][y])<10)
                             t2= "0" + byte2[x][y].toString();
                    //else if((byte2[x][y])>=10 & ((byte2[x][y])<100))
                    //    t2 = "0" + byte2[x][y].toString();
                    else
                        t2 = byte2[x][y].toString();
                    byte3[x][y] = byte3[x][y] / numFrames;
                    if((byte1[x][y])<10)
                        t3="0" + byte3[x][y].toString();
                    else
                        t3 = byte3[x][y].toString();
                        pixels[x][y] = (pixels[x][y]/numFrames) * 16581375;
                    try{
                        String rgbs = t2+t1+t0;
                        Integer rgb = Integer.valueOf(rgbs);
                              //System.out.println("Valor do rgb: " +rgb);
                        mean.setRGB(x,y,(int)pixels[x][y]);
                    }catch(NumberFormatException nfe){
                        System.out.println("ERROR: Integer to STRING: "  + nfe);
                        return false;
                    }// end of catch

    It�s ok, I�ve already found the solution.
    Thanks.

  • Why suddenly unable to create a disk image from a CD?

    I successfully created a disk image from a CD only 5 days ago. Now when I try to create a disk image from a CD (with Disk Utility) the Superdrive rumbles along for sveral minutes, while the progress bar indicates that it has reached the end of its progress.
    Only after all that does a dialog box indicate:
    "Unable to create "___.dmg"-Invalid Argument. "
    I haven't added software but did upgrade to iTunes 6. Doubtful that could affect my abilty to create a disk image.
    Would someone kindly shed some light on why this may be happening?
    Steve

    Is it strange that this problem seems CD-specific?
    Some CDs are copy-protected and some CDs are not copy-protected; so, no, it's not strange at all that you should be able to copy some CDs and not be able to copy others.
    Tuttle
    1682/8380

  • Trying to upload DSCF.JPG images from my Mac Pro to Photostream in iPhoto

    I am trying to upload the DSCF.JPG images from my Mac Pro (originally taken on my Fuji Finepix camera) to Photostream in iPhoto.
    I then want these images to load onto my iPhone 5 through iCloud.
    I have tried dragging the images over from a desktop folder to my Photostream folder in iPhoto – no good. They just won't copy over.
    I have dragged the images over from a desktop folder into a new folder in iPhoto – that worked, but I can't then get them transferred or copied over to the iCloud folder.
    Is it the DSCF format that my Photostream doesn't like? Why would that be?
    And does anybody know what I can do about it?
    Thanks so much.

    Hi dinglydell2,
    The picture formats that are supported by Photo Stream are described in this article -
    iCloud: Shared Photo Streams FAQ
    http://support.apple.com/kb/HT5903
    In particular -
    Shared Photo Streams supports JPEG, TIFF, PNG, and most RAW photo formats. On your Mac or PC, your photos are downloaded and stored in full resolution. On your iPhone, iPad, iPod touch, and Apple TV, your Photo Stream photos are delivered in a device-optimized resolution that speeds downloads and saves storage space. While actual dimensions will vary, an optimized version of a photo taken by a standard point-and-shoot camera will have a 2048 x 1536 pixel resolution when pushed to your devices. Panoramic photos can be up to 5400 pixels wide.
    If the Preview application can open your photos, you may be able to export them to a more compatible format.
    Preview 5.x: Convert graphic file types with Preview
    http://support.apple.com/kb/PH5910
    The process is the same for more recent versions of Preview.
    Open a file in Preview, and choose File > Export.
    Choose a file type from the Format pop-up menu. If you don’t see the file type you want, hold down the Option key as you click the Format pop-up menu to see specialized or older formats.
    Depending on the file format you choose, additional options may appear. If you choose JPEG or JPEG 2000, you can adjust the image’s quality. If you choose PDF, you can choose a Quartz filter to apply to the image, and you can encrypt the image so that only those with the password can view it.
    Type a new name, or choose a new location for saving the converted file, and then click Save.
    Thanks for using Apple Support Communities.
    Best,
    Brett L

  • Request a .jpg image from Indesign server via script?

    hello,
    I have a scenario in which I am switching from using QuarkXpress Server to Indesign Server. With Quark Server I am able to request a jpg image from a quark Document. Basically, by providing the right parameters, I can get a JPG preview of what a picture box or text box looks like in the Quark Document.
    I need to do something like this with InDesign Server. Is it possible to write a script specifying an Indesign Document and maybe a TextFrameID or PictureFrame ID and get a JPG rendering of it?
    I know I can export the whole document as a PDF but I need to be able to get images of single textframes/pictureframes or grouped frames.
    Does anyone know if this is possible or how to do this?
    thanks in advance!!!
    -Lloyd

    Or maybe the only way to achieve this (hopefully not, though) is to export the whole document as a JPG, and then find a way to programmatically crop the part I need based on the coordinates of the textframe/pictureframe (or grouped framed) that I need?
    thanks in advance,
    Lloyd

  • Can i create a single image from multiple images in lightroom?

    Can i create a single image from multiple images in lightroom?

    Like a panorama, a composite or focus stack? Have you tried the Lightroom forum?
    Photoshop Lightroom

  • I just created a new iPhoto library with holding the option key down and then opening iPhoto with version 7.1.5.  I changed the name of the first library to iPhoto library 1 and now I all my photos are gone.  My operating system is Mavericks.

    I just created a new iPhoto library with holding the option key down and then opening iPhoto with version 7.1.5.  I changed the name of the first library to iPhoto library 1 and now I all my photos are gone.  My operating system is Mavericks.

    launch iPhoto wile holding down the option key and select the original library - when you create a new library of course it is empty
    And you seriously need to backup your iPhoto library and purchase and install iPhoto '11 version 9.5.x from the App store and download and run the iPhoto library upgraded \then run the new iPhoto - 7.1.5 is not fully compatible with Mavericks
    LN
    PS you also need to update your profile - it states that you have OS X 10.6.8

  • How do i create a jpeg image from clips in fcp

    how do i/can I create a jpeg image from clips in fcp?
    Stephen

    Select clip in timeline and place the playhead over the frame you want to save as a JPEG. Open the share window ( Button on far right of tool bar) and select 'Save current frame'. If you don't see that option click on add destination and select the Save current frame choice. It will be added to your share options.

  • Why wont jpg images from macbook open on Windows PC?

    I have loaded jpg images from my nikon camera into iphoto on macbook pro.
    No editing was done.
    Then i copied then to a usb and attempted to open on a windows pc .
    They wont open in either windows or photoshop on windows pc.
    Can you help please?
    Many thanks
    Dell.

    You may be burning the disk as a data CD. Make sure that you're burning the disk as an Audio CD (iTunes Burning preference). You can also burn an MP3 CD if your tracks are in MP3 format and your player will handle an MP3 disk.
    Hope this helps.

  • Stop images from going under the panels?

    I don't know what happened but recently when I dock an image it resizes to the entire size of the photoshop window. The image edge stops on the left at the tool bar but on the right it goes underneath my panels. Another thing that started at the same time is an issue with mini bridge, as you can see it's attached to my panel but when I click the arrow to expand it it pushes the rest of the panel to the right and off screen.
    Also I've been having issues with the "Fit Screen" button. I used to be able to have the window a certain size and when I'd hit Fit Screen the the window would keep its size but the image would zoom so there were those grey areas around the image, now when I Fit Screen it resizes the window as well. I've checked that the Zoom Resizes Window option is unchecked but nothing works. Please help! I know that there is an application frame option for Mac that supposedly fixes these issues but I'm on a PC (Windows7) so I don't have that option.

    If you dock the panels on the right (layers,etc) like the toolbox is docked that will stop the image from going under the panels.
    Just grab the top of the panels (red box in screenshot) and move to the right until you see a blue line, then release.
    MTSTUNER

  • How do you create a still image from a video using IMovies 11?

    How do you create a still image from a video using IMovies 11 on a Pro Mac?

    The simplest way is to do a simple screen capture.  

Maybe you are looking for