OpenCL: best way to resize memory objects

I'm a beginner in OpenCL and I have a question about memory management (like 99.99% of noob questions about OpenCL, I guess...). I enqueue the kernel for execution inside a loop in the host code; at each iteration the size of the buffers used for memory objects passed as kernel arguments is different. Currently, I do something like this using the C++ wrapper API (which BTW I find much more easy to use than the C interface, that nevertheless seems to be the most used interface yet):
// Set platform, kernel, queue etc.
for (int i = 0; i < nIterations; i++){
// Set buffer sizes and fill them
// OpenCL section
cl::Buffer clBuffer1 = cl::Buffer(context, CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR, bufferSize1*typeSize1, (void *) &(buffer1[0]));
cl::Buffer clBuffer2 = cl::Buffer(context, CL_MEM_USE_HOST_PTR, bufferSize2*typeSize2, (void *) &(buffer2[0]));
cl::Buffer clBuffer3 = cl::Buffer(context, CL_MEM_WRITE_ONLY | CL_MEM_USE_HOST_PTR, bufferSize3*typeSize3, (void *) &(buffer3[0]));
kernel.setArg(0, clBuffer1);
kernel.setArg(0, clBuffer2);
kernel.setArg(0, clBuffer3);
queue.enqueueNDRangeKernel(kernel, cl::NullRange, cl::NDRange(someValueForRange), cl::NullRange);
queue.enqueueMapBuffer(clBuffer2, CL_FALSE, CL_MAP_READ, 0, bufferSize2*typeSize2);
queue.enqueueMapBuffer(clBuffer3, CL_TRUE, CL_MAP_READ, 0, bufferSize3*typeSize3);
// Do something with retrieved data
I'm sure there are thousands of less-than-sub optimal memory access patterns in the code above, but for the moment I'm facing this issue: is there a way to modify the size of the cl::Buffer objects without having to reinstantiate them at each iteration of the loop? I fear that this constinuous create/destroy of cl::Buffer objects causes a full reallocation of memory on the CL device at each loop iteration, potentially degrading the overall performance. I think that also a size modification (a' la STL, to be more clear) could result in some memory reallocation, but hopefully less frequently. Or is it better to statically define oversized buffers outside the loop and play with the size arguments of enqueueMapBuffer inside the loop to transfer only the needed range of data to the GPU at each iteration of the loop?
Sorry for the possibly confusing question but as I said I'm a noob with OpenCL and this particular kind of problem seems to be not very common. Thanks.
Last edited by snack (2014-01-08 14:52:31)

Hi
First a vector drawing will not work on the web unless you convert it too svg, (only supported on 40% of browsers IE requires a plug-in) or use it within flash. You will have to convert it to gif / jpeg / png. If you convert to png this will retain the transparency for you.
As to the size, then resizing should be done in illustrator or similar then exported into photoshop or fireworks, and from these use your export for web option, and optimize the image.
PZ

Similar Messages

  • Best way to do a Object which holds a collection of another object type.

    I'm writing a caching object to store another object. The cache is only valid for a session, so I want a store the data in a nested table.
    I have try to simplify my example down to its core.
    How do I make this work and what is the best to index the index the items stored for fastest retrieval.
    CREATE OR REPLACE TYPE ty_item AS OBJECT (
    id_object VARCHAR2 (18),
    ORDER MEMBER FUNCTION compare (other ty_item)
    RETURN INTEGER
    CREATE OR REPLACE TYPE BODY ty_item
    AS
    ORDER MEMBER FUNCTION compare (other ty_item)
    RETURN INTEGER
    IS
    BEGIN
    IF SELF.id_object < other.id_object
    THEN
    RETURN -1;
    ELSIF SELF.id_object > other.id_object
    THEN
    RETURN 1;
    ELSE
    RETURN 0;
    END IF;
    END;
    END;
    CREATE OR REPLACE TYPE ty_item_store AS TABLE OF ty_item;
    CREATE OR REPLACE TYPE ty_item_holder AS OBJECT (
    CACHE ty_item_store,
    MEMBER FUNCTION get (p_id_object IN VARCHAR2)
    RETURN REF ty_item,
    MEMBER FUNCTION find (p_id_object IN VARCHAR2)
    RETURN REF ty_item,
    MEMBER FUNCTION ADD (p_id_object IN VARCHAR2)
    RETURN REF ty_item
    CREATE OR REPLACE TYPE BODY ty_item_holder
    AS
    MEMBER FUNCTION get (p_id_object IN VARCHAR2)
    RETURN REF ty_item
    IS
    rtn REF ty_item;
    BEGIN
    rtn := find (p_id_object);
    IF rtn IS NULL
    THEN
    rtn := ADD (p_id_object);
    END IF;
    RETURN rtn;
    END;
    MEMBER FUNCTION find (p_id_object IN VARCHAR2)
    RETURN REF ty_item
    IS
    rtn ty_item;
    BEGIN
    SELECT VALUE (ch)
    INTO rtn
    FROM CACHE ch
    WHERE ch.id_object = p_id_object;
    RETURN rtn;
    END;
    MEMBER FUNCTION ADD (p_id_object IN VARCHAR2)
    RETURN REF ty_item
    IS
    item ty_item;
    BEGIN
    item := ty_item (p_id_object);
    INSERT INTO CACHE
    VALUES (item);
    END;
    END;
    /

    Best way to do a Object which holds a collection of another object type. The best place for data in a database is.. no real surprise.. in tables. If that data is temporary of nature, global temporary tables cater for that.
    Storing/caching data using PL/SQL requires very expensive private process memory (PGA) from the server. This does not scale.
    I'm writing a caching object to store another object. Irrespective of how l33t your haxor skillz are, you will not be able to code as a sophisticated, performant and scalable PL/SQL data cache, as what already exists (as the database buffer cache) in Oracle.
    The cache is only valid for a session, so I want a store the data in a nested table.Not sure how you take one (session local data) to mean the other (oh, let's use a nested table).
    Session local data can be done using PL/SQL static variables. Can be done using name-value pairs residing in a context (Oracle namespace). Can be done using a global temporary table.
    The choice is dependent on the requirements that need to be addressed. However, the term +"caching+" has very specific connotations that say that a global temporary table is likely the best suited candidate.

  • What is the best way to resize a clip

    What is the best way to resize a clip? I have some clips in 1280x720p and a B camera shot of the same person that was shot at 1440x1080p and I want to multi-edit them so they need to be the same size. Is there a way inside FCP to re-interpret the 1440x1080 to 1280x720 or do I have to Export them as smaller clips and re-import them? Just have a lot of clips so would be good to find a internal FCP way of doing it.

    Well Zeb, again with the insults. If you had just stated simply "What codec" are you using that would have been fine. But instead you decided to insult me and assume I knew nothing.
    FYI I started working with video in 1985 and was one of the first to use Digital Video in 1991 as a Software Developer. So I can assure you I know a lot about codecs and NLE having even written one once. One of the things I learned in IT was to always ask for the best route through a problem from the experts around you before wasting valuable time and money finding your own, and usually the dead-ends at that!
    So there you go, next time I'll mention the codec and next time if you could be more polite then things will progress more smothely on here

  • Best way to make a object details page

    I have a dataTable, built with a sessionBean List. We have to make a link "show detail" in each row, and redirect to a new jsp showing selected row object details.
    Whats the best way to retrive the object selected?
    a commandLink with param (haschcode value) and search in list isn`t possible because is a sessionBean..
    I have some ideas but not with JSF....
    thanks

    1) Bind h:dataTable to an UIData property in main backing bean.
    2) Add a h:commandButton or h:commandLink to a column and bind it with an action method in main backing bean.
    3) In the main backing bean action method simply retrieve the row object byRowObject selectedRowObject = (RowObject) uiDataProperty.getRowData();and navigate to some display details page.
    4) In the display details page just access the data by #{mainManagedBean.selectedRowObject.someProperty} and so on.
    Detailed examples can be found here: [http://balusc.blogspot.com/2006/06/using-datatables.html].

  • What is the best way to resize a JPEG and store it in the Filesystem

    Hi All,
    I have developped a CMS System that renders JPEGs if it does not have the images available within the desired width already. Within my development setup (Dell Latitude D800 with ubuntu dapper drake) everything works fine and fast, as expected. Then I uploaded the application to my V20Z Server with 4gb RAM and the systems performance goes to its knees. I have hooked in a Java Profiler to see where the problem is, and it showed me that it is hanging wthin
    sun.java2d.SunGraphics2D.drawImage(Image, int, int, ImageObserver) which I use to draw my Image to a BufferedImage. Below is my complete source code That I am using. Plus the orofiling results
    Do not be confused as I am using the Turbine Framework, which gives me a RawScreen which gives me Access to the HttpServletResponse...
    package de.ellumination.carmen.modules.screens;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.io.OutputStream;
    import java.util.Iterator;
    import java.util.Locale;
    import javax.imageio.IIOImage;
    import javax.imageio.ImageIO;
    import javax.imageio.ImageWriteParam;
    import javax.imageio.ImageWriter;
    import javax.imageio.plugins.jpeg.JPEGImageWriteParam;
    import javax.imageio.stream.ImageOutputStream;
    import javax.servlet.http.HttpServletResponse;
    import org.apache.log4j.Logger;
    import org.apache.turbine.modules.screens.RawScreen;
    import org.apache.turbine.util.RunData;
    import de.ellumination.carmen.om.ImagePeer;
    public class Image extends RawScreen
    public static final float DEFAULT_COMPRESSION_QUALITY = 1.0F;
    * Logger for this class
    private static final Logger log = Logger.getLogger(Image.class);
    @Override
    protected String getContentType(RunData data)
    return "image/jpeg";
    @Override
    protected void doOutput(RunData data) throws Exception
    int imageId = data.getParameters().getInt("id");
    int width = data.getParameters().getInt("width", -1);
    int height = data.getParameters().getInt("height", -1);
    HttpServletResponse response = data.getResponse();
    de.ellumination.carmen.om.Image image = ImagePeer.retrieveByPK(imageId);
    File imgFile = new File(image.getLocation());
    if(width > 0 || height > 0)
    outputScaledImage(imgFile, response, width, height);
    else
    outputImage(imgFile, response);
    private void outputScaledImage(File imageFile, HttpServletResponse response, int width, int height) throws Exception
    File scaledFile = new File(imageFile.getParent() + System.getProperty("file.separator") + width + "_" + imageFile.getName());
    if(scaledFile.exists())
    outputImage(scaledFile, response);
    else
    scaleImage(imageFile, scaledFile, width);
    outputImage(scaledFile, response);
    private void outputImage(File imageFile, HttpServletResponse response) throws Exception
    FileInputStream in = new FileInputStream(imageFile);
    response.setContentLength((int) imageFile.length());
    OutputStream out = response.getOutputStream();
    int bSize = 10240;
    byte[] buffer = new byte[bSize];
    int inBuffer = 0;
    while (inBuffer >= 0)
    inBuffer = in.read(buffer);
    if (inBuffer > 0)
    out.write(buffer, 0, inBuffer);
    * scales the image to its new size. while scaling the Image, the code first resizes the image using the new Width Parameter.
    * If the Image is to high after scaling, it then uses the Images height to determin the scaling Factor.
    * @param inputFile the original Image
    * @param outputFile the File to store the scaled image to
    * @param compressionQuality the compression Quality to use
    * @param newWidth the desired images width
    * @param newHeight the desired images height
    public static void scaleImage(File inputFile, File outputFile, float compressionQuality, int newWidth, int newHeight)
    try
    if (inputFile.exists())
    BufferedImage hiRes = ImageIO.read(inputFile);
    double scaleFactor = (double) newWidth / (double) hiRes.getWidth(null);
    int tempHeight = (int) (hiRes.getHeight(null) * scaleFactor);
    if (tempHeight > newHeight)
    scaleFactor = (double) newHeight / (double) hiRes.getHeight(null);
    int width = (int) (hiRes.getWidth(null) * scaleFactor);
    int height = (int) (hiRes.getHeight(null) * scaleFactor);
    scaleImage(outputFile, compressionQuality, hiRes, width, height);
    catch (IOException e)
    log.error("Unable to create the thumbnail " + outputFile.getAbsolutePath() + " from " + inputFile.getAbsolutePath() + " because of the following Reason.", e);
    * scales the image to its new size. while scaling the Image, the code first resizes the image using the new Width Parameter.
    * If the Image is to high after scaling, it then uses the Images height to determine the scaling Factor. This method uses the
    * default compression quality to store image data.
    * @param inputFile the original Image
    * @param outputFile the File to store the scaled image to
    * @param newWidth the desired images width
    * @param newHeight the desired images height
    public static void scaleImage(File inputFile, File outputFile, int newWidth, int newHeight)
    scaleImage(inputFile, outputFile, DEFAULT_COMPRESSION_QUALITY, newWidth, newHeight);
    * scales the image to its new size. while scaling the Image, the code first resizes the image using the new Width Parameter.
    * uses the highest image compression quality by default.
    * @param inputFile the original Image
    * @param outputFile the File to store the scaled image to
    * @param compressionQuality the compression Quality of the new Image
    * @param newWidth the desired images width
    public static void scaleImage(File inputFile, File outputFile, float compressionQuality, int newWidth)
    try
    if (inputFile.exists())
    BufferedImage hiRes = ImageIO.read(inputFile);
    double scaleFactor = (double) newWidth / (double) hiRes.getWidth(null);
    int width = (int) (hiRes.getWidth(null) * scaleFactor);
    int height = (int) (hiRes.getHeight(null) * scaleFactor);
    // draw original image to thumbnail image object and
    // scale it to the new size on-the-fly
    scaleImage(outputFile, compressionQuality, hiRes, width, height);
    else
    log.error("Unable to create the thumbnail " + outputFile.getAbsolutePath() + " from " + inputFile.getAbsolutePath() + " because inputFile not exists: " + inputFile.getName());
    catch (IOException e)
    log.error("Unable to create the thumbnail " + outputFile.getAbsolutePath() + " from " + inputFile.getAbsolutePath() + " because of the following Reason.", e);
    * scales the image to its new size. while scaling the Image, the code first resizes the image using the new Width Parameter.
    * uses the highest image compression quality by default.
    * @param inputFile the original Image
    * @param outputFile the File to store the scaled image to
    * @param newWidth the desired images width
    public static void scaleImage(File inputFile, File outputFile, int newWidth)
    scaleImage(inputFile, outputFile, DEFAULT_COMPRESSION_QUALITY, newWidth);
    * This private method actually scales the inputImage to the desired height, width and compression Quality
    * @param outputFile The File in which the Image should be stored.
    * @param compressionQuality The Compression Quality to be applied to the image
    * @param inputImage the original input Image
    * @param width the height of the new Image
    * @param height the width of the new Image
    * @throws IOException
    private static void scaleImage(File outputFile, float compressionQuality, BufferedImage inputImage, int width, int height) throws IOException
    BufferedImage lowRes = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
    java.awt.Image image = inputImage.getScaledInstance(width, height, java.awt.Image.SCALE_SMOOTH);
    ImageWriter writer = null;
    Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
    if (iter.hasNext()) writer = (ImageWriter) iter.next();
    File outputPath = outputFile.getParentFile();
    if (outputPath != null)
    if (!outputPath.exists()) outputPath.mkdirs();
    lowRes.getGraphics().drawImage(image, 0, 0, null);
    ImageOutputStream ios = ImageIO.createImageOutputStream(outputFile);
    writer.setOutput(ios);
    ImageWriteParam iwparam = new JPEGImageWriteParam(Locale.getDefault());
    iwparam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
    iwparam.setCompressionQuality(compressionQuality);
    // save thumbnail image to OUTFILE
    writer.write(null, new IIOImage(lowRes, null, null), iwparam);
    writer.dispose();
    ios.close();
    image.flush();
    inputImage.flush();
    lowRes.flush();
    * scales the image to its new size. while scaling the Image, the code first resizes the image using the new Width Parameter.
    * If the Image is to high after scaling, it then uses the Images height to determin the scaling Factor.
    * @param inputImage the original Image
    * @param outputFile the File to store the scaled image to
    * @param compressionQuality the compression Quality to use
    * @param newWidth the desired images width
    * @param newHeight the desired images height
    public static void scaleImage(BufferedImage inputImage, File outputFile, float compressionQuality, int newWidth, int newHeight)
    try
    double scaleFactor = (double) newWidth / (double) inputImage.getWidth(null);
    int tempHeight = (int) (inputImage.getHeight(null) * scaleFactor);
    if (tempHeight > newHeight)
    scaleFactor = (double) newHeight / (double) inputImage.getHeight(null);
    int width = (int) (inputImage.getWidth(null) * scaleFactor);
    int height = (int) (inputImage.getHeight(null) * scaleFactor);
    scaleImage(outputFile, compressionQuality, inputImage, width, height);
    catch (IOException e)
    log.error("Unable to create the thumbnail " + outputFile.getAbsolutePath() + " because of the following Reason.", e);
    All Threads     702.570     100 %
    java.lang.Thread.run()     551.322     78 %
    de.ellumination.carmen.modules.screens.Image.doOutput(RunData)     170.666     24 %
    de.ellumination.carmen.modules.screens.Image.outputScaledImage(File, HttpServletResponse, int, int)     170.108     24 %
                             de.ellumination.carmen.modules.screens.Image.scaleImage(File, File, int)     170.108     24 %
                                  de.ellumination.carmen.modules.screens.Image.scaleImage(File, File, float, int)     170.108     24 %
                                       de.ellumination.carmen.modules.screens.Image.scaleImage(File, float, BufferedImage, int, int)     165.787     24 %
                                            sun.java2d.SunGraphics2D.drawImage(Image, int, int, ImageObserver)     165.189     24 %
                                            com.sun.imageio.plugins.jpeg.JPEGImageWriter.write(IIOMetadata, IIOImage, ImageWriteParam)     397     0 %
                                            javax.imageio.ImageIO$ImageWriterIterator.next()     69     0 %
                                            javax.imageio.ImageIO.createImageOutputStream(Object)     47     0 %
                                            java.awt.image.BufferedImage.<init>(int, int, int)     36     0 %
                                            java.awt.Image.getScaledInstance(int, int, int)     23     0 %
                                            java.awt.image.BufferedImage.getGraphics()     21     0 %
                                       javax.imageio.ImageIO.read(File)     4.320     1 %
                        de.ellumination.carmen.om.BaseImagePeer.retrieveByPK(int)     557     0 %
                   de.ellumination.carmen.modules.screens.Index.doBuildTemplate(RunData, Context)     1.673     0 %
              org.apache.catalina.startup.Bootstrap.main(String[])     151.225     22 %
              org.quartz.core.QuartzSchedulerThread.run()     22     0 %
    Now I am looking for the Best way to solve my problem. Maybe I am wrong from the get go.
    Runtime Setup Java 1.5.0_04 Tomcat 5.5.12 V20z (AMD64 Opteron 4gb RAM)
    Any help is heighly appreciated
    Kind regards

    This is a bad thing to do with JPEGs. You're better off just reducing the 'q' if you want a smaller/faster/lower resolution image. That way you're throwing away resolution intelligently. Using scaling you're throwing resolution away unintelligently. I was on a project where 40,000 images were scaled when they should have been low-q'd. Don't do it.

  • ID CS4: Is there a way to resize multiple objects at one time?

    InDesign CS4: I have a group of object frames that I need to resize (I don't care about resizing the content, I know how to do that) and I'm wondering if there's a way to resize them all at once to a specific size. If I group them and resize them it only gives me the group height and width, I want them each to be a specific measurement.
    Any suggestions or know plug-ins to help?

    If you don't want to use data merge or xml, you can also place multiple images in one action.

  • Best way to MouseDrag multiple objects around a scene.

    So I am having a little trouble trying to drag 3 Box's in a scene.
    Originally I had it set up where each was relocated to an x,y translated Z and set to a HWD. Then I figured I would, instead of the mouse click on the box itself, be in the root. From there I would look through all of the root.getChildren() then made that see if it contained the x,y position.
    Then from knowing which of my root Children I clicked I did root.getChildren.get(current).setOnDragged to figure out which one was dragged.
    The code itself worked except for finding which box I was on.
    The issue I find is that I onyl have getX, getSceneX, and getScreenX. X, and SceneX produce the same value, and ScreenX is useless. I tried then to do event.getX() - root.getLayoutX() to make the contains function to work, but it wasn't working and would require me to change up more things. getLayoutX() was = 0 since I didn't set the root location, only the locations of the box's.
    From there I kept wondering if there was a better way. Then I thought maybe to loop through every element in my root or in an arrayList(Which is what I used, but realized the root.getchildren should work like the original) but the problem is it keeps only registering the last one in the list, so it just loops and that's it.
    So what I want to know is, what would be the best way to figure out what object I'm in?
    Originally I use the contains(Swing) but Swing is different, and now especially since we can register mouseEvents to each node, shouldn't we know exactly which one we are on, just by looping through each of them? I figure that's easier than having to check every single mouse position contained within, especially if I have 10000 things to check?
    Edited by: KonradZuse on Mar 18, 2013 8:05 PM

    I slightly modified your code for 3D.
    - added a pointlight
    - added a phong material
    - the rectangle changed to a box
    - the circle changed to a sphere
    - add scene.setCamera(new PerspectiveCamera(false));
    Without the last line it is not working.
    I tested it with javafx8.0 build 80 Netbean7.3
    import javafx.application.Application;
    import javafx.scene.Node;
    import javafx.scene.Scene;
    import javafx.scene.input.MouseEvent;
    import javafx.scene.layout.Pane;
    import javafx.scene.paint.Color;
    import javafx.scene.shape.Circle;
    import javafx.scene.shape.Polygon;
    import javafx.scene.shape.Rectangle;
    import javafx.stage.Stage;
    import javafx.event.EventHandler;
    import javafx.scene.Group;
    import javafx.scene.PerspectiveCamera;
    import javafx.scene.PointLight;
    import javafx.scene.paint.PhongMaterial;
    import javafx.scene.shape.Box;
    import javafx.scene.shape.DrawMode;
    import javafx.scene.shape.Sphere;
    public class DraggingShapes3D extends Application {
        @Override
        public void start(Stage primaryStage) {
            PointLight pointLight = new PointLight(Color.ANTIQUEWHITE);    
            pointLight.setTranslateX(800);    
            pointLight.setTranslateY(-100);  
            pointLight.setTranslateZ(-1000);
            PhongMaterial material = new PhongMaterial();
            material.setDiffuseColor(Color.LIGHTGRAY);
            material.setSpecularColor(Color.rgb(30, 30, 30));
            Box box = new Box(200, 200, 200);
            box.setMaterial(material);
            box.setTranslateX(100);
            box.setTranslateY(100);
            box.setDrawMode(DrawMode.FILL);
            box.addEventHandler(MouseEvent.ANY, new DragShapeHandler());
            Group root = new Group();
            Sphere sphere = new Sphere(100);
            sphere.setTranslateX(400);
            sphere.setTranslateY(100);
            sphere.setMaterial(material);
            sphere.addEventHandler(MouseEvent.ANY, new DragShapeHandler());
            root.getChildren().addAll(box, sphere);
             root.getChildren().addAll(pointLight);
            Scene scene = new Scene(root, 800, 800, true);
            scene.setCamera(new PerspectiveCamera(false));
            primaryStage.setScene(scene);
            primaryStage.show();
        public static void main(String[] args) {
            launch(args);
        class DragShapeHandler implements EventHandler<MouseEvent> {
            private double sceneAnchorX;
            private double sceneAnchorY;
            @Override
            public void handle(MouseEvent event) {
                if (event.getEventType() == MouseEvent.MOUSE_PRESSED) {
                    sceneAnchorX = event.getSceneX();
                    sceneAnchorY = event.getSceneY();
                } else if (event.getEventType() == MouseEvent.MOUSE_DRAGGED) {
                    double x = event.getSceneX();
                    double y = event.getSceneY();
                    Node node = (Node) event.getSource();
                    node.setTranslateX(node.getTranslateX() + x - sceneAnchorX);
                    node.setTranslateY(node.getTranslateY() + y - sceneAnchorY);
                    sceneAnchorX = x;
                    sceneAnchorY = y;
    }

  • Best way to resize a graphic for slideshow

    Just a small issue I'm sure, but I'm trying to figure out the best way to handle this. I have a slide show set up with photos of various sizes. Some of the shots are landscape and the others portrait. I have a custom shadow I want at the bottom of each photo. However, if I just put it on the page, it doesn't have anyway to resize based on the photo. Is there a way around this?

    The sample that you posted is not grayscale so it is no surprise that you are having trouble scaling it to the desired dimensions. Try changing the color mode to grayscale first, then scale the image, then save for web as a GIF file - - - reducing the color palette to the least number of grays needed to display the image.

  • The best way to delete an object

    hi
    i'm searching for a while for the best method to delete an object
    for example let's say i have this object
    Mycar car = new Mycar("bmw");
    is this a correct way to delete it
    car=null;
    System.gc();

    J2ee_consultant wrote:
    i think that they are the same so what's the good solution to do that?You don't. In C++, for example, explicitly freeing objects is a major cause of runtime errors (double frees, or use of freed objects). In java you simply have to trust the garbage collector.

  • Best way to populate an object

    This is more of a coding convention question. I was wondering what is the best or industry standard way to populate an object.
    If there's a method that returns an object is it better to pass an empty object (just declared) into the method, have the method populate the object and then just use the object
    e.g. Object foo;
    populateObject(foo);
    foo.getProperty();
    or
    have the method return a newly populated object
    e.g. Object foo = populateObject();
    foo.getProperty();
    thanks

    It's better to pass in an object as an argument when performance is important. You can pass in the same object instead of creating new objects for each call to getProperty().
    It's better to return a newly populated object when the caller does not know what class of object will be returned. The getProperty() method could return a subclass of Object.
    As is often the case, the answer is: it depends.

  • Best way to detect memory usage etc. on mobile device for debugging?

    Hi
    What's the best way, when developing, to detect memory usage and such while the app is running on the device?
    So you can test it and see if something is causing it to run wild. I'm making an iOS/Android device so I want to try it on both slow and fast phones and I have a script that "adds on" memory usage as the user continues. I would like to monitor this (either in app, or from the debugger) to see what happens.
    Any ideas?
    Thank you

    Wow thanks Yacine! Didn't know this one, it will be a life saver for my IOS debugging !!
    Cheers!

  • Best way to restore "deleted objects" container's ACLs?

    Hi,
    I haven noticed, when using the the LDP for reading the security description of "Deleted Objects" container that LDP returns to me "Error: Security: No Such Attribute <16>". Should it be readable or not? At least all other environments
    I can read it.
    And if it should be readable, then what is the best way to fix it? Take the ownership, and etc... If I take the ownership, then I assume some ACLs are reseted and installations like Exchange and Lync requires domain preparations, right?
    Petri

    > description of "Deleted Objects" container that LDP returns to me
    > "Error: Security: No Such Attribute <16>". Should it be readable or not?
    AFAIK, deleted objects lose their ACL.
    Martin
    Mal ein
    GUTES Buch über GPOs lesen?
    NO THEY ARE NOT EVIL, if you know what you are doing:
    Good or bad GPOs?
    And if IT bothers me - coke bottle design refreshment :))

  • What is the best way to get another object's method to update my GUI?

    package stuff;
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.*;
    public class Test extends JFrame{
      private static JButton ProcessButton = new JButton();
      private static JLabel jLabel2 = new JLabel();
      public static void main( String args []){
         Test f = new Test();
         f.setSize(500,500);
         Container c = f.getContentPane();
         ProcessButton.addActionListener( new ActionListener(){
                                     public void actionPerformed(ActionEvent e) {
                                        jLabel2.setText("Connecting to DB");
                                        //Connection connection = Tools.setUpConnectionToDB(url,userName,pwd);
         c.add(ProcessButton, BorderLayout.NORTH);
         jLabel2.setText("My Label");
         c.add(jLabel2, BorderLayout.SOUTH);
         f.setVisible(true);
    {\code]
    The method setUpConnectionToDB can take 1 - 10 mins to complete. By this time a user will prob have quit my app thinking
    it's crashed because it doesn't update the GUI with a progress status. :(
    What is the best way to get this method to update the GUI of the app which calls it?
    Something like  Connection connection = Tools.setUpConnectionToDB(url,userName,pwd, this);
    ie this being a reference to the GUI's JFrame is what I'm trying to use?

    A handy class to know about but not really what I'm after.
    I need the method call
    Tools.setUpConnectionToDB(url,userName,pwd);
    to be able to update a component ( The JLabel ) on the GUI
    Connection connection = Tools.setUpConnectionToDB(url,userName,pwd, this);
    [\code]
    method defn:public static Connection setUpConnectionToDB( String url, String user, String pwd, JFrame f ){
    //Why doesn't this code below modify the GUI on the calling App?
    f.jLabel2.setText("Setting UP DB Connection");
    f.repaint();
    Connection c = null;
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    c = DriverManager.getConnection(url,user,pwd);
    catch(ClassNotFoundException e){
    JOptionPane.showMessageDialog(null , "Error loading DB driver");
    System.exit(0);
    catch(Exception e){
    JOptionPane.showMessageDialog(null , "Error connecting to DB, check config file");
    System.exit(0);
    return c;
    }[\code]

  • Best way to transform an object into a circle?

    Let's say I have a long rectangle I want to warp into a circle, what would be the best way to go about doing this?

    Drag the rectangle into the Brushes palette.
    In the resulting dialog, define an Art Brush.
    Draw a circle.
    Apply the Art Brush to the circle.
    JET

  • What is the best way to resize a book?

    I have InDesign CC and I am designing a culture book for my company. It’s about 100 pages and full of pictures, shapes, and text.
    The book is almost completed, but I just got word today that we are changing the size. The original size was 7x9 and the new size is 6x9. This throws off the whole layout.
    What is the best/ fastest way to scale down the book? Because all I know right now is manually re-laying out each page.
    I also have acrobat XI pro, just in case I can use this software to help in the resizing process.
    Thanks.

    @fcgpublishing – the "easiest" way would be to scale the contents only in x-axis to fit the new size.
    You can do it on the InDesign pages with all objects selected.
    You can do it with exported PDF pages placed into a new InDesign file and scale these.
    But this would do harm to your aestetic preferences…
    Sigh. No easy question. There is no magic way to do it without losing something on its way. Time and effort is needed to refine the process and the results. Whatever you like to chose: Alternate Layout, Layout Adjustment, writing a script…
    "Best" and "fastest" are not compatible here.
    Define "best" and you'll see it's not "fastest".
    Uwe

Maybe you are looking for

  • Is it possible to make a DVD rom work on Sparc Ultra 5 running Solaris 2.6?

    I have been asked to try and get a DVD drive to work on a sparc ultra 5 running Solaris 2.6. Its been a while since I have done much with an ultra 5. My first reaction was no. However I thought that I should ask just in case it can be done. Its got t

  • Can I move/rescale more than one still image all together, when they will all use the same parameter

    Okay, basically, I like to make small, simple movies for my DVD menus.  I make these with premiere CS5.5.  They are just a series of stills as a slide show, with appropriate music.  What makes these so time consuming is this:  I have maybe twenty pic

  • Icloud storage and size limits

    I want to purchase some Icloud storage. I know the max come in 50GB, but want to know if I can purchase more and combine the two together. So In an example. can I purchase 50GB and another 50GB and and use the total amount together on the same Itunes

  • Doubt in Integration Scenario Creation

    Hi All, My scenario is file to Idoc.Need to create a Integration Scenario. I have stored all the Interface and Mapping objects in teh same Software Component Version (say SWCA). So in Integration Scenario, What will be the Sender and Receiver Softwar

  • Getting Disk Utility to copy a DVD

    I created a DVD copy of a laserdisk on DVD+RW, and it works. I wanted to use my Mac to copy it to a DVD-R for my permanent backup, so I connected my Mad Dog USB drive to my iMac, put in a brand new DVD-R blank in it, and put my movie into my iMac's d