资源描述:
《外文翻译----浅谈SWT图像》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、TakingalookatSWTImagesSummarySWTsImageclasscanbeusedtodisplayimagesinaGUI.ThemostcommonsourceofimagesistoloadfromastandardfileformatsuchasGIF,JPEG,PNG,orBMP.Somecontrols,includingButtonsandTreeitems,areabletodisplayanImagedirectlythroughthesetlmage(lmage)method,butanycontroPspaint
2、eventallowsimagestobedrawnthroughthecallback'sgraphiccontext.SWT'sImageDataclassrepresentstherawdatamakingupanSWTImageanddeterminesthecolorforeachpixelcoordinate.ThisarticleshowsthecorrectusesofImageDataandImage,showshowtoloadimagesfromfiles,andhowtoachievegraphiceffectssuchastran
3、sparency,alphablending,animation,scaling,andcustomcursors・ByJoeWinchester,IBMSeptember10th,2003Thisfirstsectionofthisarticlegivesanintroductiontocolorsandshowshowanimagerecordsthecolorvalueofeachpixel.■Introduction•Imagelifecycle•ImageData■Color•PaletteDmtaoIndexedpaletteoDirectpa
4、letteThenextsectiondescribesimagetransparency,alphablending,animation,andhowtoscaleimages・■Transparency■ManipulatingImageData■SavingImages•BlendinqoSinqlealphavalueoDifferentalphavalueperpixel■Imageeffects■GIFanimation•ScalingFinally,thearticleshowshowtocreatecursorsfromimages,byu
5、singasourceimagetogetherwithamask.•CursorsoPlatformcursorsoCustomcursorsIntroductionThesimplestwaytocreateanSWTImageistoloaditfromarecognizedgraphicfileformat.ThisincludesGIF,BMP(Windowsformatbitmap),JPG,andPNG.TheTIFFformatisalsosupportedinmorerecentEclipsereleases・Imagescanbeloa
6、dedfromaknownlocationinthefilesystemusingtheconstructorImage(Displaydisplay,StringfileLocation):Imageimage=newImage(display,〃C:/eclipse/eclipse/plugins/org.eclipse.platform_2.0.2/eclipse_lg.gif〃);Insteadofhard-codingthelocationoftheimage,itsmorecommontoloadtheImagefromafolderlocat
7、ionrelativetoagivenclass.ThisisdonebycreatinganInputstreampointingtothefilewiththemethodClass.gctRcsourccAsStrcam(Stringname),andusingtheresultastheargumenttotheconstructorImage(Displaydisplay,InputStreaminputStream).TheEclipsepackageexplorerbelowshowstheclasscom.foo.ShellWithButt
8、onShowingEclipseLogoandtheeclipse