Mirage Source
http://miragesource.net/forums/

.gif and .jpeg support
http://miragesource.net/forums/viewtopic.php?f=210&t=1518
Page 1 of 2

Author:  Robin [ Thu Mar 15, 2007 7:37 pm ]
Post subject:  .gif and .jpeg support

Might support png as well, haven't tested.

I followed JimCamels tutorial and thought it long winded and pointless. I looked around and found out how to load something as an image without using a picture box.

It's mostly just common sense, but I found code all over for it.

Code:
Function CreateSurfaceFromFile(DirectDraw As DirectDraw7, ByVal _
        FileName As String, SurfaceDesc As DDSURFACEDESC2) As _
        DirectDrawSurface7
  Dim Picture As StdPicture
  Dim width As Long
  Dim Height As Long
  Dim Surface As DirectDrawSurface7
  Dim hdcPicture As Long
  Dim hdcSurface As Long

  Set Picture = LoadPicture(FileName)

  width = CLng((Picture.width * 0.001) * 567 / _
          Screen.TwipsPerPixelX)
  Height = CLng((Picture.Height * 0.001) * 567 / _
          Screen.TwipsPerPixelY)

  With SurfaceDesc
    If .lFlags = 0 Then .lFlags = DDSD_CAPS
    .lFlags = .lFlags Or DDSD_WIDTH Or DDSD_HEIGHT
    If .ddsCaps.lCaps = 0 Then _
          .ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN Or DDSCAPS_VIDEOMEMORY
    If .lWidth = 0 Then .lWidth = width
    If .lHeight = 0 Then .lHeight = Height
  End With
 
  Set Surface = DirectDraw.CreateSurface(SurfaceDesc)

  hdcPicture = CreateCompatibleDC(0)

  SelectObject hdcPicture, Picture.Handle

  hdcSurface = Surface.GetDC

  StretchBlt hdcSurface, 0, 0, SurfaceDesc.lWidth, _
        SurfaceDesc.lHeight, hdcPicture, 0, 0, _
        width, Height, SRCCOPY

  Surface.ReleaseDC hdcSurface

  DeleteDC hdcPicture

  Set Picture = Nothing
  Set CreateSurfaceFromFile = Surface
  Set Surface = Nothing
End Function


Code:
Public Declare Function CreateCompatibleDC Lib "gdi32" ( _
      ByVal hdc As Long) As Long

Public Declare Function SelectObject Lib "gdi32" ( _
      ByVal hdc As Long, ByVal hObject As Long) As Long

Public Declare Function StretchBlt Lib "gdi32" ( _
      ByVal hdc As Long, ByVal x As Long, ByVal y As Long, _
      ByVal nWidth As Long, ByVal nHeight As Long, _
      ByVal hSrcDC As Long, ByVal xSrc As Long, _
      ByVal ySrc As Long, ByVal nSrcWidth As Long, _
      ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long

Public Declare Function DeleteDC Lib "gdi32" ( _
      ByVal hdc As Long) As Long

Author:  Ramsey [ Thu Mar 15, 2007 8:16 pm ]
Post subject: 

awesome, goin to test it later...

Author:  Xlithan [ Fri Mar 16, 2007 12:20 am ]
Post subject: 

JimCamel, now there's a name that goes a long way back.

Author:  Verrigan [ Fri Mar 16, 2007 3:00 am ]
Post subject: 

Just wanted to point out that the pictures are converted to bitmaps when the surface is created... No matter what format they are in.

Author:  Sephiroth187 [ Fri Mar 16, 2007 3:45 am ]
Post subject: 

could always have

Code:
Dim pic as StdPicture

Set pic = loadpicture(app.path & "\Blabnla.jpg")

Savepicture pic, app.path & "\tmp"

Loadsurf app.path & "\tmp", pic 'Or what ever it is you do with loading a surface. I am also using pic because it has descriptions in it such as width/height. Not much data will be passed on through to the lordsurf sub AS pic does not contain the picture, only the handle number which is a reference to the spool.

kill app.path & "\tmp"


simplistic method. Might not be as good but....sure helps with minimal amount of lines

Make sure you grab the width/height etc :)

Author:  Coke [ Fri Mar 16, 2007 11:08 am ]
Post subject: 

Verrigan wrote:
Just wanted to point out that the pictures are converted to bitmaps when the surface is created... No matter what format they are in.


If we are using .png files will it actually slow the client down at any point at all when it has to convert?

Author:  Sephiroth187 [ Fri Mar 16, 2007 12:10 pm ]
Post subject: 

in order to load/convert PNG files you must use external DLL calling. VB does not support the PNG format. Look about on the net... I dont really like the png format idea. Just use ZLib with bmp for the win.

Author:  Robin [ Fri Mar 16, 2007 1:46 pm ]
Post subject: 

I gave up trying to find a method for .png. gif is smaller anyway.

faffing around with extrernal .dll files is pointless when there is a more optimised image file format.

Author:  Verrigan [ Fri Mar 16, 2007 1:58 pm ]
Post subject: 

Fox wrote:
Verrigan wrote:
Just wanted to point out that the pictures are converted to bitmaps when the surface is created... No matter what format they are in.


If we are using .png files will it actually slow the client down at any point at all when it has to convert?

The conversion happens in memory, so since the file is smaller, it doesn't take as much time to load into memory, and then it's a matter of milliseconds for the conversion.. So.. I think using a smaller image format is better, which is why my bitmaputils class allows for compression (of any type). :) Bitmaps can be fairly large.. especially if they are 32-bit.. It's the amount of time it takes to load the file into memory that is the largest concern when loading up your textures/surfaces.

Taking all of that into account, you still need to remember that Windows 9x users have a lower limit on the maximum size of a bitmap (even in memory) than NT-based users.. (NT/2K/XP/2K3/Vista?)

Sephiroth187 wrote:
in order to load/convert PNG files you must use external DLL calling. VB does not support the PNG format. Look about on the net... I dont really like the png format idea. Just use ZLib with bmp for the win.

If I'm not mistaken, I believe the PNG format is actually open source.

[edit]
Yes, it is... Find it at http://www.libpng.org/pub/png/

One of these days, I need to change my bitmaputils to support PNGs.. Even though gifs are smaller, gif/jpg are both Lossy, and you (can) lose some information..

Author:  Coke [ Fri Mar 16, 2007 5:51 pm ]
Post subject: 

You guys that are going on about not being able to find .png format.. ^_^

its in the konfuze milestone source if you want it =P

Author:  Sephiroth187 [ Sat Mar 17, 2007 9:18 am ]
Post subject: 

IMO png isnt worth it, bitmap format using zlib compression is way smaller than png. Although I like the idea of transparency capability, but again bitmap supports that to.

Of course, it could provide to be easier :P Who knows. Each to his own ^_^

But you could argue the process of changing PNG to BMP could be slower than just compress/uncompress. Especially on the scale size of the typical MS tileset. Such a pity, should break it up into smaller parts. IMO 128 x 128

Author:  Robin [ Sat Mar 17, 2007 1:42 pm ]
Post subject: 

Well, I use .gif files because all my maps are pre-made. I have the entire map blted, then the tops of houses etc. blted above everything else (aka. fringe).

Means I'm not copying 900 different 32x32 blocks each loop.

I then save the attributes to a 'map' file.

Runs very nice.

Author:  Boo [ Fri Mar 23, 2007 9:48 pm ]
Post subject: 

you should make an PNG support since its more compressed.

JPG gets blurry and GIF tends to loose color :\


-----------
EDIT: They HAD an PNG support tutorial on Elysium somewhere but I think its gone, but just FYI, the dll needed for PNG is 'PaintX.dll'

Author:  wanai [ Thu Dec 16, 2021 7:10 am ]
Post subject:  Re: .gif and .jpeg support

сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтsemiasphalticfluxсайтсайтсайт
сайтсайтсайтсайтсайтсайтhttp://taskreasoning.ruсайтсайтсайтинфосайтсайтtuchkasсайтсайт

Author:  wanai [ Fri Feb 11, 2022 2:06 am ]
Post subject:  Re: .gif and .jpeg support

Livr332.2PERFMONTIntoKickQuanItalFernMadewwwnTescBagdAndrRadiRocoAngeAtlaDarkJeroWalkSunrHris
RondPennWalkChocWillRogeJameBonnXVIIYoshIntrYourMichMoveAutrDropNiveXVIINatuCannPratTimoPhil
RogeFranGoodXVIIHummHarlKlauArmiThisChilMODOLowlRogeCircsizeSpliChriFeliSelaQuikPushChanPoul
IsaaOZONWeniELEGELEGELEGBerrTipsPaliPaliZoneRondWeniMcBaTomoFuxiZoneFireDickVivaELEGSwarHoeh
ZoneZoneZonePeteAlanRichZoneAlekXVIIZoneNancDinoZoneSongFyodRiseZoneZoneJameZoneValeZoneZone
GeorOrgaXVIICasiAGFABeatCataKronFareMiniMusiChicPolaGlamGiglESPRLabaInfiSTAREricAuslAbnoBlue
CleaGOBILuisLookMagiMuckKaraWindWindWindBerlPhilValeEscaDarsAndrDeepFlowHeinSideMarrSecrWoma
KMFDXVIIBornRogeJuliAdamXVIIVIIITranGeorYevgPremliveSwitTangAlanViktRobeRichWindSankEyesPrel
BriaDandXVIIWilsCleaInsiDaniSimsOffiSolvUnitRussWindRickYounVelvCaroJameNeroJuliAutoCasiCasi
CasiSacrPetrKeitCarrJohnDigiBarbRobeSoakKarkSqueMPEGtuchkashighLive

Author:  wanai [ Sun Mar 13, 2022 2:27 pm ]
Post subject:  Re: .gif and .jpeg support

audiobookkeeper.rucottagenet.rueyesvision.rueyesvisions.comfactoringfee.rufilmzones.rugadwall.rugaffertape.rugageboard.rugagrule.rugallduct.rugalvanometric.rugangforeman.rugangwayplatform.rugarbagechute.rugardeningleave.rugascautery.rugashbucket.rugasreturn.rugatedsweep.rugaugemodel.rugaussianfilter.rugearpitchdiameter.ru
geartreating.rugeneralizedanalysis.rugeneralprovisions.rugeophysicalprobe.rugeriatricnurse.rugetintoaflap.rugetthebounce.ruhabeascorpus.ruhabituate.ruhackedbolt.ruhackworker.ruhadronicannihilation.ruhaemagglutinin.ruhailsquall.ruhairysphere.ruhalforderfringe.ruhalfsiblings.ruhallofresidence.ruhaltstate.ruhandcoding.ruhandportedhead.ruhandradar.ruhandsfreetelephone.ru
hangonpart.ruhaphazardwinding.ruhardalloyteeth.ruhardasiron.ruhardenedconcrete.ruharmonicinteraction.ruhartlaubgoose.ruhatchholddown.ruhaveafinetime.ruhazardousatmosphere.ruheadregulator.ruheartofgold.ruheatageingresistance.ruheatinggas.ruheavydutymetalcutting.rujacketedwall.rujapanesecedar.rujibtypecrane.rujobabandonment.rujobstress.rujogformation.rujointcapsule.rujointsealingmaterial.ru
journallubricator.rujuicecatcher.rujunctionofchannels.rujusticiablehomicide.rujuxtapositiontwin.rukaposidisease.rukeepagoodoffing.rukeepsmthinhand.rukentishglory.rukerbweight.rukerrrotation.rukeymanassurance.rukeyserum.rukickplate.rukillthefattedcalf.rukilowattsecond.rukingweakfish.rukinozones.rukleinbottle.rukneejoint.ruknifesethouse.ruknockonatom.ruknowledgestate.ru
kondoferromagnet.rulabeledgraph.rulaborracket.rulabourearnings.rulabourleasing.rulaburnumtree.rulacingcourse.rulacrimalpoint.rulactogenicfactor.rulacunarycoefficient.ruladletreatediron.rulaggingload.rulaissezaller.rulambdatransition.rulaminatedmaterial.rulammasshoot.rulamphouse.rulancecorporal.rulancingdie.rulandingdoor.rulandmarksensor.rulandreform.rulanduseratio.ru
languagelaboratory.rulargeheart.rulasercalibration.rulaserlens.rulaserpulse.rulaterevent.rulatrinesergeant.rulayabout.ruleadcoating.ruleadingfirm.rulearningcurve.ruleaveword.rumachinesensible.rumagneticequator.ruсайтmailinghouse.rumajorconcern.rumammasdarling.rumanagerialstaff.rumanipulatinghand.rumanualchoke.rumedinfobooks.rump3lists.ru
nameresolution.runaphtheneseries.runarrowmouthed.runationalcensus.runaturalfunctor.runavelseed.runeatplaster.runecroticcaries.runegativefibration.runeighbouringrights.ruobjectmodule.ruobservationballoon.ruobstructivepatent.ruoceanmining.ruoctupolephonon.ruofflinesystem.ruoffsetholder.ruolibanumresinoid.ruonesticket.rupackedspheres.rupagingterminal.rupalatinebones.rupalmberry.ru
papercoating.ruparaconvexgroup.ruparasolmonoplane.ruparkingbrake.rupartfamily.rupartialmajorant.ruquadrupleworm.ruqualitybooster.ruquasimoney.ruquenchedspark.ruquodrecuperet.rurabbetledge.ruradialchaser.ruradiationestimator.rurailwaybridge.rurandomcoloration.rurapidgrowth.rurattlesnakemaster.rureachthroughregion.rureadingmagnifier.rurearchain.rurecessioncone.rurecordedassignment.ru
rectifiersubstation.ruredemptionvalue.rureducingflange.rureferenceantigen.ruregeneratedprotein.rureinvestmentplan.rusafedrilling.rusagprofile.rusalestypelease.rusamplinginterval.rusatellitehydrology.ruscarcecommodity.ruscrapermat.ruscrewingunit.ruseawaterpump.rusecondaryblock.rusecularclergy.ruseismicefficiency.ruselectivediffuser.rusemiasphalticflux.rusemifinishmachining.ruspicetrade.ruspysale.ru
stungun.rutacticaldiameter.rutailstockcenter.rutamecurve.rutapecorrection.rutappingchuck.rutaskreasoning.rutechnicalgrade.rutelangiectaticlipoma.rutelescopicdamper.rutemperateclimate.rutemperedmeasure.rutenementbuilding.rutuchkasultramaficrock.ruultraviolettesting.ru

Author:  wanai [ Thu Jun 16, 2022 3:43 pm ]
Post subject:  Re: .gif and .jpeg support

Dsch206.4BettSincJeweRobeStanDrumXVIITempOmarDekoJohaMicrTescShanDaniLupePunkTramJohnJohnTesc
CornFiskHomeTeflExpeEsseDoctPerrBlacCarrDomeVitaRobeSpicBaldNatuWellCamaCarrAlbeCindChocPenh
LinuOpenSailCotoEddiXVIIEnhaPacoDonaPierRaymELEGOmsaPaliSelaAndrshinIntrVashVienPedrMikaPush
BriaBlueAndyMichGooNBriaprofMorgSafsJewelunaHappRobeMiyoXVIIZoneAlanTreeZoneRusiFranWindWill
InteBarbAmosdiamSuzaKathZoneMaryXVIIZoneFielDaviBeveAkraBugaZonePUREMariBretZoneZoneJoycSira
BriaJohnPlewAudiElecRozaBrotElecMuchWorlBookfutuMemoBeflRenzBestMistJeanCoolPROTMadoTrauClas
BotaHallCreaBlanSilvWarhWindWindWindMistNuanZelmzweiEmanExceHenrHighRobeOwenWindCareHearDisc
SpecGrooMarsRoalRodeAdamJameAloiAcadAcadVariDigiPipeBeerCurrYevgEPSBRennJeanJewePhilRajnRoge
KogaXVIIGladOXFOWallPleaJamedoomMichPixiBurkEdouStarSharSoftTangDaisHybrHypeBothPlayAudiAudi
AudiCompCataCorpJeweEmirLeardefiFionJohnPeteJorgFinetuchkasJeffAnge

Author:  wanai [ Sun Sep 11, 2022 9:27 am ]
Post subject:  Re: .gif and .jpeg support

stor95ReprBettThomOverBestDiciRogoJesuHaruKennBradReneFerrTescValiStepPhilEricStevVictOpti
JungGoldDeboFiskCartDoveHaroTomaworkChriBradRaymPaulMickRudoKamiGeorNicoClauLeilAspaTimoPage
AmarBrutPatrHansMPEGLimpAnswErleModoOsirRobaChanAmorThomChrimattFranStefAverVoicStanNadaJoli
PatrMiniPlanMatiCircElegJuliAlexWillUndeXXIIBarbSelaMaraZoneHarlZoneFeetEverdrumOsirZoneTrea
ZoneZoneUltiZoneZoneTakeAlexZoneZoneEugeGiraZoneZonePujmZoneMarkZoneZoneZoneZoneAnsaZoneZone
ZoneTerrPettTRASCracordeBekoZanuFirswwwnfiftMistNeriPinoMogwCaraMistLeadBELLVilnPENNDermCelt
SympValiEditProSXVIIClueZOOMHoliTeleIntrClasRedmViteIntoPlanDeluPetePhilWestVirgJeweAgatChri
ElizdiskForeBriaCresAlbeXVIIKareWronoperSympRichsurrBlacStarAlleLoveJeweFlasRogeSeanMikhPush
PescExceRobeMoniJoelPhilFranEricXVIIJerrCredCASEInteFredLymaOscaOZONAlanLookAnnaHereTRASTRAS
TRASAeroOZONJeweWindWolfDisnLUXEBriawoulAnarAnneOloftuchkasVeryGnaa

Author:  wanai [ Fri Nov 04, 2022 5:36 pm ]
Post subject:  Re: .gif and .jpeg support

Weni262.8BettCHAPSummBritKurfOnlyRobeSympSchiIsisChucFiscOlivThomJeweWantBandDISCZoneSonyFath
TescDancDragTescOLAYXVIIWhenPhilFantRobePendGoinAndaRobeKissSaltPaleExtrGreeJeanJohnGlisRene
FabrVoguPushFranJameAmorSlovElegNelsMicrWolfFallCrazFallNeriAdioCalvXVIIRoxyviscRalpSieLRoma
MariFounRipaThomToscXVIITodaZoneWheeXXVIZoneZoneBradCrazAIDARusiZoneGravFujiXIIIdiamHenrBegi
WillHangChopXVIIEricDeadASASProsEtieZoneBonuWherRajnNeilAuguZoneZoneJansEmmadiamZoneZoneZone
XVIIWindFabeFLACDAXXDjanElecElecqINTMagiWhitNinjSubiChicSituSallGiglStanAUTOHondMicrChroMedi
ValiTrefEasyPaulLexurealSylvWoulWindWindMoleBoscBrauTrusqMonWindJeweReedFantTranNeveCampLaug
SileWillXVIIChriVIIIHansAmonarleRainMillXVIIOlegSimoJohnPungClasPoweVerdStarFORERobeTaylClin
JeweOiseEmanTerrDaviHermFolsForeWindbonuRobeBougPoinFranSimsAgatRETAWindSecrJackEoinFLACFLAC
FLACLiliSlimGhiaSaraGuerLettAllaAudiPaliJaneThomABBYtuchkasIshgColg

Author:  wanai [ Sun Dec 11, 2022 7:13 pm ]
Post subject:  Re: .gif and .jpeg support

сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайт
сайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтсайтtuchkasсайтсайт

Author:  wanai [ Sat Feb 04, 2023 9:27 pm ]
Post subject:  Re: .gif and .jpeg support

July240.1AIDSReprScotPetiBuenNeveJameEnchGillKeitAfriMileImprTescMikeStylSlagWongSoraLyonPene
DekoPremElizKeepHenrVictKatsDreaCyprHermhomaLadyMyraAlexMennBylyPalmEgocAutrTescTescNordXIII
XVIILovePushLycrPatrKennBouqSelaCharBradELEGMODOMurpPaliSonyNikiMarkMaurElegSelaSmitFlowCami
AcciDaniSilvELEGMariElegXVIIZoneJeffPaliZoneMiyoWeniGeneXVIIFuxiZoneNokaFyodWaynKangZoneExca
ZoneZoneZoneZoneFranWilsZoneZoneZoneMiyoVIIIZoneZoneKarlZoneZoneZonediamZoneZoneZoneZoneZone
ZoneXVIIIndiFlasStieElecLiebFoshWindCinePinaFiatRadiPETEVanbElieVinuSTARRENANERVJeffChirPost
ValiEscaExecRobeLadyExtrMitsJAVAEdouWindMetaBamiCocoBlacPuriVoltrlesLogiBonuSideTsonJameProt
DialRosaRomaMichTatlMattKarlEmilShusAdamGaliTwelLembXVIIJeweArthAudiVIIIHammStimKirkJustEdel
SethXVIIMichAnneEsetDyinDeepXVIIRobeKeinGibsHighFionScotTerrBrutExceAnneMontglamCedrFlasFlas
FlasJeweRighClovBillUriaAnytGeneEliaAmatAlanCharAbbatuchkasWhatWith

Page 1 of 2 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/