compression of image and convert between Bitmap and byte]

Hello

I'm trying to compress an image raw data(byte[]), and here's what I did:

Bitmap image = Bitmap.createBitmapFromBytes( _raw, 0, -1, 7 );
Bitmap scaledBitmap = new Bitmap(192, 144);
image.scaleInto(scaledBitmap, Bitmap.FILTER_BILINEAR, Bitmap.SCALE_TO_FIT);

So now that I have a compressed Bitmap, scaledBitmap and I want the gross data(byte[]) extract from the scaledBitmap. I noticed there is a getRGB565 method, but I don't know how to use it. Can someone give me an example on how to extract the raw data? If it is not possible, is there another way to compress the _raw?

Thanks in advanc

I found the solution:

Bitmap image = Bitmap.createBitmapFromBytes( _raw, 0, -1, 8 );

int newWidth = 192;
int newHeight = 144;

Bitmap scaledBitmap = new Bitmap(newWidth, newHeight);
image.scaleInto(scaledBitmap, Bitmap.FILTER_BILINEAR, Bitmap.SCALE_TO_FIT);
PNGEncodedImage encoder = PNGEncodedImage.encode(scaledBitmap);
byte[] resizedBytes = encoder.getData();

Tags: BlackBerry Developers

Similar Questions

  • Spacing between the image and the text

    Hello!

    I can't find how to increase the gap between the image and the text. Here is the picture that will explain what I mean:

    2016.01.03_18h12m23s_004.jpg

    Thanks for the reply and your help.

    Kind regards

    Hrvoje

    Open the text wrapping Panel (window > text wrapping) and you will see the distance adjustment controls.

  • White spaces between and vertical shifting of images (and text) as a preview of the browser

    I built my site in Muse, but when I preview the, there are white spaces of different sizes that appear between images and text. In addition, an entire section of the Web site has moved down through an entire page. Here are a few screenshots as I can manage them. Unfortunately it is not yet hosted, so I can't post a link.

    Just a note: I'm build this page of my site as a portfolio to side scrolling. At the beginning of each "page", I added an anchor point, and I've added a 'back to the start arrow' so that the elements of different menu on the far left of the page (at the beginning) a link to their respective 'page' along the portfolio of horizontal scrolling. Similarly, the "back to the start arrow" menu link.  I don't know if this is part of the question, but it seems that it shouldn't be, because I got that simply making the page extremely broad and not very large.

    Here are a few screenshots.

    Inside, Muse:

    Screen Shot 2015-12-22 at 5.10.29 PM.png

    Leave the browser preview:

    Screen Shot 2015-12-22 at 5.09.54 PM.png

    Inside the Muse:

    Screen Shot 2015-12-22 at 5.10.22 PM.png

    Leave the browser preview:

    (Here are two screenshots only because they were separated by white space so that I could not them on the screen at the same time.)

    Screen Shot 2015-12-22 at 5.09.34 PM.png

    Screen Shot 2015-12-22 at 5.09.42 PM.png

    A more. This one shifted downwards, rather than on the side. Note that I did so that the image on the bottom was not attached to a low sticky footer or anything.

    Inside, Muse:

    Screen Shot 2015-12-22 at 5.08.11 PM.png

    Leave the browser preview:

    Screen Shot 2015-12-22 at 5.07.47 PM.png

    Thank you!

    Well well, the standard answer (and I should perhaps store them somewhere as a copy & paste NOTE): you must use groups and other methods of structuring as widgets. Your items may not stick together because they have no container parent to hold them together as in reverse, they can overlap with because they have no logic telling them everything that is left, right, above and below. Muse is not a page layout program and you not post a PDF file where everything is nailed in place. dumping everything on the page without which concerns the way in which it will interact in your browser never gives the result you expect.

    Mylenium

  • How to convert between p1 and p1raw in v$ session_wait?

    We have a tool on v$ session_wait showing only p1 instead of p1raw. For a wait as free lock, I need to know the p1raw. But how to convert between p1 and p1raw?

    example of v$ session_wait:
    P1 675562835
    p1raw 28444553

    I tried to use rawtohex (p1raw) = rawtohex (28444553) = 3238343434353533, which has nothing to do with the real p1. Someone has an idea?

    Thank you
    Daniel
      1* select distinct sid, p1, p1raw, TO_char(p1,'XXXXXXXX') from v$session_wait
    SQL> /
    
           SID        P1 P1RAW    TO_CHAR(P
    ---------- ---------- -------- ---------
           159 1650815232 62657100     62657100
           163       300 0000012C          12C
           166       300 0000012C          12C
           160       100 00000064           64
           161       300 0000012C          12C
           162       500 000001F4          1F4
           164     180000 0002BF20        2BF20
           165       300 0000012C          12C
           168       300 0000012C          12C
           152         0 00            0
           167       300 0000012C          12C
    
           SID        P1 P1RAW    TO_CHAR(P
    ---------- ---------- -------- ---------
           170       300 0000012C          12C
           169       300 0000012C          12C
    
    13 rows selected.
    

    See a pattern here?

  • Restore the size of the image bitmap (image) and PPI

    Here's something that I have not found a quick solution after several years of use.

    The scenario is as follows:

    1. you receive a document with embedded images and no access to links original.

    2. the images are resized and proportions have changed. For example, PPI: 85.372 x 71.954 and the scale of the Image (H, V): 84.337%, 100.065%.

    Is there a quick way to change the scale of the image at 100%, 100% or 72 x 72 PPI?

    I always do this by calculating the percentage of that image has be restored by horizontally and vertically for the original report.

    See you soon.

    Mordy Golding provides this method on his Real World Illustrator blog:

    http://rwillustrator.blogspot.com/2008/11/technique-unembedding-images.html

    It gives a detailed description, but basically it's save as PDF, open in Photoshop, choose the option Images.

    Hope this helps

    Mike D.

  • How to convert the Bitmap Image in BlackBerry

    Hello

    In my application, I get the picture from the server. Now, I want to convert this Bitmap Image to display on the screen. For this I use below codes. But it doesn't give me the same image does not mean with the clarity and the exact size. He's smaller than the picture.

    I used the codes below:

    private Bitmap getBitmapFromImg(Image img) {
            Bitmap bmp = null;
            try {
                Logger.out(TAG, "It is inside the the image conversion        " +img);
                Image image = Image.createImage(img);
                byte[] data = BMPGenerator.encodeBMP(image);
                Logger.out(TAG, "It is inside the the image conversion---333333333"+data);
                bmp = Bitmap.createBitmapFromBytes(data, 0, data.length, 1);
                } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return bmp;
            // TODO Auto-generated method stub
        }
    

    Here is the BMPGenerator class:

    public final class BMPGenerator {
    
            /**
             * @param image
             * @return
             * @throws IOException
             * @see {@link #encodeBMP(int[], int, int)}
             */
            public static byte[] encodeBMP(Image image) throws IOException {
                    int width = image.getWidth();
                    int height = image.getHeight();
                    int[] rgb = new int[height * width];
                    image.getRGB(rgb, 0, width, 0, 0, width, height);
                    return encodeBMP(rgb, width, height);
            }
    
            /**
             * A self-contained BMP generator, which takes a byte array (without any unusual
             * offsets) extracted from an {@link Image}. The target platform is J2ME. You may
             * wish to use the convenience method {@link #encodeBMP(Image)} instead of this.
             * 

    * A BMP file consists of 4 parts:- *

      *
    • header
    • *
    • information header
    • *
    • optional palette
    • *
    • image data
    • *
    * At this time only 24 bit uncompressed BMPs with Windows V3 headers can be created. * Future releases may become much more space-efficient, but will most likely be * ditched in favour of a PNG generator. * * @param rgb * @param width * @param height * @return * @throws IOException * @see http://en.wikipedia.org/wiki/Windows_bitmap */ public static byte[] encodeBMP(int[] rgb, int width, int height) throws IOException { int pad = (4 - (width % 4)) % 4; // the size of the BMP file in bytes int size = 14 + 40 + height * (pad + width * 3); ByteArrayOutputStream bytes = new ByteArrayOutputStream(size); DataOutputStream stream = new DataOutputStream(bytes); // HEADER // the magic number used to identify the BMP file: 0x42 0x4D stream.writeByte(0x42); stream.writeByte(0x4D); stream.writeInt(swapEndian(size)); // reserved stream.writeInt(0); // the offset, i.e. starting address of the bitmap data stream.writeInt(swapEndian(14 + 40)); // INFORMATION HEADER (Windows V3 header) // the size of this header (40 bytes) stream.writeInt(swapEndian(40)); // the bitmap width in pixels (signed integer). stream.writeInt(swapEndian(width)); // the bitmap height in pixels (signed integer). stream.writeInt(swapEndian(height)); // the number of colour planes being used. Must be set to 1. stream.writeShort(swapEndian((short) 1)); // the number of bits per pixel, which is the colour depth of the image. stream.writeShort(swapEndian((short) 24)); // the compression method being used. stream.writeInt(0); // image size. The size of the raw bitmap data. 0 is valid for uncompressed. stream.writeInt(0); // the horizontal resolution of the image. (pixel per meter, signed integer) stream.writeInt(0); // the vertical resolution of the image. (pixel per meter, signed integer) stream.writeInt(0); // the number of colours in the colour palette, or 0 to default to 2n. stream.writeInt(0); // the number of important colours used, or 0 when every colour is important; // generally ignored. stream.writeInt(0); // PALETTE // none for 24 bit depth // IMAGE DATA // starting in the bottom left, working right and then up // a series of 3 bytes per pixel in the order B G R. for (int j = height - 1; j >= 0; j--) { for (int i = 0; i < width; i++) { int val = rgb[i + width * j]; stream.writeByte(val & 0x000000FF); stream.writeByte((val >>> 8) & 0x000000FF); stream.writeByte((val >>> 16) & 0x000000FF); } // number of bytes in each row must be padded to multiple of 4 for (int i = 0; i < pad; i++) { stream.writeByte(0); } } byte[] out = bytes.toByteArray(); bytes.close(); // quick consistency check if (out.length != size) throw new RuntimeException("bad math"); return out; } /** * Swap the Endian-ness of a 32 bit integer. * * @param value * @return */ private static int swapEndian(int value) { int b1 = value & 0xff; int b2 = (value >> 8) & 0xff; int b3 = (value >> 16) & 0xff; int b4 = (value >> 24) & 0xff; return b1 << 24 | b2 << 16 | b3 << 8 | b4 << 0; } /** * Swap the Endian-ness of a 16 bit integer. * * @param value * @return */ private static short swapEndian(short value) { int b1 = value & 0xff; int b2 = (value >> 8) & 0xff; return (short) (b1 << 8 | b2 << 0); }

    Where an error in my code? Is there another way to do the same thing?

    Why you want to use a bmp image?
    You can just use png, jpg or whatever of the original image is.
    If there is a situation where you need the bitmap image call http://www.blackberry.com/developers/docs/7.1.0api/net/rim/device/api/system/EncodedImage.html#getBi...

  • Load Image and removes BitmapData

    Hello.

    I use the qnx.ui.display.image class to load an image that is in the package with the application, and it works fine. However, I'm looking at a bunch of functions that take BitmapData format of an Image, and I wonder how to load an image in a format of BitmapData, or how to convert the qnx.ui.display.image class to give me the BitmapData form.

    Thanks in advance.

    Note that the Image can take a URL, Bitmap, or BitmapImage in setImage().  And it has a cache property that is a qnx.utils.ImageCache.

    Apparently, qnx.utils.ImageCache.getImage () returns a BitmapData.  Looks like you need to know what URL cache stores under.  Not sure how you would find out that unless the image had been loaded in the first place of a URL.

    The BitmapData docs say you can load with flash.display.Loader, then it can be assumed if you were loading from a URL that you would get directly, bypassing the ImageCache stuff.

    (I don't have a direct answer, sorry.)

  • AVI to extract the image and save it

    Hi, I have a video in avi form I want to segment by each image and save the image in tiff format. Ive done that in a certain time loop, but it does not work. someone knows why?

    Thank you

    Hello Stephen,

    For the path of the file entry, specify the full path, including the file name for each file.

    -Currently directly you give as the application directory path, to this add the following

    -Since you need of each image to be saved first to get the iteration number and convert to a decimal string and it concatenate with .tiff

    -Using the resulting string as input to build access roads and base of the application directory.

    -Get the path appearing in the annex to IMAQ write File2 VI.

    I would like to know if it works.

  • Why Auto-scale intensity images and how can I disable this?

    Dear Sirs

    I display an image from a FireWire camera (collected with "IMAQdx to Image.vi") in an indicator of picture (Vision-> Image display) on the front panel. When the distribution of intensity changes, the overall intensity seems to auto scale. But if change the intensity in a part of the image, and I put a cursor in another part of the image, the Image information box told me that the pixel value does not change even if the visible intensity of the indicator changes.

    I also made a comparison with the 'good old' graph of the intensity. So, I have to use 'IMAQdx get Image Data.vi' and place the data table before presenting the image in the graph of the intensity. If I disable AutoScale Z, a part of the image does not affect the rest, but if I turn it on, the image behaves like the display of the Image above. Obviously, there is a kind of automatic scaling in the display of images.

    Can someone tell me if and how I can disable this auto-scaling feature?

    Best regards

    / Leif Nyholm

    All pallets are applied to 8-bit grayscale images, the 16-bit image is converted to 8 bits before applying the palette.  You're right that it would be nice to be able to apply a rainbow palette to the original 16-bit image, but it is not available.  No doubt, you can write your own routine that would use a custom lookup table to convert the 16-bit image to an image of rainbow-colored, but probably would not bother.  The final image would most likely look exactly like the current image.

    Bruce

  • 3 related issues: slow movement; the photos are all from the first image; and no sound from the soundtrack to the DVD downloaded.

    I put a DVD in my computer. It plays fine in Windows Media Player. When I transfer to Windows Movie Maker Live, three things happen: 1) the thumbnails are all the same - the first image. (2) the movement is slow. I tried it accelerates, but it is simply not the movement in real time - either too slow or too fast. (3) the soundtrack plays for a fraction of a second.

    What is the problem and how to fix it?

    I converted DVD to WMV format. This fixes the movement of the image and I can hear the music (not quite synchronized), however the thumbnails are still just the first image. In addition, every single feature that I blow (editing, effects, forwards, etc.) the picture freezes and yet the soundtrack plays again.

    ===================================
    It is normal that video to be the first image thumbs.

    Since it was a DVD... I guess it's a big project
    and the gel could be due to a lack of system resources.
    If you wait it can dissipate.

    Some video converters are better than others... Freemake
    maybe worth a try.

    It is also possible that your video driver may need an update.

    Verify that the video driver is problematic is to
    reduce the graphics hardware acceleration:

    Windows 7 - reduce graphics acceleration
    (see following article)

    More low hardware acceleration
    http://help.AOL.com/help/microsites/microsite.do?cmd=displayKC&docType=kc&externalId=15391
    (Windows 7 / Vista / XP / 98 / ME / 2000)

    Good luck...

  • How to reproduce a series of images and effects

    I'm learning to work with keyframes, creating an icon of simple rotation. I also have two adjacent images that have a variety of effects applied to them.

    Is there a way to copy an image and all its effects, or even a group of images and effects and paste them into another place on the timeline?

    I thought that the keyword to search for "sequences", but I'm confused. I watched the tutorial @ How to create a new sequence in Adobe Premiere Pro. School online - YouTube video, but I do not understand the difference between a project and a sequence. I visualize a sequence as a part of a video - an episode or segment. But this tutorial seems to describe the creation of a separate project.

    Yet you can import footage - projects How to import a sequence in Premiere Pro to another project - YouTube

    So I am confused. For now, I want to just copy a group of images and effects and paste them to another location on the timeline. Is this something I would do with a sequence, or something else?

    Thank you.

    If you want to copy clips and effects just drag your mouse to select all the clips, copy them using control c. move the selection of instant to where you want and then simply paste, control V.

  • I bought an image and the download is in a format that I can't open. #77602421. What should I do to get the photo in jpeg.

    I bought an image and the download is in a format that I can't open. #77602421. What should I do to get the photo in jpeg.

    Thank you

    You will need to use Illustrator to convert it to JPG. Or ask someone with Illustrator or compatible app to convert it for you. You can try to import into Photoshop for editing, but you will not be able to increase the size without loss of quality.

  • Create Adobe Muse Widget with images and the external JS file.

    Hello, I want to create widget that include all about 7-8 images and 1 JS file.

    I read the documentation, but I have a few questions.

    Is there any way to import images of widget (no link to them)?

    Y at - it means to import the folder 'images' with pictures on it and this folder to extract to which I have 'say' (for example level even where is the page or file in the folder root of the site)?

    Is there a way to include the JS file?

    In my opinion, that these things are possible, but with Adobe Muse themes.

    How to manipulate the page with the options for the widget?

    For example, in the options, you can choose between 2-3 options and the option to apply to the page.

    I want the option widget that can change 1 variable JS variable will be in the script that is added to the page (not external JS file). I know how to add this script to the page, but I don't know how to handle with the widget options. Here's another example, I have this:

    ...........

    < bodyEndHTML >

    <! [CDATA [< script type = "text/javascript" >]]

    $(function() {})

    var someVar = "somevalue1";

    });

    < /script >]] >

    < / bodyEndHTML >

    < / HTMLWidget >

    I want with option widget to manipulate this variable 'someVar' (its value), between the selected values.

    You work with html exported Muse,

    It would be a complete customization with form action, you can try to use the coding corner

    Thank you

    Sanjit

  • Photoshop CC: Have a template that I transferred the image to.  The image is too small.  How to resize the image in the template?  Or I have to go to the file original image and resize here over and over again until I have found the right person?

    I have a model I am able to plug different images at different times.  The problem is when I plug an image in this template, I think that the image is either too big or too small.  Is it possible to connect the image in the template and resize the image (and not the template itself) OR I have to go into the file with the original image and resize them it there and then try to plug it into the model to see if it fits - and if it does not fit, return to the original with the image file and resize it again and see if this fits - and so on and so on...?  "" I tried the "image size" option, but it's all or nothing - especially miss!

    Thank you!

    First, make sure that the original image is larger that you need. It is easier to delete pixels that so add nonexistent pixels.

    Place the image in the template.

    In the menu filters, choose Convert to smart object. (Make sure that the image layer is selected before doing this step)

    Now reduce the size of the image of what you need (ctrl-t or cmd - t) when satisfied click return/enter.

    Because the image layer is a smart object, you can replace the inner image in another image and the scale will remain the same. You will find the option to replace the image in the layers > smart menu object.

    If you need assistance more let us know.

  • Is it possible to add keywords, alt tags and title tags to lightbox images and/or triggers?

    I build a mobile site that is fairly heavily dependent on lighbox poster for the scrolling feature. The issue I encountered is I should be able to add alt tags and title images in the device of light therapy (slide show) to keep the SEO of my website. I designed only some of the pages so far, and I'm going through is that once an image is considered to be a 'trigger' of muse, I can add is more the elements of SEO in the same way, I can when it comes to an image.

    A few ways to get around this, I found are:

    (1) export the Dreamweaver site and then I can go the code and add the SEO for images in the lighbox on the backend.

    (2) I can build the frame by frame and then site more to file each trigger for the lighbox slideshow.

    The problem with #1 is that when I export my Dreamweaver site is then modified in muse. I see this pose a huge problem, as I move forward with new iterations of my site. Changes in dreamweaver are not transferable to muse and creating two separate sites. This means that I would need to recreate all the seo built whenever I update the site. This is not really an option and is not efficient at all. Is there a way to come and go between these two products I know? This would be more useful.

    Question # 2: I built each project page on the great site as for most background images with triggers asked. I did it to try to lower the overall gerth of the site, but it is apparent that I won't be able to work around this problem and maintain seo, of that I'm looking.

    All experience this problem and solved?

    Here is the site to date:

    ghatest. BusinessCatalyst.com

    Thank you for your comments!

    Placed images and the images in the slide show supports tooltips (the "title" attribute), and the text via the menu content 'change Image Properties... '. ».

    Strictly speaking, in HTML (images of filling) background images do not support these tags. That said, in certain contexts, it may make sense to Muse allow to set these attributes on an arbitrary object (which may, or may not, have a picture fill).

Maybe you are looking for