Image offsetting

I'm playing around with the concept of 2D fighting game sprites. I have the JFrame, image loading, painting, and everything else fine.
However, there is a slight problem. I'm trying to figure out how to drawe the images properly. Since the sprites can be different sizes depending on the pose, there might be slight problems when they are drawn.
For example, I've taken out two idle stance sprites. One is 36 pixels wide and the other is 38 pixels wide. Both are the same height. When I draw it, I get a slight jittery motion since the two are different widths. I fixed that with two methods that calculate an offset and draw it in a position based on the original sprite. This fixes the jitteryness with the idle stance.
So then I extract a sprite where the character is in the middle of a kick. I put that in place of the 38 pixel wide image for some testing. When this draws, the character mysteriously teleports backwards and does her kick. This is due to the offset methods.
I think know where the problem lies, I just don't exactly have a solution. It has to be the offset methods.
The code for them is..
public int calculateHeightOffset(BufferedImage img1, BufferedImage img2) {
   int height1 = img1.getHeight();
   int height2 = img2.getHeight();
   return height1 - height2;
public int calculateWidthOffset(BufferedImage img1, BufferedImage img2) {
  int width1 = img1.getWidth();
  int width2 = img2.getWidth();
  return width1 - width2;
}I suppose my question would be... is there a way to determine how to properly draw different-size sprites codewise? Or would I need to make it all manual. I'm assuming there is a way to do it codewise because as far as I know that's how MUGEN works. But I could be wrong though.

So far I have it set up like this:
Class Fighter - holds a list of all the Sprite objects, the coordinates of the fighter, and later on.. moves and all that stuff.
Class Sprite - holds a single BufferedImage and the offsets for the image.
Once I get enough sprites, they will be ordered in a certain fashion. There isn't any particular order they will have to be in though. This is how I'm planning to make it all work:
The character will have a file (files?) that describes move "ranges." These ranges are actually the numbers of the sprites to use. For example, a move with a range of 0-20 would use sprites 0 to 20 for its full animation. This will allow the sprites to be in a general order within the whole file, but they must be specifically ordered in order inside a range for the move to look right.
The sprites themselves will be named 0.gif, 1.gif and so on. I suppose the TreeMap would hold the actual Sprite object for its value and an Integer key that corresponds with its name (0 for 0.gif, 1 for 1.gif, etc.).

Similar Messages

  • Image offset to the right

    Why is the image offset to the right when I try to print in landscape mode? On a print the title block is mostly off the page to the right and it prints like this on both of my printers.

    Okay, I figured out a fix. Here's the deal:
    The Tablet PC Settings control panel has radio button options for Right-handed and Left-handed menu appearance - the menus are supposed to appear to the left if you're right handed, and vice-versa if you're left handed. I had changed the setting to match my right-handedness. The default setting was Left-handed.
    Apparently, the CS4 Photoshop, InDesign and Illustrator interface isn't compliant with this handedness feature of the tablet UI. Acrobat Pro and Bridge work fine with handedness settings and I haven't checked the rest of the suite applications.
    If someone running Vista with a Wacom tablet can check this out with the right-handed menu setting to confirm it's not just my system, I'd appreciate it.
    BJ

  • IPad VGA projected image offset and cut off

    I bought an iPad VGA cable last night and hooked it up to my Optoma PT-100 projector (cheap kiddie projector, 854x480 resolution).
    I tried slideshow and the pictures were horizontally stretched.  Bummer.
    Then I tried netflix and I noticed a far more serious problem - the screen is offset to the right and the right quarter of the screen is cut off. The left quarter is totally black.
    There's no settings anywhere for this thing so I wasn't really sure what to do / how to fix?
    I have not tried hooking it up to a different monitor yet.

    So half of it was just the projector not doing a very good job of resetting itself. That was the shift and the right quarter being cut off. All I needed to do there was power it off and on again and it resets the image.
    The other part is really frustrating. This is where your answer did help. For some odd reason, the VGA cable is giving a 4:3 image to my projector which I don't get at all. But changing that setting in the projector did help.  This is especially weird because when I tested it on my tv it put out a 16:9 image.
    I think if I play with the Netflix screen modes setting I might be able to get a full 16:9 image. What's frustrating about apple's "it just works" philosophy is when it doesn't and there's no way to try and workaround the issue.

  • Pan | Zoom: how to get image offsets when panning

    Hello,
    I am trying to use the Pan | Zoom control to show images, allowing zoom and pan. I haven't found yet a way to infer the X,Y offset of the part of the image that it's displayed in the imageviewer visible rectangle. I need these details in order to print objects and markers at the right place over the image.
    Is there some hidden or simple way to get these informations?
    Thanks,
       Mario

    Hello,
    I am trying to use the Pan | Zoom control to show images, allowing zoom and pan. I haven't found yet a way to infer the X,Y offset of the part of the image that it's displayed in the imageviewer visible rectangle. I need these details in order to print objects and markers at the right place over the image.
    Is there some hidden or simple way to get these informations?
    Thanks,
       Mario

  • Get Image Subset VI ignores original image offset

    Hi,
    I'm have a problem with Get Image Subset VI.
    My program gets original image rectangle from a image and apply a offset for draw in a picture control.
    But the image cannot across a region delimited by another rectangle. So, i use Get Image Subset with a
    image (with offset) and a deilimiter rectangle. 
    I give the same subset of image with and without offset.
    Attachments:
    test3.vi ‏12 KB
    servidor_g.png ‏3 KB

    In my opnion the correct result is the highlighted are in the Original Picture With Offset (See attached image ) and not Image Subset.
    Attachments:
    imagem.GIF ‏20 KB

  • Aperture printed image offset by 1/4" on Epson 7800 printer

    I'm using Aperture 3.2.4 with System 10.7.4, and Epson 7800 printer, iMac.  Have printed many images, working properly.  But recently, every printed image is offset 1/4" up.  It looks correctly centered in the printer setup screen, but when printed, the bottom margin is 1/4" larger and the top one 1/4" smaller.  For this printer, the bottom margin is supposed to be fixed at 0.56" (9/16"), and it always used to be, and that's what the setup screen still says it is.  But now the printed image's bottom margin is 0.81" (13/16"), even though the setup calls for .56". 
    I've tried to compensate by adding 1/4" to the top margin, and that does bring the printed top margin up from 5/16" to 9/16", but the bottom margin remains 13/16"
    Anyone have any ideas?

    I don't know why it is, just that it was a bug that was revealed about a year ago. I had similar problems with my 9800 and could not for the life of me figure out the cause. I had Epson telling me it was the humidity. I had Chromix telling me to put the UV filter on my Spectrolino, and it all came down to the default printer. Not sure exactly where I read about it first, but I'm glad that one more person now knows.

  • Howto: Determine Image Offset via Scripting?

    Given the screengrab, below,
    How would I go about, via scripting (js), fetching the "X+" value? Is it a calculation of other values, and if so, what are they?
    I want to get that "7.2" value.
    Thanks.

    app.selection[0].graphics[0].geometricBounds[1]-app.selection[0].geometricBounds[1]

  • Problem in save  image

    Here i write text inside image then the image which contain text drawn on stegoPanel i want to save this stego image .
    when i save it the file appear put not contain the image
    // imports
    public class TestImage extends JFrame {
        private JPanel mainPanel;
        private DisplayPanel displayPanel, stegoPanel;
        private JButton openButton, saveButton, empededButton, extractButton;
        private JFileChooser fileChooser;
        private JScrollPane normalScrollPane, stegoScrollPane;
        private JTextArea area;
        private MyActionListener actionListener;
        public TestImage() {
            actionListener = new MyActionListener();
            fileChooser = new JFileChooser();
            intializeingPanel();
            intializeingButtons();
            intializeingArea();
            getContentPane().add(mainPanel);
        public static void main(String[] args) {
            TestImage testImage = new TestImage();
            testImage.setDefaultCloseOperation(TestImage.EXIT_ON_CLOSE);
            testImage.setSize(new Dimension(600, 300));
            testImage.setLocationRelativeTo(null);
            testImage.setVisible(true);
            testImage.setExtendedState(MAXIMIZED_BOTH);
        private void intializeingPanel() {
            mainPanel = new JPanel(null);
            mainPanel.setBounds(100, 10, 600, 300);
            displayPanel = new DisplayPanel();
            TitledBorder normalImageBorder = new TitledBorder("Normal image");
            displayPanel.setBorder(normalImageBorder);
            displayPanel.setBackground(Color.WHITE);
            normalScrollPane = new JScrollPane(displayPanel,
                    JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                    JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
            normalScrollPane.setBounds(50, 150, 200, 300);
            mainPanel.add(normalScrollPane);
            stegoPanel = new DisplayPanel();
            TitledBorder stegoImageBorder = new TitledBorder("Stego image");
            stegoPanel.setBorder(stegoImageBorder);
            stegoPanel.setBackground(Color.WHITE);
            stegoScrollPane = new JScrollPane(stegoPanel,
                    JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                    JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
            stegoScrollPane.setBounds(300, 150, 200, 300);
            mainPanel.add(stegoScrollPane);
        private void intializeingButtons() {
            openButton = new JButton("Open");
            openButton.setBounds(50, 10, 100, 50);
            openButton.addActionListener(actionListener);
            mainPanel.add(openButton);
            saveButton = new JButton("Save as");
            saveButton.setBounds(150, 10, 100, 50);
            saveButton.addActionListener(actionListener);
            mainPanel.add(saveButton);
            empededButton = new JButton("Hide message");
            empededButton.setBounds(250, 10, 100, 50);
            empededButton.addActionListener(actionListener);
            mainPanel.add(empededButton);
         extractButton = new JButton("Extract message");
            extractButton.setBounds(350, 10, 100, 50);
            mainPanel.add(extractButton);
        private void intializeingArea() {
            area = new JTextArea();
            JScrollPane scrollPane = new JScrollPane(area);
            scrollPane.setBounds(50, 500, 400, 200);
            mainPanel.add(scrollPane);
        private class MyActionListener implements ActionListener {
            public void actionPerformed(ActionEvent e) {
                String str = area.getText();
                BufferedImage image = null;
                BufferedImage saveBufferedImage = null;
                int[] imageData;
                int[] img;
                int offset = 0;
                if (e.getSource() == openButton) {
                    int returnValue = fileChooser.showOpenDialog(TestImage.this);
                    if (returnValue == JFileChooser.APPROVE_OPTION) {
                        File openFile = fileChooser.getSelectedFile();
                        try {
                            displayPanel.setBufferedImage(ImageIO.read(openFile));
                            repaint();
                        } catch (Exception exception) {
                            exception.printStackTrace();
                } else if (e.getSource() == saveButton) {
                    image = stegoPanel.getBufferedImage();
                    imageData = getImageData(image);
                    try {
                        img = hideing_text(imageData, str.getBytes("US-ASCII"), offset);
                        try {
                            saveBufferedImage = toImage(image.getWidth(), image.getHeight(), img);
                        } catch (IOException ex) {
                            ex.printStackTrace();
                    } catch (UnsupportedEncodingException ex) {
                        ex.printStackTrace();
                    int returnValue = fileChooser.showSaveDialog(TestImage.this);
                    if (returnValue == JFileChooser.APPROVE_OPTION) {
                        try {
                            File selectedFile = fileChooser.getSelectedFile();
                            String fileName = selectedFile.getName();
                            String format = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length()).toLowerCase();
                            for (String name : ImageIO.getWriterFormatNames()) {
                                System.out.print("\nName: " + name + " format: " + format);
                                if (name.equals(format)) {
                                    ImageIO.write(saveBufferedImage, format, selectedFile);
                                    Iterator iter = ImageIO.getImageWritersByFormatName(format);
                                    ImageWriter writer = (ImageWriter) iter.next();
                                    ImageWriteParam iwp = writer.getDefaultWriteParam();                                FileImageOutputStream output = new FileImageOutputStream(selectedFile);
                                    writer.setOutput(output);
                                    IIOImage ioImage = new IIOImage(stegoPanel.getBufferedImage(), null, null);
                                    writer.write(null, ioImage, iwp);
                                    writer.dispose();
                                } else {
                                    System.out.println(" format is not supported");
                        } catch (IOException ex) {
                            ex.printStackTrace();
                } else if (e.getSource() == empededButton) {
                    try {
                        System.out.println("is not null");
                        image = displayPanel.getBufferedImage();
                        imageData = getImageData(image);
                        img = hideing_text(imageData, str.getBytes("US-ASCII"), offset);
                        stegoPanel.setBufferedImage(toImage(image.getWidth(), image.getHeight(), img));
                        repaint();
                    } catch (UnsupportedEncodingException ex) {
                        ex.printStackTrace();
                    } catch (IOException ex) {
                        ex.printStackTrace();
                    JOptionPane.showMessageDialog(null, "The message is hide");
            }Edited by: william_beshoy on Feb 9, 2010 5:59 PM
    Edited by: william_beshoy on Feb 9, 2010 5:59 PM

    The rest of the above code:
    private int[] hideing_text(int[] image, byte[] text, int offset) {
                try {
                    if (((text.length) * 8) + offset > image.length) {
                        throw new IOException();
                    } else {
                        for (int i = 0; i < text.length; ++i) {
                            int textbyte = text;
    for (int bit = 7; bit >= 0; bit--, offset++) {
    int b = (textbyte >> bit) & 1;
    image[offset] = ((image[offset] & 0xFE) | b);
    } catch (IOException e) {
    e.printStackTrace();
    return image;
    private int[] getImageData(BufferedImage image) {
    int size = image.getWidth() * image.getHeight();
    int[] buffer = new int[size];
    image.getRGB(0, 0, image.getWidth(), image.getHeight(), buffer, 0, image.getWidth());
    return buffer;
    public BufferedImage toImage(int w, int h, int[] data) throws IOException {
    BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
    image.setRGB(0, 0, w, h, data, 0, w);
    return image;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.image.BufferedImage;
    import javax.swing.JPanel;
    public class DisplayPanel extends JPanel {
    private BufferedImage bufferedImage;
    private Dimension PanelDimension = new Dimension();
    public void setBufferedImage(BufferedImage bufferedImage) {
    this.bufferedImage = bufferedImage;
    PanelDimension.setSize(bufferedImage.getWidth(), bufferedImage.getHeight());
    setPreferredSize(PanelDimension);
    revalidate();
    public BufferedImage getBufferedImage() {
    return bufferedImage;
    @Override
    public void paintComponent(Graphics g) {
    super.paintComponent(g);
    if (bufferedImage != null) {
    g.drawImage(bufferedImage, 0, 0, this);
    Thanks in advance                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Macbook Display - Noise, Interlacing/Dithering, and Offset

    Hello,
    Starting yesterday, my 2011 Macbook Pro (specs below) has been having issues with its display / graphics card.
    Frequently, especially while using resource-intensive programs like Chrome or Logic, my display will begin to introduce noise, then go black for a second, then come back on with the screen's image offset, wrapping around from left to right:
    After a couple seconds my computer freezes (beach ball, but can still move mouse). Then my keyboard becomes unresponsive, leaving me no option but to shut down.
    I double-checked the connection between the display and motherboard - seems fine. This is more likely a problem with the video card, I'd imagine, but I'm no expert. Thoughts?
    2011 15' Macbook Pro
    OSX Mavericks 10.9.2
    Processor: 2.2 Ghz intel Core i7
    Memory: 8 GB 1333 Mhz DDR3
    Graphics: Intel HD Graphics 3000 512 MB
    Startup Disk: 500 GB Samsung Solid State Drive

    Thanks, I will take a look at that. In the meantime, here are some relevant-looking system log lines from my last crash:
    5/22/14 12:38:42.000 PM kernel[0]: : 0x00000004
    5/22/14 12:38:42.000 PM kernel[0]: : 0x00000002
    5/22/14 12:38:42.000 PM kernel[0]: : 0xc0005200
    5/22/14 12:38:42.000 PM kernel[0]: : 0x00000000
    5/22/14 12:38:42.000 PM kernel[0]: *** kernel exceeded 500 log message per second limit  -  remaining messages this second discarded ***
    5/22/14 12:38:43.000 PM kernel[0]: [1:0:0] GPU Hang State = 0x00000000
    5/22/14 12:38:43.000 PM kernel[0]: GPU hang:
    5/22/14 12:38:43.000 PM kernel[0]: Trying restart GPU ...
    5/22/14 12:38:43.584 PM com.apple.launchd[1]: (com.apple.DumpGPURestart) Throttling respawn: Will start in 9 seconds
    5/22/14 12:38:43.000 PM kernel[0]: [1:0:0] Failed to reset hung GPU! result=0x00000097 ulResetBlockBitmap=0x00018000 ulResetResultBitmap=0x00000100
    5/22/14 12:38:44.000 PM kernel[0]: [1:0:0] GPU Hang State = 0x00000000
    5/22/14 12:38:44.000 PM kernel[0]: GPU hang:
    5/22/14 12:38:44.000 PM kernel[0]: Trying restart GPU ...
    5/22/14 12:38:44.731 PM com.apple.launchd[1]: (com.apple.DumpGPURestart) Throttling respawn: Will start in 8 seconds
    5/22/14 12:38:46.000 PM kernel[0]: [1:0:0] GPU Hang State = 0x00000000
    5/22/14 12:38:46.000 PM kernel[0]: GPU hang:
    5/22/14 12:38:46.000 PM kernel[0]: Trying restart GPU ...
    etc...

  • Extracting a transparent image

    Hi,
    I am loading in a png file which contains the frames for my animated sprite. The background of this image is transparent. I am then using the following method to extract the indivudal frames:
    public static Image getImageClip(Image image, int xpos, int ypos, int width, int height) {
    // create an image to hold the clipped image
    Image ReturnImage = Image.createImage(width, height);
    // draw the source image to the clipped image, offsetting it to show the image at xpos by ypos
    ReturnImage.getGraphics().drawImage(image, -xpos, -ypos,Graphics.LEFT|Graphics.TOP);
    // return the clipped image
    return ReturnImage;
    This works fine however the transparent background becomes white because the new created image is not transparent. Does anyone know how to create a new image with a transparent background, or do you know another way of extracting an image from a larger image.
    Thanks in advanced.
    (using M.I.D.P 1.0)

    Seems a bit of a waste to have to capture a movie clip in order to get a still picture.
    This page has some suggestions: http://www.tuaw.com/2007/04/16/take-full-screen-dvd-snapshots/
    If you scroll down to the comments, you will see some more suggestions.

  • Lets All Take A Giant Step Backwards

    [http://www.javafx.com/samples/BrickBreaker/]
    So Sun put up a fancy "how to" JavaFX site thats supposed to show people how to program. Check out Figure 3, 4 and 6.
    Im not trying to say that I know better than a Sun engineer, but does JavaFX just not have enums or what?
    Almost every class is riddled with this stuff.
    // Types of bricks
    public def TYPE_BLUE = 0;
    public def TYPE_BROKEN1 = 1;
    public def TYPE_BROKEN2 = 2;
    public def TYPE_BROWN = 3;
    public def TYPE_CYAN = 4;
    public def TYPE_GREEN = 5;
    public def TYPE_GREY = 6;
    public def TYPE_MAGENTA = 7;
    public def TYPE_ORANGE = 8;
    public def TYPE_RED = 9;
    public def TYPE_VIOLET = 10;
    public def TYPE_WHITE = 11;
    public def TYPE_YELLOW = 12;
    public class Brick extends CustomNode {
        // Type of the brick
        public-init var type: Integer;
            ImageView {
                image: bind Config.bricksImages[type]
    def BRICKS_IMAGES = [
        "blue.png",
        "broken1.png",
        "broken2.png",
        "brown.png",
        "cyan.png",
        "green.png",
        "grey.png",
        "magenta.png",
        "orange.png",
        "red.png",
        "violet.png",
        "white.png",
        "yellow.png",
    ];The brick classes only state is an integer, which is an image[] offset. Woops?
    public class Level extends CustomNode {
        // States
        // 0 - starting level
        // 1 - ball is catched
        // 2 - playing
        // 3 - game over
        var state = 0;Apparently they lack the standard library as well.
    This is a gem from a "utils" class:
    // Returns random integer number from 0 to max - 1
    public function random(max: Integer): Integer {
        RANDOM.nextDouble() * max as Integer;
    }Edited by: TuringPest on Dec 4, 2008 9:15 PM

    Psyber wrote:
    Ugh, just another language I'm going to have to learn dont bother.
    Encephalopathic wrote:
    but is JavaFx that important or popular that it is something worth learning now? nope. [the word on the street.|http://www.reddit.com/r/programming/comments/7hd8f/javafx_10_released/]
    there are a few choice comments worth quoting but i cant in polite company.

  • Printing cards and labels on Photosmart C4580 printer

    I couldn't find my particular problem using the search so I'm hoping for some answers here. I have a Photosmart C4580 printer connected to a Toshiba laptop running Vista with all the current updates. My problem is that I can't seem to get it to print on business card stock or addrress label stock. Here's the issue:
    I use Word to create business cards to print onto business card stock. The instructions that came with the card stock say to do a test page on regular paper first to verify placement, which I do - everything looks perfect so I put a page of card stock in the feeder. The printer grabs the page and prints with the image offset towards the top of the page by about 1/4" so that the top of the card is above the edge of the cards. As the cards are repeated down the page, it shifts down slightly so that by the time it gets to the bottom of the page it's almost on the card, but still overlaps the top edge slightly. Printing onto regular paper works perfectly every time.
    A similar thing happens printing address labels - again using Word to create the labels for either Avery 5267 or Avery 8161 label stock. On regular paper everything looks perfect, but feed a sheet of label stock in and the text is offest toward the top of the page. The last time I needed labels I was able to get it to print properly by printing one label at a time, then refeeding the page and printing the next one, then repeating until each label on the page was printed. When you're printing several pages of labels that takes a lot of time!
    Is there something I need to do to get this printer to print cards and labels?
    Alan Hepburn
    Alan Hepburn
    Proud to be a Blue Star Family

    @ deblois 1089 - I will need a little more information to help out. What are the specifications of the labels? Do you have the measurements and the weight of the paper type? Thanks
    I am a former employee of HP...
    How do I give Kudos?| How do I mark a post as Solved?

  • Web Gallery created in Bridge not displaying first picture correctly on a Unix server

    Hi Guys, Am really stumped by a problem that has surfaced after moving from a Windows web hosting server to a Unix hosting platform. The Web Galleries created in both Bridge CS4 and CS6 display and operate as expected on the Windows server. However, having moved to a Unix hosting platform, I observe an odd behavior when going to the Web Gallery page. When the gallery loads, it displays the first image offset. This is always the top left hand quarter of the picture, offset to show in the bottom left hand corner, leaving the top left and right quarters and the bottom left quarter black (I use quarters to best describe the situation, though it really does seem as if the view port of the Gallery is indeed quartered for this first image).
    If I click on the second image in the series, it appears full size. The same happens if I click on the "Play" button. If I return to the first image manually, it displays full size.
    The phenomenon is apparent in Firefox 19.0.2, IE9, Opera and Chrome, all of the latest build.
    Can anyone throw some light on why this phenomenon is occurring and better still, suggest a cure?
    Grateful for all and any help anyone can give.
    Cheers, Daviddhg

    Hi Guys, This turned out to be a Unix server-side issue. Apparently the compression software being used by the ISP on this server was in some way incompatible. The ISP turned the compression off and the problem was cured.
    Cheers, Daviddhg

  • Help with arrays in PHP

    Hi All,
    I have created a page that shows thumbnail images of all
    images in a
    given directory. Here is the function that searches the
    directory and
    builds an array of qualified files:
    > function getImages($dir) {
    > $directory = new DirectoryIterator($dir);
    > $fileTypes =
    '#\.jpg$|\.jpeg$|\.gif$|\.png$|\.JPG$|\.GIF$|\.PNG$#i';
    > $filtered = new RegexIterator($directory, $fileTypes);
    > $array = array();
    > foreach ($filtered as $item) {
    > $array[] = $item->getFilename();
    > }
    > return new ArrayIterator($array);
    > }
    >
    > // get an ArrayIterator of filenames and the total
    number:
    > $images = getImages('../images/images_news/');
    > $totalImages = $images->count();
    Here is the HTML and PHP used to display the images (I'm
    excluding code
    that is specific to the paging function):
    > // Implement offset and files per page
    > foreach (new LimitIterator($images, $offset,
    $filesperpage) as
    > $image) { ?>
    > <div class="imgcont">
    > <div class="imgholder">
    > <img src="../images/images_news/<?php echo $image;
    ?>"
    > alt="<?php echo $image; ?>" height="55"
    class="center" />
    > </div>
    > <p class="smallname"><?php echo $image;
    ?></p><br />
    > </div>
    > <?php } ?>
    > <div class="clear"><br />
    My question is this. I need to provide a way to delete images
    that will
    no longer be needed. Actually, I need to be able to delete
    the main
    image and the thumbnail image, each of which is in a separate
    directory. What I don't know is how this type of thing is
    normally done
    (I don't want the FTP route because I don't want a client
    messing about
    in the directory structure). And what I don't understand is
    how to
    select one or more files to delete when they were produced by
    an array.
    For ease of use, it would be nice if I could add a checkbox
    that the
    user could check to indicate that the image(s) should be
    deleted. I
    just can't figure out how to select the file(s). I sure hope
    this is
    not one of those simple things that will make me hide my head
    in shame.
    Any help would be most appreciated.
    Brett

    Brett wrote:
    > the thumbnail images now have _tmb inserted between
    > the file name and the extension. So when deleting I keep
    getting
    > warnings that the file mypic001.jpg cannot be found in
    the thumbs
    > directory. How do I get the _tmb into the file name?
    foreach ($_POST['images'] as $image) {
    unlink($mainImgDir . $image);
    $pos = strrpos($image, '.');
    $thumb = substr($image, 0, $pos) . '_tmb' . substr($image,
    $pos);
    unlink($thumbsDir . $thumb);
    > By the way, you used unset() where I think you meant
    unlink().
    Yes, I did. Sorry about that.
    > Finally, I have discovered that if I upload a file named
    Ti301.JPG, I
    > get Ti301.JPG001_thb.jpg. It seems that the strtolower()
    function in
    > getNextFilename5.php is not converting the uppercase
    extension, it is
    > just adding the incremented number plus _tmb and the new
    extension. Any
    > ideas about how to correct that?
    That shouldn't be happening, but I don't have time to look
    into that
    now. Sorry.
    David Powers, Adobe Community Expert
    Author, "The Essential Guide to Dreamweaver CS3" (friends of
    ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

  • Help With JScrollPane and many JLabels...

    I am in the process of designing an 'image browser' applet for a client, but am having some difficulty in deciding how I can most elegantly meet all of the requirements. The specification calls for an applet that can view up to 400 images (all images are small - 120 * 120 px), the view of the images can be scrolled (if not all are in the view) or scaled (zoom in and out on any area), and the images will need to 'animate' or move to new locations as sorting criteria changes. Also, I need to be able to group images into arbitrary n*n arrays and click on any image in the view (rollovers may also be necessary in the future).
    At first, I thought this would be easily solved by putting the images (JLabels?) into as many groups (JPanels?) as necessary to meet the sort criteria, then adding the groups to my main view (JScrollPane w/JPanel) in a GridLayout. My current attempt at a solution scales the groups (JPanels) via. an overridden paintComponent method from within my main scrolling view (using g2d and scale). Unfortunately, I now have many problems that I am having trouble solving:
    1. After I re-scale the JScrollPane (zoom in or out) and then try and scroll, the new images that scroll in are either garbled or just junk (seems like remnants of the original, non-scaled components?).
    2. The scrollbars, at first, were not reflecting the current scaling and how much content is visible, so I overrode the getPreferredSize method in my JScrollPane content object to return (super.getPreferredSize * scaleFactor) - this fixes the appearance of the scroll bars (ie. they accurately reflect how much content there is), but it also offsets all of the images left depending on the scale value (less scale -> images offset further left).
    3. I need pixel-perfect control over the images, so that I can animate the transition from one 'group' to another - I can't see a way to achieve this with my current solution.
    Has anyone tried to do something like this before? What is a good way of accomplishing what I need here? Any code out there that does something similar? Any help would be appreciated, I've been banging my head against the wall over this for days now...
    Thanks in advance,
    Mike P.
    Here is some relevant code:
    /* From BrowserPanel (JPanel associated with my main JScrollPane) */
    public void paint (Graphics g) {
        Graphics2D g2d = (Graphics2D) g;
        g2d.scale(scaleFactor, scaleFactor);
        super.paint(g2d);
    /* From BrowserPanel (JPanel associated with my main JScrollPane) */
    public Dimension getPreferredSize() {
        Dimension origSize = super.getPreferredSize();
        double originalSizeX;
        double originalSizeY;
        originalSizeX = origSize.getWidth();
        originalSizeY = origSize.getHeight();
        double newSizeX = originalSizeX * scaleFactor;
        double newSizeY = originalSizeY * scaleFactor;
        String strX = Double.toString(newSizeX);
        String strY = Double.toString(newSizeY);
        /* Round the string (discard anything after the decimal) */
        strX = strX.substring(0, strX.indexOf("."));
        strY = strY.substring(0, strY.indexOf("."));
        /* Convert string to int... */     
        int x = Integer.parseInt(strX);
        int y = Integer.parseInt(strY);
        return new Dimension(x, y);
    }

    I increased the frame size to 3 lines and noticed the the flickering is a result of the text area painting itself without the scrollbar and then repainting itself with the scrollbar. I don't know why this happens, but a work around is to use:
    ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,

Maybe you are looking for

  • Blue screen appears out of sleep on Cinema Display

    I find when I wake my Macbook Pro up from sleep while attached to my 23" Cinema Display I get a blue screen for anywhere from 2 to 5 seconds and then my screen. It doesn't cause problems but its just annoying. When just using the Macbook Pro its scre

  • Satellite P100-347 - DVD Drive no longer visible in Windows XP MCE

    Hi. My DVD drives seems to have disapeared from within Windows MCE running on my P100-347. BIOS can see it, it opens and closes with no issues and the light comes on as if the disc is being read yet it's not being seen by Windows as a drive. I've ins

  • Problems with Wifi on iphone 4 after updating ot iOS 5.1

    After I update to iOS 5.1 is started having problems with my home wifi. After the update every thing seems to be running alright after after a day my connection was lost. When I tried to reconnect I got the message "unable to join the network". I tri

  • Adobe Air fails to Launch

    After downloading the latest version of adobe air, none of my programs that run on it will launch. The download seemed to happen without a hitch, the program states that the install was successful. When I try to open any air program it takes me direc

  • Status of Document (Release) not available

    Hello all, "Release Status" is not available in the document which is created/changed using CV01N/CV02N transactions. I have the below customising settings for the document type. What am I doing wrong? Please suggest. Thanks RJS