Search Results

Search found 4135 results on 166 pages for 'img'.

Page 26/166 | < Previous Page | 22 23 24 25 26 27 28 29 30 31 32 33  | Next Page >

  • Error when linking C executable to OpenCV

    - by Ghilas BELHADJ
    I'm compiling OpenCV under Ubuntu 13.10 using cMake. i've already compiled c++ programs and they works well. now i'm trying to compile a C file using this cMakeLists.txt cmake_minimum_required (VERSION 2.8) project (hello) find_package (OpenCV REQUIRED) add_executable (hello src/test.c) target_link_libraries (hello ${OpenCV_LIBS}) here is the test.c file: #include <stdio.h> #include <stdlib.h> #include <opencv/highgui.h> int main (int argc, char* argv[]) { IplImage* img = NULL; const char* window_title = "Hello, OpenCV!"; if (argc < 2) { fprintf (stderr, "usage: %s IMAGE\n", argv[0]); return EXIT_FAILURE; } img = cvLoadImage(argv[1], CV_LOAD_IMAGE_UNCHANGED); if (img == NULL) { fprintf (stderr, "couldn't open image file: %s\n", argv[1]); return EXIT_FAILURE; } cvNamedWindow (window_title, CV_WINDOW_AUTOSIZE); cvShowImage (window_title, img); cvWaitKey(0); cvDestroyAllWindows(); cvReleaseImage(&img); return EXIT_SUCCESS; } it returns me this error whene running cmake . then make to the project: Linking C executable hello /usr/bin/ld: CMakeFiles/hello.dir/src/test.c.o: undefined reference to symbol «lrint@@GLIBC_2.1» /lib/i386-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status make[2]: *** [hello] Erreur 1 make[1]: *** [CMakeFiles/hello.dir/all] Erreur 2 make: *** [all] Erreur 2

    Read the article

  • Image re sizing not working after rotation in Html5 canvas

    - by Deepu the Don
    In my HTML 5 + Javascript application, we can drag, re size and rotate image in Html 5 canvas. But after doing rotation, re sizing is not working. (I think it i related to finding dx,dy,not sure). Please help me to fix the code given below. Thanks in advance. <!doctype html> <html> <head> <style> #canvas{ border:red dashed #ccc; } </style> <script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script> <script> $(function(){ var canvas=document.getElementById("canvas"),ctx=canvas.getContext("2d"),canvasOffset=$("#canvas").offset(); var offsetX=canvasOffset.left,offsetY=canvasOffset.top,startX,startY,isDown=false,pi2=Math.PI*2; var resizerRadius=8,rr=resizerRadius*resizerRadius,draggingResizer={x:0,y:0},imageX=50,imageY=50; var imageWidth,imageHeight,imageRight,imageBottom,draggingImage=false,startX,startY,doRotation=false; var r=0,rotImg = new Image(); rotImg.src="rotation.jpg"; var img=new Image(); img.onload=function(){ imageWidth=img.width; imageHeight=img.height; imageRight=imageX+imageWidth; imageBottom=imageY+imageHeight; w=img.width/2; h=img.height/2; draw(true,false); } img.src="https://dl.dropboxusercontent.com/u/139992952/stackoverflow/facesSmall.png"; function draw(withAnchors,withBorders){ ctx.fillStyle="black"; ctx.clearRect(0,0,canvas.width,canvas.height); ctx.save(); ctx.translate(imageX,imageY); ctx.translate(imageWidth/2,imageHeight/2); ctx.rotate(r); ctx.translate(-imageX,-imageY); ctx.translate(-imageWidth/2,-imageHeight/2); ctx.drawImage(img,0,0,img.width,img.height,imageX,imageY,imageWidth,imageHeight); ctx.restore(); if(withAnchors){ drawDragAnchor(imageX,imageY); drawDragAnchor(imageRight,imageY); drawDragAnchor(imageRight,imageBottom); drawDragAnchor(imageX,imageBottom); } if(withBorders){ ctx.save(); ctx.translate(imageX,imageY); ctx.translate(imageWidth/2,imageHeight/2); ctx.rotate(r); ctx.translate(-imageX,-imageY); ctx.translate(-imageWidth/2,-imageHeight/2); ctx.beginPath(); ctx.moveTo(imageX,imageY); ctx.lineTo(imageRight,imageY); ctx.lineTo(imageRight,imageBottom); ctx.lineTo(imageX,imageBottom); ctx.closePath(); ctx.stroke(); ctx.restore(); } ctx.fillStyle="blue"; ctx.save(); ctx.translate(imageX,imageY); ctx.translate(imageWidth/2,imageHeight/2); ctx.rotate(r); ctx.translate(-imageX,-imageY); ctx.translate(-imageWidth/2,-imageHeight/2); ctx.beginPath(); ctx.moveTo(imageRight+15,imageY-10); ctx.lineTo(imageRight+45,imageY-10); ctx.lineTo(imageRight+45,imageY+20); ctx.lineTo(imageRight+15,imageY+20); ctx.fill(); ctx.closePath(); ctx.restore(); } function drawDragAnchor(x,y){ ctx.save(); ctx.translate(imageX,imageY); ctx.translate(imageWidth/2,imageHeight/2); ctx.rotate(r); ctx.translate(-imageX,-imageY); ctx.translate(-imageWidth/2,-imageHeight/2); ctx.beginPath(); ctx.arc(x,y,resizerRadius,0,pi2,false); ctx.closePath(); ctx.fill(); ctx.restore(); } function anchorHitTest(x,y){ var dx,dy; dx=x-imageX; dy=y-imageY; if(dx*dx+dy*dy<=rr){ return(0); } // top-right dx=x-imageRight; dy=y-imageY; if(dx*dx+dy*dy<=rr){ return(1); } // bottom-right dx=x-imageRight; dy=y-imageBottom; if(dx*dx+dy*dy<=rr){ return(2); } // bottom-left dx=x-imageX; dy=y-imageBottom; if(dx*dx+dy*dy<=rr){ return(3); } return(-1); } function hitImage(x,y){ return(x>imageX && x<imageX+imageWidth && y>imageY && y<imageY+imageHeight); } function handleMouseDown(e){ startX=parseInt(e.clientX-offsetX); startY=parseInt(e.clientY-offsetY); draggingResizer= anchorHitTest(startX,startY); draggingImage= draggingResizer<0 && hitImage(startX,startY); doRotation = draggingResizer<0 && !draggingImage && ctx.isPointInPath(startX,startY); } function handleMouseUp(e){ draggingResizer=-1; draggingImage=false; doRotation=false; draw(true,false); } function handleMouseOut(e){ handleMouseUp(e); } function handleMouseMove(e){ mouseX=parseInt(e.clientX-offsetX); mouseY=parseInt(e.clientY-offsetY); if(draggingResizer>-1){ switch(draggingResizer){ case 0: //top-left imageX=mouseX; imageWidth=imageRight-mouseX; imageY=mouseY; imageHeight=imageBottom-mouseY; break; case 1: //top-right imageY=mouseY; imageWidth=mouseX-imageX; imageHeight=imageBottom-mouseY; break; case 2: //bottom-right imageWidth=mouseX-imageX; imageHeight=mouseY-imageY; break; case 3: //bottom-left imageX=mouseX; imageWidth=imageRight-mouseX; imageHeight=mouseY-imageY; break; } if(imageWidth<25) imageWidth=25; if(imageHeight<25) imageHeight=25; imageRight=imageX+imageWidth; imageBottom=imageY+imageHeight; draw(true,true); }else if(draggingImage){ imageClick=false; var dx=mouseX-startX; var dy=mouseY-startY; imageX+=dx; imageY+=dy; imageRight+=dx; imageBottom+=dy; startX=mouseX; startY=mouseY; draw(false,true); }else if(doRotation){ var dx=mouseX-imageX; var dy=mouseY-imageY; r=Math.atan2(dy,dx); draw(false,true); } } $("#canvas").mousedown(function(e){handleMouseDown(e);}); $("#canvas").mousemove(function(e){handleMouseMove(e);}); $("#canvas").mouseup(function(e){handleMouseUp(e);}); $("#canvas").mouseout(function(e){handleMouseOut(e);}); }); </script> </head> <body> <canvas id="canvas" width=800 height=500></canvas> </body> </html>

    Read the article

  • Override bits of a CSS class while inline?

    - by larryq
    I have an html img that is being styled by a CSS class. I would like to override the width and height values used in that class under some circumstances. I'm building this img tag using something called a TagBuilder class, provided by Microsoft for the .Net system, which allows developers to assign attributes to an html element. In this case a CSS class has been assigned to the img tag, and I can assign width and height attributes individually, but they're not taking precedence over the values set in the CSS class. My tag looks like this currently: <img alt="my link" class="static" height="240" id="StaticImage" src="http://imageserver.com/myImage.jpg" width="240"> The static CSS class has width and height values of 300 each, and as you can see I'm trying to override them with 240. It's not working in this instance but can I do it without a second CSS class?

    Read the article

  • Replace images in a DIV using javascript.

    - by Muhammad Sajid
    Hi, I want to show different images in a DIV, the turn of an image depend on a random number. The image name is like 1.gif, 2.gif, .. 6.gif to do that I coded var img = document.createElement("IMG"); img.src = "images/1.gif"; document.getElementById('imgDiv').appendChild(img); but it does not replace the old image how ever it add an another image right in the bottom of first image. syntax for DIV is: <div id="imgDiv" style="width:85px; height:100px; margin:0px 10px 10px 375px;"></div> may u halp me ?

    Read the article

  • Help porting a bit of Prototype JavaScript to jQuery

    - by ewall
    I have already implemented some AJAX pagination in my Rails app by using the example code for the will_paginate plugin--which is apparently using Prototype. But if I wanted to switch to using jQuery for future additions, I really don't want to have the Prototype stuff sitting around too (yes, I know it's possible). I haven't written a lick of JavaScript in years, let alone looked into Prototype and jQuery... so I could use some help converting this bit into jQuery-compatible syntax: document.observe("dom:loaded", function() { // the element in which we will observe all clicks and capture // ones originating from pagination links var container = $(document.body) if (container) { var img = new Image img.src = '/images/spinner.gif' function createSpinner() { return new Element('img', { src: img.src, 'class': 'spinner' }) } container.observe('click', function(e) { var el = e.element() if (el.match('.pagination a')) { el.up('.pagination').insert(createSpinner()) new Ajax.Request(el.href, { method: 'get' }) e.stop() } }) } }) Thanks in advance!

    Read the article

  • Javascript Canvas Element - Array Of Images

    - by Ben Shelock
    I'm just learning JS, trying to do things without jQuery, and I want to make something similar to this however I want to use an array of images instead of just the one. My image array is formed like this var image_array = new Array() image_array[0] = "image1.jpg" image_array[1] = "image2.jpg" And the canvas element is written like this. (Pretty much entirely taken from the Mozilla site) function draw() { var ctx = document.getElementById('canvas').getContext('2d'); var img = new Image(); img.src = 'sample.png'; img.onload = function(){ for (i=0;i<5;i++){ for (j=0;j<9;j++){ ctx.drawImage(img,j*126,i*126,126,126); } } } } It uses the image "sample.png" in that code but I want to change it to display an image from the array. Displaying a different one each time it loops. Apoligies if I've not explained this well.

    Read the article

  • What regular expression(s) would I use to remove escaped html from large sets of data.

    - by Elizabeth Buckwalter
    Our database is filled with articles retrieved from RSS feeds. I was unsure of what data I would be getting, and how much filtering was already setup (WP-O-Matic Wordpress plugin using the SimplePie library). This plugin does some basic encoding before insertion using Wordpress's built in post insert function which also does some filtering. I've figured out most of the filters before insertion, but now I have whacko data that I need to remove. This is an example of whacko data that I have data in one field which the content I want in the front, but this part removed which is at the end: <img src="http://feeds.feedburner.com/~ff/SoundOnTheSound?i=xFxEpT2Add0:xFbIkwGc-fk:V_sGLiPBpWU" border="0"></img> <img src="http://feeds.feedburner.com/~ff/SoundOnTheSound?d=qj6IDK7rITs" border="0"></img> &lt;img src=&quot;http://feeds.feedburner.com/~ff/SoundOnTheSound?i=xFxEpT2Add0:xFbIkwGc-fk:D7DqB2pKExk&quot; Notice how some of the images are escape and some aren't. I believe this has to do with the last part being cut off so as to be unrecognizable as an html tag, which then caused it to be html endcoded. Another field has only this which is now filtered before insertion, but I have to get rid of the others: &lt;img src=&quot;http://farm3.static.flickr.com/2183/2289902369_1d95bcdb85.jpg&quot; alt=&quot;post_img&quot; width=&quot;80&quot; (all examples are on one line, but broken up for readability) Question: What is the best way to work with the above escaped html (or portion of an html tag)? I can do it in Perl, PHP, SQL, Ruby, and even Python. I believe Perl to be the best at text parsing, so that's why I used the Perl tag. And PHP times out on large database operations, so that's pretty much out unless I wanted to do batch processing and what not. PS One of the nice things about using Wordpress's insert post function, is that if you use php's strip_tags function to strip out all html, insert post function will insert <p> at the paragraph points. Let me know if there's anything more that I can answer. Some article that didn't quite answer my questions. (http://stackoverflow.com/questions/2016751/remove-text-from-within-a-database-text-field) (http://stackoverflow.com/questions/462831/regular-expression-to-escape-html-ampersands-while-respecting-cdata)

    Read the article

  • Why I can't draw in a loop? (Using UIView in iPhone)

    - by Tattat
    I can draw many things using this : NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"dummy2.png" ofType:nil]; UIImage *img = [UIImage imageWithContentsOfFile:imagePath]; image = CGImageRetain(img.CGImage); CGRect imageRect; double x = 0; double y = 0; for (int k=0; k<someValue; k++) { x += k; y += k; imageRect.origin = CGPointMake(x, y); imageRect.size = CGSizeMake(25, 25); CGContextDrawImage(UIGraphicsGetCurrentContext(), imageRect, image); } } CGImageRelease(img.CGImage); So, it works, so, I put it into a command object's execute method. Then, I want to do similar thing, but this time, my execute method only do this: NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"dummy2.png" ofType:nil]; UIImage *img = [UIImage imageWithContentsOfFile:imagePath]; image = CGImageRetain(img.CGImage); CGRect imageRect; double x = inComingX; double y = inComingY; imageRect.origin = CGPointMake(x, y); imageRect.size = CGSizeMake(25, 25); CGContextDrawImage(UIGraphicsGetCurrentContext(), imageRect, image); CGImageRelease(img.CGImage); This time, this is also a Command, and it is the execute method. But I take the for loop away. I will have another method that pass the inComingX , and inComingY into my Command object. My Drawing method is simply execute the Cmd that passed in my drawingEngine: -(void)drawInContext:(CGContextRef)context { [self.cmdToBeExecuted execute]; } I also have the assign method to assign the command,: -(void)assignCmd:(Command* )cmd{ self.cmdToBeExecuted = cmd; } And this is the way I called the drawingEngine for(int k=0; k<5; k++){ [self.drawingEngine assignCmd:[DrawingCmd setDrawingInformation:(10*k):0:@"dummy.png"]]; [self.drawingEngine setNeedsDisplay]; } It can draw, but the sad thing is it only draw the last one. Why? and how to fix it? I can draw all the things in my First code, but after I take the loop outside, and use the loop in last code, it just only draw the last one. Plz help

    Read the article

  • Java regex replace multiple file paths in a large String

    - by Joe Goble
    So a Regex pro I am not, and I'm looking for a good way to do this. I have a large string which contains a variable number <img> tags. I need to change the path on all of these images to images/. The large string also contains other stuff not just these img's. <img src='http://server.com/stuff1/img1.jpg' /> <img src='http://server.com/stuff2/img2.png' /> Replacing the server name with a ReplaceAll() I could do, it's the variable path in the middle I'm clueless on how to include. It doesn't necessarily need to be a regex, but looping through the entire string just seems wasteful.

    Read the article

  • Pymedia video encoding failed

    - by user1474837
    I am using Python 2.5 with Windows XP. I am trying to make a list of pygame images into a video file using this function. I found the function on the internet and edited it. It worked at first, than it stopped working. This is what it printed out: Making video... Formating 114 Frames... starting loop making encoder Frame 1 process 1 Frame 1 process 2 Frame 1 process 2.5 This is the error: Traceback (most recent call last): File "ScreenCapture.py", line 202, in <module> makeVideoUpdated(record_files, video_file) File "ScreenCapture.py", line 151, in makeVideoUpdated d = enc.encode(da) pymedia.video.vcodec.VCodecError: Failed to encode frame( error code is 0 ) This is my code: def makeVideoUpdated(files, outFile, outCodec='mpeg1video', info1=0.1): fw = open(outFile, 'wb') if (fw == None) : print "Cannot open file " + outFile return if outCodec == 'mpeg1video' : bitrate= 2700000 else: bitrate= 9800000 start = time.time() enc = None frame = 1 print "Formating "+str(len(files))+" Frames..." print "starting loop" for img in files: if enc == None: print "making encoder" params= {'type': 0, 'gop_size': 12, 'frame_rate_base': 125, 'max_b_frames': 90, 'height': img.get_height(), 'width': img.get_width(), 'frame_rate': 90, 'deinterlace': 0, 'bitrate': bitrate, 'id': vcodec.getCodecID(outCodec) } enc = vcodec.Encoder(params) # Create VFrame print "Frame "+str(frame)+" process 1" bmpFrame= vcodec.VFrame(vcodec.formats.PIX_FMT_RGB24, img.get_size(), # Covert image to 24bit RGB (pygame.image.tostring(img, "RGB"), None, None) ) print "Frame "+str(frame)+" process 2" # Convert to YUV, then codec da = bmpFrame.convert(vcodec.formats.PIX_FMT_YUV420P) print "Frame "+str(frame)+" process 2.5" d = enc.encode(da) #THIS IS WHERE IT STOPS print "Frame "+str(frame)+" process 3" fw.write(d.data) print "Frame "+str(frame)+" process 4" frame += 1 print "savng file" fw.close() Could somebody tell me why I have this error and possibly how to fix it? The files argument is a list of pygame images, outFile is a path, outCodec is default, and info1 is not used anymore. UPDATE 1 This is the code I used to make that list of pygame images. from PIL import ImageGrab import time, pygame pygame.init() f = [] #This is the list that contains the images fps = 1 for n in range(1, 100): info = ImageGrab.grab() size = info.size mode = info.mode data = info.tostring() info = pygame.image.fromstring(data, size, mode) f.append(info) time.sleep(fps)

    Read the article

  • preg_match_all image source

    - by David
    I have the following regex expression which is to extract the source of any img tag in HTML. /(<img).*(src\s*=\s*"([a-zA-Z0-9\.;:\/\?&=\-_|\r|\n]{1,})")/isxmU However, it doesn't appear to be matching the following: <IMG SRC='http://www.mysite.com/pix/lens/mtf/CAEF8512L.gif'> How can I build it to match this as well?

    Read the article

  • Jquery show preloader for every image?

    - by mathiregister
    Hey guys, I've a website with a lot of images: <img class='thumb' src=thumbs/image1.jpg/> <img class='thumb' src=thumbs/image2.jpg/> <img class='thumb' src=thumbs/image3.jpg/> <img class='thumb' src=thumbs/image4.jpg/> I wonder if I can display a loading-div for every single image and when it's loaded the div hides? I'm using jquery for most of my animations. Can i solve that with jquery. It would be cool if every image shows this loading-div centered in the middle of the image. When the image is loaded the div should hide! Is that possible? Thank you for your help!

    Read the article

  • jQuer image hover animate

    - by Ryan Max
    Hello. I have the following jQuery script that makes an orange transparent hover effect cover the image when it's rolled over. How do I make it so this script will animate in and out (with a fade?) $(document).ready(function() { $('#gallery a').bind('mouseover', function(){ $(this).parent('li').css({position:'relative'}); var img = $(this).children('img'); $('<div />').text(' ').css({ 'height': img.height(), 'width': img.width(), 'background-color': 'orange', 'position': 'absolute', 'top': 0, 'left': 0, 'opacity': 0.5 }).bind('mouseout', function(){ $(this).remove(); }).insertAfter(this); }); });

    Read the article

  • Remove space in marquee in html

    - by Suman.hassan95
    I have created a marquee of images for my webpage. But how can the space between the last and the first image be removed to have a continuous effect ?? I am giving the code i used below, <marquee style="overflow:" behavior="scroll" direction="left" OnMouseOver="this.stop()" OnMouseOut="this.start()"> <img src="images/Bluelounge.gif" width="300" height="200" alt="lon"> <img src="images/Southleather.gif" width="300" height="200" alt="south"> <img src="images/Dell-monitor.gif" width="300" height="200" alt="monitor"> <img src="images/Spphire.gif" width="300" height="200" alt="card"> </marquee>

    Read the article

  • Displaying images in one line inside a shorter div

    - by nemiss
    How can I set all images in one line and display only the first 200px of them inside the div? Without breaking the layout, or moving images to a next line. online demo <div id="thumbsContainer"> <ul> <li><img src="http://img214.imageshack.us/img214/6030/small3.jpg" alt="" /></li> <li><img src="http://img263.imageshack.us/img263/5600/small1ga.jpg" alt="" /></li> <li><img src="http://img638.imageshack.us/img638/3521/small4j.jpg" alt="" /></li> <li><img src="http://img682.imageshack.us/img682/507/small5.jpg" alt="" /></li> <li><img src=" http://img96.imageshack.us/img96/6118/small2o.jpg" alt="" /></li> </ul> </div> #thumbsContainer { width:200px; overflow:hidden; } ul { list-style:none; } li { float:left; }

    Read the article

  • Trying to switch header image if on home page

    - by novicePrgrmr
    New to PHP, and wondering what is wrong with this code because its definitely not switching the header img. This is what is used to be: <a href="http://www.finegra.in"><img id="logo" alt="fine grain Logo" src="http://www.finegra.in/wp-content/uploads/2012/04/fineGRAINlogoGOOD-WEB.png"> This is what I changed it to: <?php if (is_home()) { ?> <a href="http://www.finegra.in"><img id="logo" alt="fine grain Logo" src="http://www.finegra.in/wp-content/uploads/2012/09/finegrain-logo-sept.png"> </a> <?php } else { ?> <a href="http://www.finegra.in"><img id="logo" alt="fine grain Logo" src="http://www.finegra.in/wp-content/uploads/2012/04/fineGRAINlogoGOOD-WEB.png"> </a> <?php } ?>

    Read the article

  • Jquery current menu

    - by Isis
    Hello I have: var href = window.location.href; if(href.search('/welcome\\/') > 0) { $('.menuwelcome').css('display', 'block'); $('#welcome2').append('<b>?????????? ??????????</b>').find('a').remove(); $('#welcome2').find('img').attr('src', '/static/images/arrow_black.gif'); } if(href.search('/contacts\\/') > 0) { $('.menuwelcome').css('display', 'block'); $('#mcontacts').append('<b>????????</b>').find('a').remove(); $('#mcontacts').find('img').attr('src', '/static/images/arrow_black_down.gif'); } if(href.search('/sindbad_history\\/') > 0) { $('.menuwelcome').css('display', 'block'); $('.menuwelcome:first').append('<b>???????</b>').find('a').remove(); $('.menuwelcome:first').find('img').attr('src', '/static/images/arrow_black.gif'); } if(href.search('/insurance\\/') > 0) { $('.menusafe').css('display', 'block'); $('#msafe').append('<b>???????????</b>').find('a').remove(); $('#msafe').find('img').attr('src', '/static/images/arrow_black_down.gif'); } if(href.search('/insurance_advices\\/') > 0) { $('.menusafe').css('display', 'block'); $('.menusafe:first').append('<b>???????? ??????????</b>').find('a').remove(); $('.menusafe:first').find('img').attr('src', '/static/images/arrow_black.gif'); } How can I minimize this code? Sorry for bad english

    Read the article

  • Save Bitmap image in a location in C#

    - by acadia
    Hello, I have this function to store the bmp image in a desired location as shown below My question is, how do I save the image in C:\temp folder by default, instead of opening the filedialog box? I want to specify sd.fileName=picname+".bmp" and store it in c:\temp by default. I tried to specify Thanks for your help in advance. I tried to public static bool SaveDIBAs( string picname, IntPtr bminfo, IntPtr pixdat ) { SaveFileDialog sd = new SaveFileDialog(); sd.FileName = picname; sd.Title = "Save bitmap as..."; sd.Filter = "Bitmap file (*.bmp)|*.bmp|TIFF file (*.tif)|*.tif|JPEG file (*.jpg)|*.jpg|PNG file (*.png)|*.png|GIF file (*.gif)|*.gif|All files (*.*)|*.*"; sd.FilterIndex = 1; if( sd.ShowDialog() != DialogResult.OK ) return false; Guid clsid; if( ! GetCodecClsid( sd.FileName, out clsid ) ) { MessageBox.Show( "Unknown picture format for extension " + Path.GetExtension( sd.FileName ), "Image Codec", MessageBoxButtons.OK, MessageBoxIcon.Information ); return false; } IntPtr img = IntPtr.Zero; int st = GdipCreateBitmapFromGdiDib( bminfo, pixdat, ref img ); if( (st != 0) || (img == IntPtr.Zero) ) return false; st = GdipSaveImageToFile( img, sd.FileName, ref clsid, IntPtr.Zero ); GdipDisposeImage( img ); return st == 0; }

    Read the article

  • how to keep the height of the div equal to the union of the height of elements inside it

    - by Idlecool
    I have been making a wordpress template. i got stuck at some place... the problem is, how to maintain the size of a div = the size of p tags and img tags... i have seen that the div only able to contain the p tag but the img tag over flows... i have my code in this following order: <div> <p> some contents <img src="an_image"/> some morecontent</p> <div> what i basically want is: div height = <p> height U(union) <img> height but, what actually i am getting is: div height = <p> height; while <img> over flows i have already checked for similar questions on Stack Overflow but was not able to find one which solves a similar problem.. please give me some idea..

    Read the article

  • Refactor a link and an image

    - by Mihail Stoynov
    I have to write an link with an image inside. Instead of explaining, here's the code I have now: <c:if test="${userSession.loggedUser eq null and company.image != null}"> <a onclick="${rich:component('loginPanel')}.show()"> <img src="/download.do?hash=#{company.image.hash}" /> </a> </c:if> <c:if test="${userSession.loggedUser eq null and company.image == null}"> <a onclick="${rich:component('loginPanel')}.show()"> <img src="${request.contextPath}/img/icons/logo_default.jpg" /> </a> </c:if> <c:if test="${userSession.loggedUser ne null and company.image != null}"> <a href="company.xhtml?${company.name}"> <img src="/download.do?hash=#{company.image.hash}" /> </a> </c:if> <c:if test="#{userSession.loggedUser ne null and company.image == null}"> <a href="company.xhtml?${company.name}"> <img src="${request.contextPath}/img/icons/logo_default.jpg" /> </a> </c:if> This code looks awful - there are two exact links with two exact images but combined in all possible combinations. Is there a better way? Is there a way to avoid c:if - it created tables? Update: Bozho proposes: You can replace <c:if and <a with <h:outputLink rendered="#{..}". Apart from that I don't see any other optimization. But it doesn't work. This does not render correctly: <a href=> <h:outputLink rendered="#{..} <h:outputLink rendered="#{..} </a> (the image is outside the anchor) This does render fine: <h:outputLink value=> <h:outputLink rendered="#{..} <h:outputLink rendered="#{..} </a> , but it always adds href and in two of the cases I don't want href when rendered.

    Read the article

  • JFrame does not refresh after deleting an image

    - by dajackal
    Hi! I'm working for the first time with images in a JFrame, and I have some problems. I succeeded in putting an image on my JFrame, and now i want after 2 seconds to remove my image from the JFrame. But after 2 seconds, the image does not disappear, unless I resize the frame or i minimize and after that maximize the frame. Help me if you can. Thanks. Here is the code: File f = new File("2.jpg"); System.out.println("Picture " + f.getAbsolutePath()); BufferedImage image = ImageIO.read(f); MyBufferedImage img = new MyBufferedImage(image); img.resize(400, 300); img.setSize(400, 300); img.setLocation(50, 50); getContentPane().add(img); this.setSize(600, 400); this.setLocationRelativeTo(null); this.setVisible(true); Thread.sleep(2000); System.out.println("2 seconds over"); getContentPane().remove(img); Here is the MyBufferedImage class: public class MyBufferedImage extends JComponent{ private BufferedImage image; private int nPaint; private int avgTime; private long previousSecondsTime; public MyBufferedImage(BufferedImage b) { super(); this.image = b; this.nPaint = 0; this.avgTime = 0; this.previousSecondsTime = System.currentTimeMillis(); } @Override public void paintComponent(Graphics g) { Graphics2D g2D = (Graphics2D) g; g2D.setColor(Color.BLACK); g2D.fillRect(0, 0, this.getWidth(), this.getHeight()); long currentTimeA = System.currentTimeMillis(); //g2D.drawImage(this.image, 320, 0, 0, 240, 0, 0, 640, 480, null); g2D.drawImage(image, 0,0, null); long currentTimeB = System.currentTimeMillis(); this.avgTime += currentTimeB - currentTimeA; this.nPaint++; if (currentTimeB - this.previousSecondsTime > 1000) { System.out.format("Drawn FPS: %d\n", nPaint++); System.out.format("Average time of drawings in the last sec.: %.1f ms\n", (double) this.avgTime / this.nPaint++); this.previousSecondsTime = currentTimeB; this.avgTime = 0; this.nPaint = 0; } } }

    Read the article

  • Listfield layout question - blackberry

    - by Kai
    I'm having an interesting anomaly when displaying a listfield on the blackberry simulator: The top item is the height of a single line of text (about 12 pixels) while the rest are fine. Does anyone know why only the top item is being drawn this way? Also, when I add an empty venue in position 0, it still displays the first actual venue this way (item in position 1). Not sure what to do. Thanks for any help. The layout looks like this: ----------------------------------- | *part of image* | title | ----------------------------------- | | title | | * full image * | address | | | city, zip | ----------------------------------- The object is called like so: listField = new ListField( venueList.size() ); listField.setCallback( this ); listField.setSelectedIndex(-1); _middle.add( listField ); Here is the drawListRow code: public void drawListRow( ListField listField, Graphics graphics, int index, int y, int width ) { listField.setRowHeight(90); Hashtable item = (Hashtable) venueList.elementAt( index ); String venue_name = (String) item.get("name"); String image_url = (String) item.get("image_url"); String address = (String) item.get("address"); String city = (String) item.get("city"); String zip = (String) item.get("zip"); EncodedImage img = null; try { String filename = image_url.substring( image_url.indexOf("crop/") + 5, image_url.length() ); FileConnection fconn = (FileConnection) Connector.open( "file:///SDCard/Blackberry/project1/" + filename, Connector.READ); if ( !fconn.exists() ) { } else { InputStream input = fconn.openInputStream(); byte[] data = new byte[(int)fconn.fileSize()]; input.read(data); input.close(); if(data.length > 0) { EncodedImage rawimg = EncodedImage.createEncodedImage(data, 0, data.length); int dw = Fixed32.toFP(Display.getWidth()); int iw = Fixed32.toFP(rawimg.getWidth()); int sf = Fixed32.div(iw, dw); img = rawimg.scaleImage32(sf * 4, sf * 4); } else { } } } catch(IOException ef) { } graphics.drawText( venue_name, 140, y, 0, width ); graphics.drawText( address, 140, y + 15, 0, width ); graphics.drawText( city + ", " + zip, 140, y + 30, 0, width ); if(img != null) { graphics.drawImage(0, y, img.getWidth(), img.getHeight(), img, 0, 0, 0); } }

    Read the article

  • jQuery: selecting by class after class change by .addClass() or .attr()

    - by Sosh
    I have some jQuery code something like this: $(document).ready(function() { $("img.off").click(function() { alert('on'); $(this).attr('class', 'on'); }); $("img.on").click(function() { alert('off'); $(this).attr('class', 'off'); }); }); The selector works fine for images that have the class name defined in the original HTML document, however after manipulating the class name with jQuery, the img item will not respond to selectors using it's new class. In other words, running the above code, if you click an 'off' img, it will trigger the first function, and change the class to 'on'. However, clicking this image again does not trigger the second function (as I would have expected), but rather triggers the first again. It's as if the selector is reading the old DOM rather than the updated version. What am I doing wrong here? Firefox 3.6.3 - jQuery 1.4.2

    Read the article

  • How to give the First image in a gallery a different class than the rest of the images - Carrierwave

    - by ChrisBedoya
    I have a model called "Photo" that belongs to a model called "Shoe". I using Carrierwave to upload multiple images. index.html.erb <% shoes.each do |shoe| %> <div class="shoe"> <div class="gallery"> <% shoe.photos.each do |photo| %> <%= link_to image_tag(photo.photo_file.url(:thumb).to_s), photo.photo_file.url.to_s, :class => 'fancybox', :rel => 'gallery' %> <% end %> </div> </div> <% end %> Outputs this: <div class="shoe"> <div class="gallery"> <a class="fancybox" href="../nike-kd-6-meteorology-2.jpg" rel="gallery"> <img src="../thumb_nike-kd-6-meteorology-2.jpg"> </a> <a class="fancybox" href="../nike-kd-6-meteorology-2.jpg" rel="gallery"> <img src="../thumb_nike-kd-6-meteorology-2.jpg"> </a> <a class="fancybox" href="../nike-kd-6-meteorology-2.jpg" rel="gallery"> <img src="../thumb_nike-kd-6-meteorology-2.jpg"> </a> </div> </div> But I want the first image of each gallery to be able to have its own class and the rest of the images to have their own class. Something like this: <a class="firstclass" href="../nike-kd-6-meteorology-2.jpg" rel="gallery"> <img src="../thumb_nike-kd-6-meteorology-2.jpg"> </a> <a class="fancybox" href="../nike-kd-6-meteorology-2.jpg" rel="gallery"> <img src="../thumb_nike-kd-6-meteorology-2.jpg"> </a> <a class="fancybox" href="../nike-kd-6-meteorology-2.jpg" rel="gallery"> <img src="../thumb_nike-kd-6-meteorology-2.jpg"> </a> How can I do this? Also I want each gallery to have its own unique id but when I try to add this: :rel => 'gallery<%= shoe.id %>' I get a Syntax error. Thanks.

    Read the article

  • Is something wrong with this php GD code?

    - by ThinkingInBits
    if ($img = @imagecreatefromjpeg('./images/upload/13/1.JPG')) { imagejpeg($img, $path, 100); imagedestroy($img); } else { die ("image was not created or saved"); } I'm getting the message: Warning: imagejpeg(): 8 is not a valid Image resource in C:\xampp\htdocs\invivid\libraries\photograph_classes.php on line 276 Warning: imagedestroy(): 8 is not a valid Image resource in C:\xampp\htdocs\invivid\libraries\photograph_classes.php on line 277 The image is being created initially, we know this from the if statement, but why doesn't imagejpeg or imagedestroy work properly?

    Read the article

< Previous Page | 22 23 24 25 26 27 28 29 30 31 32 33  | Next Page >